Giter VIP home page Giter VIP logo

raspberrypi3-opencv-docker's Introduction

Docker Stars Docker Pulls

About

The Git repo of an OpenCV Docker image , for Raspberry Pi 3 with Raspbian OS (Debian). The modules from OpenCV contrib are included as well. It is based on the resin.io python image.

Usage

See the image Docker Hub page for information on how to use the image.

Build

If you prefer to build the image yourself (takes around 2 hours), you can do it as follows:

  • Make sure docker is installed in your Raspberry Pi. See here for instructions.
  • Clone this repository into your Raspberry Pi.
git clone [email protected]:mohaseeb/raspberrypi3-opencv-docker.git
  • Build the image as follows (assumes you want to build the image for OpenvCV 4.1.0):
cd raspberrypi3-opencv-docker/opencv_4/4.1.0/
docker build -t my_pi_opencv_img .
  • And run it
docker run -it --rm \
       --name my_opencv_app_run \
       my_pi_opencv_img \
       python -c "import cv2; print(cv2.__version__)"

Example

This demonstrates how you can capture video using your Raspberry Pi camera.

  • Save the video capturing script to a file named save_video.py in your Raspberry Pi.
# based on https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html#saving-a-video
import cv2

cap = cv2.VideoCapture(0)

# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('/videos/output.avi', fourcc, 20.0, (640, 480))
n_frames = 200
while n_frames > 0:
    ret, frame = cap.read()
    if ret == True:
        # write the flipped frame
        out.write(frame)
        n_frames -= 1
    else:
        break
    print('frames to capture: {}'.format(n_frames))

# Release everything when done
cap.release()
out.release()
  • Execute the script as follows (assumes the camera appears as /dev/vidoe0 on the Raspberry Pi)
# run this from the same directory as your save_video.py script
docker run -it --rm \
    -v `pwd`/save_video.py:/save_video.py \
    -v `pwd`:/videos \
    --device /dev/video0 \
    my_pi_opencv_img \
    python /save_video.py
  • The captured video will be written to file named output.avi in the same directory from which the command was executed.

References

OpenCV
Blog post on installing OpenCV 3 on Raspberry Pi
Blog post on installing OpenCV 4 on Raspberry Pi

Licence

MIT

raspberrypi3-opencv-docker's People

Contributors

mohaseeb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

raspberrypi3-opencv-docker's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.