Gary Sieling

Stream Video from AWS DeepLens to OpenCV

While the AWS DeepLens camera is designed to work with AWS, it’s just a normal linux camera and you can open video streams from OpenCV.

The camera comes with a firewall (UFW) pre-installed, so you need to disable a port for video:

sudo ufw allow 8090

Then edit the ffserver configuration file to expose the streams from the camera:

sudo vi /etc/ffserver.conf

Add the following:


  File "/opt/awscam/out/ch2_out.mjpeg"
  NoAudio



  File "/opt/awscam/out/ch1_out.h264"
  NoAudio

Then run ffserver.

Now you can access this remotely with Python:

import cv2
import datetime

camera = cv2.VideoCapture('http://192.168.1.187:8090/feed.h264')
while True:
  (grabbed, frame) = camera.read()

  if not grabbed:
    break
 
  frame = cv2.resize(frame, (int(1920/4), int(1080/4)), cv2.INTER_AREA)

  cv2.putText(frame, datetime.datetime.now().strftime("%A %d %B %Y %I:%M:%S%p"),
    (10, frame.shape[0] - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.35, (0, 0, 255), 1)

  cv2.imshow("Feed", frame)

  key = cv2.waitKey(1) & 0xFF

  if key == ord("q"):
    break

camera.release()
cv2.destroyAllWindows()
Exit mobile version