element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi IoT
  • Challenges & Projects
  • Design Challenges
  • Pi IoT
  • More
  • Cancel
Pi IoT
Blog [Pi IoT] Alarm Clock #10: Camera Feeds
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fvan
  • Date Created: 27 Jul 2016 7:39 PM Date Created
  • Views 2589 views
  • Likes 5 likes
  • Comments 15 comments
  • fvan_piiot
  • pi camera v2
  • piiot
  • feature_tutorial
Related
Recommended

[Pi IoT] Alarm Clock #10: Camera Feeds

fvan
fvan
27 Jul 2016

  • Hardware
  • Software
    • Enable
    • Stream
    • Embed

 

With the limited time that remains, things need to get kicked in higher gear. For this post, I worked on creating camera feeds using the camera module that was provided in the kit, in combination with the low cost Pi Zero. I built two of these, one for my shed, and another one for my lab.

 

Here's how I did it.

 

Hardware

 

Nothing super exciting on the hardware side of things, as it's merely a Pi Zero with wifi dongle and camera module, but I can perhaps share two interesting gadgets I've used image

 

The first one is the ZeroView, which I already mentioned in my [Pi IoT] Alarm Clock #02: Unboxing The Kit. Useful to stick a Pi Zero and camera on any window in a very compact format. Even if you don't attach it onto a window, the spacers can be used to attach a string or similar to attach it somewhere else while keeping everything as one unit.

 

imageimage

 

The second one, is this micro USB converter shim. Helps keep things compact as well!

 

imageimage

 

Moving on to the software side of things ...

 

Software

 

Enable

 

The first thing to do is to enable camera support using the "raspi-config" command. It doesn't matter which type or version of the Pi camera is used.

 

pi@zeroview:~ $ sudo raspi-config

 

Select the "Enable camera" menu, and when prompted, select the option to enable it.

imageimage

 

Don't forget to reboot the Pi before trying to use the camera!

 

Stream

 

There are different options available to stream from the Pi camera. I've used "motion" before in the Pi NoIR and Catch Santa Challenge, but have come across interesting solutions by Calin Crisan while searching for a more up-to-date alternative.

 

On Calin's GitHub page, a bunch of different projects are available, even a prebuilt image with all tools included called MotionEyeOS (currently featured on element14's homepage as well: Raspberry Pi Smart Surveillance Monitoring System), because I'm integrating everything into a single interface though, I've opted for the lightweight StreamEye program, which creates an easily embeddable MJPEG stream.

 

I followed the instructions described on the GitHub page:

 

pi@zeroview:~ $ git clone https://github.com/ccrisan/streameye.git
Cloning into 'streameye'...
remote: Counting objects: 133, done.
remote: Total 133 (delta 0), reused 0 (delta 0), pack-reused 133
Receiving objects: 100% (133/133), 52.15 KiB | 0 bytes/s, done.
Resolving deltas: 100% (75/75), done.
Checking connectivity... done.

 

pi@zeroview:~ $ cd streameye

 

pi@zeroview:~/streameye $ make
cc -Wall -pthread -O2 -D_GNU_SOURCE -c -o streameye.o streameye.c
cc -Wall -pthread -O2 -D_GNU_SOURCE -c -o client.o client.c
cc -Wall -pthread -O2 -D_GNU_SOURCE -c -o auth.o auth.c
cc -Wall -pthread -O2 -D_GNU_SOURCE -o streameye streameye.o client.o auth.o

 

pi@zeroview:~/streameye $ sudo make install
cp streameye /usr/local/bin

 

In the "extras" folder is a script for the Raspberry Pi, allowing the capture of a continuous stream of JPEG images. Launching the command with the "--help" options, gives a list of all other options available.

 

pi@zeroview:~/streameye $ cd extras/

 

pi@zeroview:~/streameye/extras $ ./raspimjpeg.py  --help
usage: raspimjpeg.py -w WIDTH -h HEIGHT -r FRAMERATE [options]

This program continuously captures JPEGs from the CSI camera and writes them
to standard output.

Available options:
  -w WIDTH, --width WIDTH
                        capture width, in pixels (64 to 1920, required)
  -h HEIGHT, --height HEIGHT
                        capture height, in pixels (64 to 1080, required)
  -r FRAMERATE, --framerate FRAMERATE
                        number of frames per second (1 to 30, required)
  -q QUALITY, --quality QUALITY
                        jpeg quality factor (1 to 100, defaults to 50)
  --vflip               flip image vertically
  --hflip               flip image horizontally
  --rotation {0,90,180,270}
                        rotate image
  --brightness BRIGHTNESS
                        image brightness (0 to 100, defaults to 50)
  --contrast CONTRAST   image contrast (-100 to 100, defaults to 0)
  --saturation SATURATION
                        image saturation (-100 to 100, defaults to 0)
  --sharpness SHARPNESS
                        image sharpness (-100 to 100, defaults to 0)
  --iso ISO             capture ISO (100 to 800)
  --ev EV               EV compensation (-25 to 25)
  --shutter SHUTTER     shutter speed, in microseconds (0 to 6000000)
  --exposure {off,auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks}
                        exposure mode
  --awb {off,auto,sunlight,cloudy,shade,tungsten,fluorescent,incandescent,flash,horizon}
                        set automatic white balance
  --metering {average,spot,backlit,matrix}
                        metering mode
  --drc {off,low,medium,high}
                        dynamic range compression
  --vstab               turn on video stabilization
  --imxfx {none,negative,solarize,sketch,denoise,emboss,oilpaint,hatch,gpen,pastel,watercolor,film,blur,saturation,colorswap,washedout,posterise,colorpoint,colorbalance,cartoon,deinterlace1,deinterlace2}
                        image effect
  --colfx COLFX         color effect (U:V format, 0 to 255, e.g. 128:128)
  -s, --stills          use stills mode instead of video mode (considerably
                        slower)
  -d, --debug           debug mode, increase verbosity
  --help                show this help message and exit
  -v, --version         show program's version number and exit

 

Finally, to begin streaming, launch the "raspimjpeg" script and pipe ("|") it to "streameye". This starts a webserver, streaming the images.

 

pi@zeroview:~/streameye/extras $ ./raspimjpeg.py -w 640 -h 480 -r 15 | streameye
2016-07-25 18:45:44: INFO : streamEye 0.7
2016-07-25 18:45:44: INFO : hello!
2016-07-25 18:45:44: INFO : listening on 0.0.0.0:8080
2016-07-25 18:45:45:  INFO: raspimjpeg.py 0.5
2016-07-25 18:45:45:  INFO: hello!
2016-07-25 18:46:04: INFO : new client connection from 192.168.0.116:50075
2016-07-25 18:46:04: INFO : new client connection from 192.168.0.116:50076

 

Depending on the selected resolution and frame rate, the result should look a little like this:

image

I was very impressed by the latency, as it is very low (less than a second) compared to what I've used in the past.

 

Embed

 

For the final part of this post, I embedded the two image streams in my OpenHAB installation. It only requires a modification in the sitemap, no items need to be defined:

 

        Frame label="Video" {
                Image url="http://192.168.0.125:8080/"
                Image url="http://192.168.0.166:8080/"
        }

 

Refresh the OpenHAB interface, et voila, both streams are embedded:

 

image

 

I moved one camera to the shed, and one to my lab. Yep, that's me writing this very blog post in the lower image image (And yes, I still have a lot of cleaning up to do!)

 


image

 


Navigate to the next or previous post using the arrows.

image
  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 9 years ago +2
    You have a Weber barbecue
  • mcb1
    mcb1 over 9 years ago +2
    Nice. I used UV4L for streaming video. It had quite low delay as well. Features – Projects I do like the larger empty spaces at the new place. Cheers Mark
  • mcb1
    mcb1 over 9 years ago in reply to mcb1 +2
    PS ... I'm deciding that following your posts is dangerous to my online retail experience ... I brought more stuff.
  • mcb1
    mcb1 over 9 years ago in reply to clem57

    Does a buck to buck down converter work?

    Quite likely.

    I just purchased a couple of cheap 12v to USB charger/adapters for $2 or so.

    They have a LED, resistor, inductor and a chip inside and that's about it.

     

    Funnily it came with dual outlets (with pin 2 and 3 joined) and were marked as 1.0A and 2.1A, yet it was the same piece of wire .....image

     

    Once you remove the cover and the bits to connect with the cigarette lighter outlet, you have a fairly compact board to use.

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • clem57
    clem57 over 9 years ago in reply to mcb1

    I like to avoid a run for power and try to take a 12 volt to 5 volt converter approach. Does a buck to buck down converter work?

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 9 years ago in reply to clem57

    Don't panic not all cars have a rear 12v outlet.

    You can buy long USB leads quite cheap and simply run it under the carpet thru to the rear.

     

    It's also likely that you could add the internals of a cheap 12v to USB inside the light area to gain what you need.

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • clem57
    clem57 over 9 years ago in reply to fvan

    I have a Kia Forte and have not looked. Where is yours?

    Clem

    PS. Just went and check, opened where spare should be and no plug. I do have a light that is on when the trunk opens. I will need to wait till daylight to see more.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fvan
    fvan over 9 years ago in reply to clem57

    I have such a plug in the booth/trunk of the car. I think most have ?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube