Linux:software:webam

From Linux How-To Repository

Jump to: navigation, search

Webcam Programs

Webcam

Configuration File Parameters

       [grab]
       device = /dev/video0
       text = "webcam %Y-%m-%d %H:%M:%S"
       infofile = filename
       fg_red = 255
       fg_green = 255
       fg_blue = 255
       width = 320
       height = 240
       delay = 3
       wait = 0
       input = composite1
       norm = pal
       rotate = 0
       top = 0
       left = 0
       bottom = -1
       right = -1
       quality = 75
       trigger = 0
       once = 0

This middle bit is optional and also comes under "grab"

       distor = 1
              If distor param is set to 1, the correction of distortion works.
       distor_k = 700
              This  is  the coefficient of distortion. This algorithm is based
              on the paper "Correcting Distortion of Image by Image  Registra‐
              tion" of Toru Tamaki, Tsuyoshi Yamamura and Noboru Ahnishi. More
              your lens has an important distortion, more ’distor_k’  must  be
              neared  of 0. 700 is the default value. Coefficient k of program
              is x100 than article.
       distor_cx = 192
       distor_cy = 144
              Coordinates of the lens optical axis: width/2 and  height/2  are
              the  default  values. The axis doesn’t go through the image cen‐
              ter. So, you can change its coordinates  around  the  center  of
              image to affine correction.
       distor_zoom = 30
              Zoom  parameter is used to cache the distorted borders of image,
              if you don’t like this. Default value is 100.
       distor_sensorw = 320
       distor_sensorh = 240
              Dimensions of camera sensor. Default values are for 1/4p sensor.
              This  parameters  used to have the same k coefficient than article
              

       [ftp]
       host = www
       user = webcam
       pass = xxxxxx
       dir  = public_html/images
       file = webcam.jpeg
       tmp  = uploading.jpeg
       passive = 1
       debug = 0
       auto = 0
       local = 0
       ssh = 0

Motion

Ref: http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome

This is the minimum needed to run motion as a snapshot webcam and nothing else. Everything is pretty straight forward.

    # 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
    
    # 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
    
        # 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 My Cam

    # 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/www/images

        #snapshot_filename %v-%Y%m%d%H%M%S-snapshot
        
        snapshot_filename mycam

        # Make automated snapshot every N seconds (default: 0 = disabled)
         
        snapshot_interval 60
    
    # Define a port number (e.g. 8000) to enable the mini-http server.
    # 0 = disabled.

    webcam_port 0
    
    # Set to 'off' to allow anybody (not just localhost) to view the
    # webcam via the mini-http server (http://hostname:port).
    webcam_localhost on
    
    webcam_quality 50
    webcam_maxrate 8

        # Maximum length in seconds of an mpeg movie
        # When value is exceeded a new mpeg file is created. (Default: 0 = infinite)
        

Also, turn off a couple of settings to do with mpeg movie output. This is to prevent huge mpeg files being created and eventually filling up your partition so that nothing will work, as I discovered one day.

        # Maximum length in seconds of an mpeg movie
        # When value is exceeded a new mpeg file is created. (Default: 0 = infinite)
        
        max_mpeg_time 1

        # Always save images even if there was no motion (default: off)
        
        output_all off

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

If you have multiple cams, you need to use thread files and you need to append this to the above motion.conf settings:

        ##############################################################
        # Thread config files - One for each camera.
        # Except if only one camera - You only need this config file.
        # If you have more than one camera you MUST define one thread
        # config file for each camera in addition to this config file.
        ##############################################################

        # Remember: If you have more than one camera you must have one
        # thread file for each camera. E.g. 2 cameras requires 3 files:
        # This motion.conf file AND thread1.conf and thread2.conf.
        # Only put the options that are unique to each camera in the
        # thread config files. 

        thread /etc/motion/thread1.conf
        thread /etc/motion/thread2.conf
        thread /etc/motion/thread3.conf

Each thread file may look something like this, with each one having a different videodevice and filename.

        # these options override the motion.conf file's options

        videodevice /dev/video0

        snapshot_interval 7

        text_left My Cam 1

        snapshot_filename mycam1
Personal tools
KARA Logo