Happy Farming . com

How to Grow Your Own Food

  • Oct 21 2010

    The pictures are coming in from my webcam now and I’m using a program called motion. It’s capable of storing pictures when a movement is detected in front of the webcam, but I have disabled this feature and configured it to take a picture every 60 seconds instead. motion has a small internal web server that can be accessed from the local intranet or from Internet. I’m planning on letting the NSLU2 upload the pictures to happyfarming.com instead, but the local web server is a cool way to test if the camera is running. Here’s a print of my configuration file for motion:

    $ cat motion.conf
    
    # The program is run with motion motion.conf &
    daemon off
    
    # No debug messages
    quiet on
    
    # Path to webcam
    videodevice /dev/video0
    
    # Disable motion detection
    output_all on
    
    # Seconds between saving a picture
    minimum_frame_time 60
    
    # Picture details
    width 640
    height 480
    quality 100
    
    # Picture filename
    jpeg_filename webcam
    
    # The pictures are stored here
    target_dir /home/thomas/motion/snapshots
    
    # Local web server settings. Replace XXXX with desired port number.
    webcam_port XXXX
    webcam_localhost off
    webcam_quality 50

    This is the command I use for running motion:

    $ motion motion.conf &
    [1] 2147
    [0] Processing thread 0 - config file motion.conf
    [0] Motion 3.2.9 Started
    [0] ffmpeg LIBAVCODEC_BUILD 3355136 LIBAVFORMAT_BUILD 3409664
    [0] Thread 1 is from motion.conf
    [1] Thread 1 started
    [1] Not a V4L2 device?
    [1] Using VIDEO_PALETTE_YUV420P palette
    [1] Using V4L1
    [1] Started stream webcam server in port XXXX
    [1] File of type 1 saved to: /home/thomas/motion/snapshots/webcam.jpg

    The picture is stored on the USB flash disk connected to the NSLU2.

    The previous snapshot is overwritten when this particular configuration file is used, but it’s possible to add a time and date stamp to the filename and make a time lapse series of growing plants. I think it’s even possible for motion to collect the snapshot into a movie file. What a cool program :-D

    Now I just need a way to get the picture uploaded to happyfarming.com so you’ll be able to watch me goof around in my garden and throw leeks at the camera ;-)

  • Oct 20 2010

    I had to shorten the USB cable to make my webcam work properly or I would get lots of errors when I tried to grab images. With a shorter cable I had to move the webcam closer to the window and place it on the roof instead:

    Here’s the webcam looking down on the garden. The USB cable is going in through the window but it’s still possible to close the window locking the cable into position:

    If you look closely you can find the camera on top of the small roof to the left of the house:

    There’s not many vegetables left in my garden at this moment although the following plants are still going strong despite the decreasing temperature: Green manure, leeks, parsnips, strawberries and sunflowers.

    I tried to get the first picture from the webcam with my NSLU2 computer and installed a recorder program called streamer:

    apt-get install streamer

    This is the command I used:

    $ streamer -c /dev/video0 -b 16 -o webcamfile.jpg

    and got this picture:

    I have to go work on the brightness setting ;-) On my laptop there’s a calibration going on automatically but I guess I have to adjust the settings manually on my NSLU2.

Shops / Blog Sponsors


Amazon Products