10
Belajar Membuat Sistem Keamanan Sederhana Berbasis webcam dengan Camserv dan Motion di Ubuntu By:Daywalker@Datakom-C223 http://www.ittelkom.ac.id/pinguin http://iwing.wordpress.com Ting-tong ting-tong “you got mail”, alangkah terkejutnya Iwing pagi ini tatkala dalam inbox email barunya terdapat sebuah email yang dikirim oleh bosnya, bunyi emailnya adalah sebagai berikut. “Selamat pagi Mr.iwing Karena sering terjadinya tindak pengutilan dikantor cabang kita, maka saya meminta saudara untuk membuatkan suatu sistem mata-mata berbasis web yang bisa diremote dari kantor pusat. Tolong dikerjakan a.s.ap Best regards Mr.Malcom-X” Nah teman-teman, pada kesempatan kali ini saya akan mencoba membantu Mr. Iwing dalam memecahkan case yang diberikan Mr.Malcom-X kepadanya. Topology lab yang saya gunakan adalah seperti gambar 1 berikut: Gambar 1

Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

  • Upload
    iwing

  • View
    2.928

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

Belajar Membuat Sistem Keamanan Sederhana

Berbasis webcam dengan Camserv dan Motion di Ubuntu

By:Daywalker@Datakom-C223

http://www.ittelkom.ac.id/pinguin

http://iwing.wordpress.com

Ting-tong ting-tong “you got mail”, alangkah terkejutnya Iwing pagi ini tatkala dalam

inbox email barunya terdapat sebuah email yang dikirim oleh bosnya, bunyi emailnya adalah

sebagai berikut.

“Selamat pagi Mr.iwing

Karena sering terjadinya tindak pengutilan dikantor cabang kita, maka saya meminta

saudara untuk membuatkan suatu sistem mata-mata berbasis web yang bisa diremote dari

kantor pusat. Tolong dikerjakan a.s.ap

Best regards

Mr.Malcom-X”

Nah teman-teman, pada kesempatan kali ini saya akan mencoba membantu Mr. Iwing

dalam memecahkan case yang diberikan Mr.Malcom-X kepadanya.

Topology lab yang saya gunakan adalah seperti gambar 1 berikut:

Gambar 1

Page 2: Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

Sebagai informasi :

Komputer Server yang saya gunakan menggunakan sistem operasi ubuntu 9.04

Pada computer Server dibutuhkan perangkat tambahan berupa webcam

Pada server diinstall paket software camserv dan motion

(camserv digunakan sebagai aplikasi untuk streaming video, sedangkan motion sebagai

streaming video sekaligus bisa mengcapture objek dengan prinsip motion detect, hasil

capture akan dismpan dalam format jpg)

Untuk pengujian di computer pengamat menggunakan browser Mozilla

Langkah-langkah pembuatan Server mata-matanya adalah sebagai berikut:

1. Install Software camsev dan motion menggunakan bantuan synaptic manager

(seperti terlihat pada gambar2 dan gambar 3)

Gambar 2

Page 3: Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

Gambar 3

2. Kita edit konfigurasi camserv.cfg didalam folder /etc/camserv

Gambar 4

Konfigurasinya adalah sebagai berikut

# video_basic: The 'basic' color-changing video module.

[video_basic]

path /usr/lib/camserv/libvideo_basic.so.0

# video_v4l_bttv: Example of a common BTTV module for video4linux.

# port 0 == TV, port 1 = Composite 1, port 2 = Composite 2

# frequency == is the channel frequency for the TV

# autobright == 0 turns off autobrightness adjusting, otherwise it

adjusts

# the brightness of the picture every 'autobright' frames.

# brightmean == The mean pixel value that is the 'goal' of the

autobright.

# (0->255)

# brightx1->y2 == (x1,y1) top left coords, and (x2,y2) bottom right

coords

# of a rectangle of which to take the average pixel

Page 4: Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

value.

# this is then used in calculating the mean to adjust

the

# brightness of the image.

# mode == the video norm to use: 0 == PAL, 1 == NTSC, 2 == SECAM, 3 ==

AUTO

# color,hue,contrast,brightness,whiteness = 0->60000, representing

# the value of each component.

[video_v4l_bttv]

path /usr/lib/camserv/libvideo_v4l.so.0

device_path /dev/video0

port 0

mode 3

#frequency 74.43

color 30000

hue 30000

contrast 30000

brightness 30000

whiteness 30000

autobright 1

brightmean 128

brightx1 0

brighty1 320

brightx2 0

brighty2 240

# FreeBSD BTTV driver:

# port 0 = Video

# 1 = Tuner

# Channel Sets:

# nabscst 1

# cableirc 2

# cablehrc 3

# weurope 4

# jpnbcst 5

# jpncable 6

# xussr 7

# australia 8

[video_fbsd_bttv]

path /usr/lib/camserv/libvideo_fbsd_bttv.so.0

port 1

width 320

height 240

autobright 100

#brightness 0

#chroma 180

#contrast 1000

channelset 2

channel 60

[video_v4l_qcam]

path /usr/lib/camserv/libvideo_v4l.so.0

device_path /dev/video1

port 0

color 30000

hue 30000

contrast 30000

brightness 30000

whiteness 30000

autobright 0

[jpg_filter]

path /usr/lib/camserv/libjpg_filter.so.0

quality 30

# text_filters: Text filters are used to provide text on your webcam

Page 5: Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

# bg,fg == #RRGGBB if RGB camera, #CC if B&W camera,else

'transparent'

# x,y == Coordinates for the text

# mangle == 0 turns off mangling of the 'text', 1 turns it on

# text == Text to display. If mangling == 1, special metachars

# such as '%X' will be expanded -- see date(1) for lots

of

# flags

# fontname == 6x11 or 8x8 for the fontsize.

[hello_world_banner]

path /usr/lib/camserv/libtext_filter.so.0

text Hello World

bg #000000

fg #ffffff

x 0

y 0

mangle 0

fontname 6x11

[time_stamp]

path /usr/lib/camserv/libtext_filter.so.0

text Time: %X

bg #000000

fg #ffffff

x 0

y 11

mangle 1

fontname 8x8

[static_filter]

path /usr/lib/camserv/librand_filter.so.0

num_perline 20

coloredpix 0

#

# You can add the imlib2_filter to your filters list to display pictures

# over your own, or small regions, or whatever your heart desires.

[imlib2_filter]

path /usr/lib/camserv/libimlib2_filter.so.0

file /tmp/my_nasty_picture.png

x 0

y 0

##########################################

# Begin Fixed Sections #

##########################################

# socket parameters:

# listen_port = port the camserv program listens on

# max_frames = Maximum # of frames to send to the client before

# closing the connection (0 disables)

# max_bytes = Maximum # of bytes to send to a client before

# closing the connection (0 disables)

# max_seconds = Maximum # of seconds a client can be connected

before

# being closed (0 disables)

[socket]

listen_port 9192

max_frames 0

max_bytes 0

max_seconds 0

[filters]

num_filters 2

filter0_section time_stamp

filter1_section jpg_filter

# [video] - This section is devoted to all things dealing with the

pictures

Page 6: Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

# taken by the input video module. These are general things

which

# should be used by all video modules.

#

# IMPORTANT: If you are seeing cycling colours instead of the

# video for your camera, you need to change

video_basic

# to video_v4l_qcam or video_v4l_bttv

[video]

video_section video_v4l_bttv

width 320

height 240

#width 200

#height 150

maxfps 0

memhack 1

[main]

# To do a single time invocation of the output from the camserv,

# use output_snapfile which designates the output location, and

# output_presnaps to take a number of pictures before finally outputting

# the final image.

#output_snapfile foo.jpg

#output_presnaps 100

3. Kita edit konfigurasi motion.conf didalam folder /etc/motion

Gambar 5

Konfigurasinya adalah sebagai berikut

# Minimal motion example config file provided by the

# Debian motion package - for basic webcam operation.

# You most certainly want to investigate

# /usr/share/doc/motion/examples/motion-dist.conf.gz

# for further configuration options. Also, refer to the

# motion man page and /usr/share/doc/motion/motion_guide.html

# for detailed information on configuration options.

daemon off

quiet on

# You may very well need to change this (check with 'dmesg'

# after plugging in your webcam).

videodevice /dev/video0

# Image size in pixels (valid range is camera dependent).

width 320

height 240

framerate 25

quality 85

auto_brightness off

Page 7: Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

# General threshold level and noise threshold

# level (for distinguishing between noise and motion).

threshold 4500

noise_level 64

# Initial brightness, contrast, hue (NTSC), and saturation.

# 0 = disabled (valid range 0-255).

brightness 0

contrast 0

saturation 0

hue 0

# Encode movies in real-time (install ffmpeg before enabling).

ffmpeg_cap_new off

# Codec to be used by ffmpeg for the video compression.

# Supported formats: mpeg4, msmpeg4.

ffmpeg_video_codec msmpeg4

# Target base directory for pictures and films (you may need

# to change this (or change its permissions) depending on

# which system user runs motion).

#target_dir /var/lib/motion/snapshots

target_dir /home/harry/motion/public

# Define a port number (e.g. 8000) to enable the mini-http server.

# 0 = disabled.

webcam_port 9192

# Set to 'off' to allow anybody (not just localhost) to view the

# webcam via the mini-http server (http://hostname:port).

webcam_localhost off

webcam_quality 50

webcam_maxrate 8

NB: konfigurasi camserv.conf dan motion.conf berdasarkan referensi no [2]

4. Jalankan camservnya seperti terlihat pada gambar 6

Gambar 6

5. Jalankan motionnya seperti terlihat pada gambar 7

Gambar 7

Page 8: Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

Gambar 8

Page 9: Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

6. Untuk pengujian, di computer pengamat 1 dan 2, buka browser Mozilla dan ketikan ip

dan port dari server mata-mata kita (dalam kasus saya adalah

http://192.168.10.35:9192). Jika konfigurasi kita tidak ada yang salah maka akan

keluar seperti pada gambar 9

Gambar 9

Page 10: Belajar Membuat Sistem Keamanan Sederhana Dengan Camserv Dan Motion Di Ubuntu

7. Hasil capture-an akan disimpan di folder /home/harry/motion/public dengan format

gambar adalah .jpg, seperti pada gambar 10

Gambar 10

Ref:

[1].http://www.ubuntu.com

[2].Wijayanto.2008.Tugas Akhir: DESIGN AND IMPLEMENTATION SECURITY SYSTEM USING CCTV OVER IP AT IT TELKOM BANDUNG:IT Telkom

############Sekian dulu teman-teman semoga bermanfaat############