Code Monkey home page Code Monkey logo

opencv_webcam's Introduction

OpenCV live streaming in Docker

  • Share your laptop webcam on the local network

    • Access your laptop webcam feed and a shared directory inside a Docker container

      • Run the vision application inside the container and display the live camera feed, modify the vision application and see the changes.

Start Here

git clone https://github.com/J0hn-B/opencv_webcam.git && cd opencv_webcam

Share your laptop webcam on local network

To change the default settings, edit the camera camera_feed & local_port variables

If your want to share the camera of a Windows machine and you have Task installed:

Taskfile.yml

task share_camera

else:

pip3 install -r camera_server/requirements.txt

python3 camera_server/camera.py

Starting the server, the IP address and port number will be displayed in the terminal


Access your laptop webcam feed inside a container

! Important: The container uses -v /tmp/.X11-unix:/tmp/.X11-unix to display the camera feed.

For -v /tmp/.X11-unix:/tmp/.X11-unix to work effectively, you should use a Unix-based host such as Linux, WSL or MacOS to run the container.

For Windows, you need to install an X server like VcXsrv

Update the camera_feed IP address in app file with the IP address and port number displayed in the previous step

camera_feed = "" # example: http://192.168.0.10:5000

Continue with:

task run_vision

else:

# Build the image
docker build -t vision:latest vision
# Run the container
docker run -it -e DISPLAY=$DISPLAY -v $(pwd)/vision/app/:/vision -v /tmp/.X11-unix:/tmp/.X11-unix --network="host" vision:latest /bin/bash

Run the vision application

From inside the container:

# root@docker-desktop:/vision#

pip install -r requirements.txt
# root@docker-desktop:/vision#

python main.py

A new window will open displaying the live camera feed

opencv

Stop the app and exit the container

# root@docker-desktop:/vision#

CTRL+C

exit

opencv_webcam's People

Contributors

j0hn-b avatar

Watchers

Kostas Georgiou avatar  avatar

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.