DIY : CCTV Server with Ubuntu Server 12.04 + Motion + USB Webcam(s)

Building CCTV Server with Ubuntu Server 12.04 + Motion + USB Webcam(s)

What you need:

  1. PC with Ubuntu Server Installed
  2. PCI USB Card(s), as 1 USB Controller only capable of handling 2 USB Webcams
  3. Webcam(s). Make sure they work in linux. I have bought cheap webcams from Ebay, which are detected automatically by Ubuntu
  4. Optional : IR Illuminator
  5. WIP :  Utilizing USB RJ45 Extender

Steps:

1. Preparing Server & installing Motion

Update your server repo to the latest :

 sudo apt-get update

Install motion :

sudo apt-get install motion

2. Tweaking uvcvideo driver

sudo rmmod uvcvideo
sudo modprobe uvcvideo quirks=128

This will be reset every reboot. If this works, create the following file:

sudo pico /etc/modprobe.d/uvcvideo.conf

containing the line:

options uvcvideo quirks=128

3. Configuring Motion for multiple threads, storage location, etc

The configuration file is located at : /etc/motion/motion.conf

Suggestion : comment out the device in motion conf and configure each camera with their separate thread conf file

Make sure to add line of each thread file in the last line of the motion.conf

thread /etc/motion/camera1.conf

thread /etc/motion/camera2.conf

…..

thread /etc/motion/camera6.conf

Example content of camera1.conf ( pay attention to bold line):

root@cctv01:~# cat /etc/motion/camera1.conf
# /usr/local/etc/thread1.conf
#
# This config file was generated by motion 3.2.12

 

###########################################################
# Capture device options
############################################################

# Videodevice to be used for capturing (default /dev/video0)
# for FreeBSD default is /dev/bktr0
videodevice /dev/video2

# The video input to be used (default: 8)
# Should normally be set to 1 for video/TV cards, and 8 for USB cameras
input 8

# Draw a user defined text on the images using same options as C function strftime(3)
# Default: Not defined = no text
# Text is placed in lower left corner
text_left CAMERA 1
############################################################
# Target Directories and filenames For Images And Films
# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename
# you can use conversion specifiers
# %Y = year, %m = month, %d = date,
# %H = hour, %M = minute, %S = second,
# %v = event, %q = frame number, %t = thread (camera) number,
# %D = changed pixels, %N = noise level,
# %i and %J = width and height of motion area,
# %K and %L = X and Y coordinates of motion center
# %C = value defined by text_event
# Quotation marks round string are allowed.
############################################################

# Target base directory for pictures and films
# Recommended to use absolute patch. (Default: current working directory)
#target_dir /usr/local/apache2/htdocs/cam1
############################################################
# Live Webcam Server
############################################################

# The mini-http server listens to this port for requests (default: 0 = disabled)
webcam_port 8081

# Command to be executed when a picture (.ppm|.jpg) is saved (default: none)
# The filename of the picture is appended as an argument for the command.
#on_picture_save /usr/local/motion-extras/camparse1.pl

# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none)
# Filename of movie is appended as an argument for the command.
#on_movie_end /usr/local/motion-extras/mpegparse1.pl

Test & run motion :

sudo /etc/init.d/motion start

check syslog, make sure no error. You should see something like this:

Jul 20 10:43:52 cctv01 motion: [5] Using palette YUYV (352×288) bytesperlines 704 sizeimage 202752 colorspace 00000000
Jul 20 10:43:52 cctv01 motion: [5] found control 0x00980900, “Brightness”, range 0,255
Jul 20 10:43:52 cctv01 motion: [5] #011″Brightness”, default 140, current 102
Jul 20 10:43:52 cctv01 motion: [5] found control 0x00980901, “Contrast”, range 0,127
Jul 20 10:43:52 cctv01 motion: [5] #011″Contrast”, default 36, current 36
Jul 20 10:43:52 cctv01 motion: [5] found control 0x00980902, “Saturation”, range 0,127
Jul 20 10:43:52 cctv01 motion: [5] #011″Saturation”, default 80, current 80
Jul 20 10:43:52 cctv01 motion: [5] found control 0x00980903, “Hue”, range -15,15
Jul 20 10:43:52 cctv01 motion: [5] #011″Hue”, default -3, current -3
Jul 20 10:43:52 cctv01 motion: [5] found control 0x00980910, “Gamma”, range 1,3
Jul 20 10:43:52 cctv01 motion: [5] #011″Gamma”, default 2, current 2
Jul 20 10:43:52 cctv01 motion: [5] mmap information:
Jul 20 10:43:52 cctv01 motion: [5] frames=4
Jul 20 10:43:52 cctv01 motion: [5] 0 length=202752
Jul 20 10:43:52 cctv01 motion: [5] 1 length=202752
Jul 20 10:43:52 cctv01 motion: [5] 2 length=202752
Jul 20 10:43:52 cctv01 motion: [5] 3 length=202752
Jul 20 10:43:52 cctv01 motion: [5] Resizing pre_capture buffer to 1 items
Jul 20 10:43:53 cctv01 motion: [2] Started stream webcam server in port 8082
Jul 20 10:43:53 cctv01 motion: [2] Resizing pre_capture buffer to 2 items
Jul 20 10:43:53 cctv01 motion: [6] Started stream webcam server in port 8086
Jul 20 10:43:53 cctv01 motion: [6] Resizing pre_capture buffer to 2 items
Jul 20 10:43:53 cctv01 motion: [1] Started stream webcam server in port 8081
Jul 20 10:43:53 cctv01 motion: [1] Resizing pre_capture buffer to 2 items
Jul 20 10:43:53 cctv01 motion: [5] Started stream webcam server in port 8085
Jul 20 10:43:53 cctv01 motion: [5] Resizing pre_capture buffer to 2 items
Jul 20 10:43:53 cctv01 motion: [4] Started stream webcam server in port 8084
Jul 20 10:43:53 cctv01 motion: [4] Resizing pre_capture buffer to 2 items
Jul 20 10:43:53 cctv01 motion: [3] Started stream webcam server in port 8083
Jul 20 10:43:53 cctv01 motion: [3] Resizing pre_capture buffer to 2 items

4. IR Filter Mod &  utilizing IR Illuminator

http://www.instructables.com/id/Hacked-WebCam-for-IR-Photography-and-Night-Vision/

5. Mod for outdoor usage:

http://www.instructables.com/id/Convert-a-Webcam-to-work-outdors-in-bright-light/

6. BROKEN WIP : Utilizing USB RJ45 Extender

useful links :

http://renoirsrants.blogspot.com/2011/07/multiple-webcams-on-zoneminder.html

http://adhi.widjajanto.net/blog/archives/2011/12/my_home_server.html (in bahasa Indonesia)

http://www.instructables.com/id/Hacked-WebCam-for-IR-Photography-and-Night-Vision/

http://www.instructables.com/id/Convert-a-Webcam-to-work-outdors-in-bright-light/

pfsense 2 under VMware server 2( was Work on progress : running pfsense 2.0 (based on freebsd 8.1) under xenserver 5)

Few months ago, I had zero success with pfsense 2.0 under xenserver. This project is pretty important, since pfsense 2.0 offers a lot of improvement.

Posted with WordPress for BlackBerry.

Update March 2011:

A lot of thing has changed. Xenserver has finally given its place for VMware server 2. One of the reason is the later ability to host pfsense 2 guest.

So far with RC version, everything is running pretty nice. I love the traffic shape – limiter feature, useful to limit client connection with multiple combination, source/destination/total bucket based rules. Thanks pfsense, and VMware.

Room for improvement/ more homework:
1. Managing optimal guest bootup delay at startup.
2. Tweaking network performance.

Stay tuned.

Clevo TN120R Touchscreen TC4UM WORKED in Ubuntu Jaunty & Karmic

This how to probably will only work for ‘ET&T Technology TC4UM with device  ID 0664:0306 on Clevo TN120R running Ubuntu Hardy/Intrepid/Jaunty/Karmic.

Extract the driver from magictouch website (Linux_USB_V2.20_ub904_090430[i386].tar.gz) and you will find these objects:

drwxr-xr-x 4 dedieko dedieko 4096 2009-04-29 10:19 .
drwxr-xr-x 3 dedieko dedieko 4096 2009-11-26 10:35 ..
drwx—— 2 dedieko dedieko 4096 2009-11-26 07:16 driver
-rwxrwxrwx 1 dedieko dedieko 4116 2009-04-28 14:18 install_Ubuntu9.04
-rwxrwxrwx 1 dedieko dedieko 2085 2009-04-28 14:28 uninstall_Ubuntu9.04
drwx—— 2 dedieko dedieko 4096 2009-11-26 07:16 utility

Instead of running Install_Ubuntu9.04, I wanted to know how things work, so we go with the manual way.
Go to driver folder and you will find 1 file:

-rwxr-xr-x 1 dedieko dedieko 75285 2009-04-29 10:05 etouch_drv.so

Copy this file to /usr/lib/xorg/modules/input
Go to utility folder and youwill find 3 files:

-rwxr-xr-x 1 dedieko dedieko 31706 2009-04-29 09:12 Calibration
-rwxr-xr-x 1 dedieko dedieko 14829 2008-12-10 14:33 Lift-off
-rwxr-xr-x 1 dedieko dedieko 29058 2009-04-28 15:57 Swap

Copy these files to /etc/etandt folder. Don’t forget to change the file ownership. Safest bet is to chmod 777

  • STEP 3: Configure xorg.conf

If you use freshly installed Karmic, there is no xorg.conf, you could run this command to generate default Xorg.conf:

sudo dpkg-reconfigure -phigh xserver-xorg

Then edit the newly generated xorg.conf. Add ServerLayout Section and InputDevice Section
The hardest thing is probably to pinpoint the device location. Type this:

lshal | grep hiddev

Mine is look like this:

dedieko@dedieko-laptop:~$ lshal | grep hiddev
udi = ‘/org/freedesktop/Hal/devices/usb_device_664_306_noserial_if0_hiddev’
  hiddev.application_pages = {‘Unknown page 0xd0004’} (string list)
  hiddev.device = ‘/dev/usb/hiddev0‘  (string)
  hiddev.product = ‘ET&T Technology TC4UM’  (string)
  info.capabilities = {‘hiddev’} (string list)
  info.category = ‘hiddev’  (string)
  info.udi = ‘/org/freedesktop/Hal/devices/usb_device_664_306_noserial_if0_hiddev’  (string)
  linux.device_file = ‘/dev/usb/hiddev0’  (string)
  linux.sysfs_path = ‘/sys/devices/pci0000:00/0000:00:1d.2/usb7/7-1/7-1:1.0/usb/hiddev0’  (string)
dedieko@dedieko-laptop:~$

Pay attention to the red line, now write that or memorize it, then put it in the Xorg.conf below.
Mine is look like this:

Section “Monitor”
    Identifier    “Configured Monitor”
EndSection

Section “Screen”
    Identifier    “Default Screen”
    Monitor        “Configured Monitor”
    Device        “Configured Video Device”
    SubSection “Display”
        #Virtual    2560 1024
        Virtual    4096 4096
    EndSubSection
EndSection

Section “Device”
    Identifier    “Configured Video Device”
    Option “AccelMethod” “UXA”
    #Option “MigrationHeuristic” “Greedy”
EndSection

Section “ServerFlags”
    Option    “DontZap”    “False”
EndSection

Section “InputDevice”
    Identifier “ETouch”
    Driver “ETouch”
    Option “Device” “/dev/usb/hiddev0”
EndSection

Section “ServerLayout”
    Identifier “Layout01”
    InputDevice “ETouch” “SendCoreEvents”
EndSection

Pay attention only to the part mark with red color. Save it and restart your system.
If you type it correctly, there should be no problem. If you do encounter problems, boot your system using Recovery Mode ( Select it from Boot Menu by pressing ESC), and check the Xorg log at /var/log/Xorg.0.log
Read the log carefully and then make changes to Xorg.conf, restart your system again by either type:

 sudo reboot -n

or simply by pressing

Ctrl+Alt+Del

When you got things right, your GUI will load, you touch screen will function, BUT… still not calibrated

  • STEP 4: Calibration
Before you proceed, please make sure you unplug any external monitor and set the permission correctly.
Go to /etc/etandt folder and run this

sudo /etc/etandt/Calibration

If you dont use sudo, you will get Segmentation Fault
You’ll see white screen with small crossed circle. Press the center of it as precise as possible. You can cancel anytime by pressing Ctrl+C

You’re done.

References:
http://ubuntuforums.org/showthread.php?t=677833
http://magictouch.com/support_usb_xd.html
http://www.qbik.ch/usb/devices/showdescr.php?id=4460
http://forum.ubuntu-fr.org/viewtopic.php?pid=3073235 (in French)
http://widi-atmono.blogspot.com/2009/11/install-driver-touch-screen-m912m-di.html

Ubuntu – How to Restart Freezed/Hang Gnome Panel

After upgrading to Jaunty, in Compiz sometimes I get a lot of Gnome-Panel Freezes, hovering the mouse cursor over it won’t trigger any response.

This freezes usually triggered by pressing Alt-F2.

So, the gnome-panel has to be restarted with this command:

killall gnome-panel

nohup gnome-panel –replace &

References:

http://mylinuxnotebook.blogspot.com/2008/09/restart-gnome-panel.html

Cairo Dock bug? – /usr/share/menu/cairo-dock: 1: Syntax error: word unexpected (expecting “)”)

it’s been some times that everytime I did apt-get to install some stuff, I always found this line somewhere in the console output:

Processing triggers for menu …
/usr/share/menu/cairo-dock: 1: Syntax error: word unexpected (expecting “)”)
Execution of /usr/share/menu/cairo-dock generated no output or returned an error.

But, strangely, the cairo dock itself is running just fine, in my desktop
Kinda annoying though….

Wvdial Setting for Ubuntu Intrepid + Sierra Wireless GSM USB Modem + Indosat IM3 Prepaid

Finally, after some googling and trial-error, this is the latest setting:

[Dialer im3]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,”IP”,”indosatgprs”
Modem Type = USB Modem
ISDN = 0
New PPPD = yes
Phone = *99***1#
Modem = /dev/ttyUSB0
Username = gprs
Password = im3
Baud = 460800
Auto Reconnect = On
Stupid Mode = 1

Technorati Tags: , ,

Add support for IPCOP – Advanced Proxy – Update Accelerator to cache Antivirus ESET Nod32 update files

I’ve been digging and foraging for infos about this one. The author of this ipcop great plugin, stated in the FAQ that it is possible to add custom rules for Update Accelerator, but can’t seem to find the guide anywhere.

Here are my findings so far :

Simply edit this file in your IPCOP box:

/usr/sbin/updxlrator

and you will find these lines :

while (<>) {

    $request=$_;

    @tmp=split(/ /,$request);
    chomp(@tmp);

    $source_url = $tmp[0];
    $hostaddr   = $tmp[1]; while ($hostaddr =~ /.*/$/) { chop $hostaddr; }
    $username   = $tmp[2]; if ($username eq ”) { $username=’-‘; };
    $method     = $tmp[3];

    $xlrator_url = $source_url;

    if (($method eq ‘GET’) || ($method eq ‘HEAD’))
    {

    # ———————————————————–
    #  Section: Windows Update / Windows Downloads
    # ———————————————————–

    if (
        (($source_url =~ m@^http://[^/]*.microsoft.com/.*.(exe|psf|msi|msp|cab)$@i) ||
         ($source_url =~ m@^http://[^/]*.windowsupdate.com/.*.(exe|psf|msi|msp|cab)$@i))
    &&   ($source_url !~ m@^http://[^/]*.microsoft.com/.*(/autoupd|selfupdate/).*.cab@i)
    &&   ($source_url !~ m@&@)
       )
    {
        $xlrator_url = &check_cache($source_url,$hostaddr,$username,”Microsoft”,$unique);
    }

    # ———————————————————–
    #  Section: Adobe Downloads
    # ———————————————————–

    if (
        ($source_url =~ m@^http://(ar)?download.adobe.com/.*.(exe|msi|bin|dmg|idx|gz)$@i) ||
        ($source_url =~ m@^http://swupdl.adobe.com/updates/.*.(exe|msi|bin|dmg|idx|gz|[a-z][a-z]_[A-Z][A-Z])$@i) ||
        ($source_url =~ m@^http://swupmf.adobe.com/manifest/.*.upd$@i)
       )
    {
        $xlrator_url = &check_cache($source_url,$hostaddr,$username,”Adobe”,$unique);
    }

    # ———————————————————–
    #  Section: Linux Downloads
    # ———————————————————–

    if ($source_url =~ m@^[h|f]t?tp://[^?]+.(deb|rpm)$@i)
    {
        $xlrator_url = &check_cache($source_url,$hostaddr,$username,”Linux”,$mirror);
    }

    # ———————————————————–
    #  Section: Trend Micro Downloads
    # ———————————————————–

    if (
        ($source_url =~ m@^http://[^/]*.trendmicro.com/activeupdate/.*@i) &&
        ($source_url !~ m@.*/tmnotify.dat$@i) &&
        ($source_url !~ m@.*/ini_xml.zip$@i) &&
        ($source_url !~ m@.*/server.ini$@i)
       )
    {
        $xlrator_url = &check_cache($source_url,$hostaddr,$username,”TrendMicro”,$mirror);
    }

    # ———————————————————–
    #  Section: Symantec Downloads
    # ———————————————————–

    if ($source_url =~ m@^[h|f]tt?p://[^/]*.symantec(liveupdate)?.com/.*.(exe|zip|vdb|xdb)$@i)
    {
        $xlrator_url = &check_cache($source_url,$hostaddr,$username,”Symantec”,$unique);
    }

    # ———————————————————–
    #  Section: Apple Downloads
    # ———————————————————–

    if (
        (($source_url =~ m@^http://swcdn.apple.com/content/downloads/.*.(tar)$@i) ||
         ($source_url =~ m@^http://appldnld.apple.com.edgesuite.net/.*.(exe|dmg)$@i) ||
         ($source_url =~ m@^http://.*.g.akamai.net/.*/3093/1/.*.(tar|pkg|dmg|exe)$@i))
       )
    {
        $xlrator_url = &check_cache($source_url,$hostaddr,$username,”Apple”,$unique);
    }

    # ———————————————————–
    #  Section: Avast Downloads
    # ———————————————————–

    if ($source_url =~ m@^http://download[d]+.avast.com/.*.(exe|vpu)$@i)
    {
        $xlrator_url = &check_cache($source_url,$hostaddr,$username,”Avast”,$mirror);
    }
   

    # ———————————————————–

    }

Simply add these lines, just below the Avast section:

    # ———————————————————–

    #  Section: NOD Downloads

    # ———————————————————–

    if ($source_url =~ m@^[h|f]t?tp://[^?]+.(nup|ver|)$@i)

    {

        $xlrator_url = &check_cache($source_url,$hostaddr,$username,”Other”,$mirror);

    }

I’m using the Linux section as the template, which is the easiest template compare to others. What do those line mean?

$source_url =~ m@^[h|f]t?tp://[^?]+.(nup|ver|)$@i)

translate: UA should cache  nup and ver files…

$source_url =~ m@^[h|f]t?tp://[^?]+.(nup|ver|)$@i)

translate: and the URLS could be anywhere…

$source_url =~ m@^[h|f]t?tp://[^?]+.(nup|ver|)$@i)

translate: and it doesn’t matter whether it is http or ftp…

Pay attention to this:

$xlrator_url = &check_cache($source_url,$hostaddr,$username,”Other“,$mirror);

It’s vendorid flag, which indicated that these NUP and VER files should use Other flag in the UA web interface. If you want to mess around and add your own image/category, edit this file

/home/httpd/cgi-bin/updatexlrator.cgi

find these line :

print “tt “;
            if ($vendorid =~ /^Adobe$/i)
            {
                print “Adobe n”;
            } elsif ($vendorid =~ /^Microsoft$/i)
            {
                print “Microsoft n”;
            } elsif ($vendorid =~ /^Symantec$/i)
            {
                print “Symantec n”;
            } elsif ($vendorid =~ /^Linux$/i)
            {
                print “Linux n”;
            } elsif ($vendorid =~ /^TrendMicro$/i)
            {
                print “Trend Micro n”;
            } elsif ($vendorid =~ /^Apple$/i)
            {
                print “Apple n”;
            } elsif ($vendorid =~ /^Avast$/i)
            {
                print “Avast n”;
            } else
            {
                if (-e “/home/httpd/html/images/updxl-src-” . $vendorid . “.gif”)
                {
                    print “" . ucfirst $vendorid . " n”;
                } else {
                    print “" . ucfirst $vendorid . " n”;
                }
            }

Maybe there are other files or lines that should be edited as well, I don’t know yet.
Technorati Tags: ,