Skip to content

IOI = Image over internet

gr4viton edited this page Jul 4, 2018 · 9 revisions

= camera image and video sharing over LAN internet

camera

  • Usb webcam
  • Raspberry pi camera module (rpcm)

share via

  • LAN = local only
  • net = world (not done yet - scary)

LAN share options

camera -> file system image -> web

  • periodically write camera image as jpeg file
  • load this jpeg file and reload it in web interface
- writing file over and over will corrupt your sd card in the end
+ semi-simple

camera -> web

  • grab video from camera and directly stream it to web interface
+ not writing to the fs = better fps and sd card life expectancy
+ good for simple streaming
- not interactive

camera -> altering -> web

  • yes :trollface:
  • after grabbing the image you run your computer vision magic on it and than stream it
+ you can do whatever you want with your stream

actual video over LAN implementations

mjpeg-streamer.input_file.so + raspistill

The first solution i found is to use mjpeg_streamer and raspistill.

  • raspistill was periodically saving image to harddrive
  • mjpeg_streamer was loading this file and displaying it on web
+ simple = just run two programs
- not interactive
- writing to fs

usage

  • streamer
sudo mjpg_streamer -i "/usr/local/lib/input_file.so -f /home/pi/stream/ -n out.mjpg" -o "/usr/local/lib/output_http.so -w /usr/local/www -p 8080
  • camera image writer
sudo raspistill --nopreview -w 640 -h 480 -q 75 -o /home/pi/stream/out.mjpg -tl 100 -t 9999999 -th 0:0:0

mjpeg-streamer.input_file.so + opencv magic

just create your program in whatever (python / C) and using opencv (or whatever) write altered image to the disk

  • you can use picamera to load raspicam image to opencv
- still writing to fs
+ computer vision magic
+ possible python

mjpeg_streamer.input_raspicam.so

read the image directly from the raspicamera without writing to the filesystem

+ not writing to the fs = better fps and sd card life expectancy
- cannot alter the stream from raspicam
- cannot use other streams (webcam)

usage

mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so -x 1280 -y 720 -fps 15 -ex night

mjpeg_streamer.input_opencv.so

  • read the image directly from opencv compatible streams (webcam = yes, raspicam = no)
  • possibly do some opencv magic over it (with precreated filter)
  • stream it to web interface
+ not writing to the fs = better fps and sd card life expectancy
- cannot read raspicam
+ can alter the stream from cam
- cannot change the opencv filter on the fly

(not tested) imho you cannot change the opencv filter dynamically cause it is probably loaded when you run the mjpeg-command

flask + opencv + picamera + jpeg file

  • use opencv
  • save it to jpeg file
  • to display it via flask
  • like this guy Ruchir Sharma
    • though he is lying he is not using picamera just opencv stream (not compatible with opencv)
- you really do not want to write the file!

flask + opencv + opencvstream

+ no jpeg file write
+ python
+ opencv
- only opencv streams (no raspicam)

i found in some discussion snippet for loading camera image and using flask for displaying it directly

  • it works with opencv stream encoding it into jpeg
  • then setting the Content type as image/jpeg and it works

it looks alot like the previous solution from Ruchir but without the saving jpeg as file part

I got this functional - the cv2.VideoStream is loading data continuously and flask is displaying them.

Maybe, i will create example out of this - though idk maybe i will have general solution for usbcam / raspicam soon..

Before that - the function webcam flask stream is in this branch

flask + opencv + picamera

now it is getting interesting

+ no jpeg file write
+ python
+ opencv
+ raspicam over picamera