Giter VIP home page Giter VIP logo

webcam2rgb's Introduction

webcam2rgb

Turning your webcam into a simple RGB light sensor sampling at the framerate.

Installation

Install it in your local package repository with --user otherwise become admin and omit it:

setup.py install --user

Prerequisites for development

pip3 install opencv-contrib-python
pip3 install opencv-python

How to use

Import it

import webcam2rgb

Get an instance

camera = webcam2rgb.Webcam2rgb()

Set up a callback function

def hasData(retval, data):

where data is an BGR tupel and retval contains any error from openCV

Start continous acquisition

camera.start(callback = hasData)

the callback is then called at the framerate of the camera

This method has the following optional arguments:

  • cameraNumber=0 starts acquisition from camera number cameraNumber
  • width = None tries to set the width of the camera acquisition
  • height = None tries to set the height of the camera acquisition
  • fps = None tries to set the framerate
  • directShow = False switches on Direct Show under Windows

Stop the acquisition

camera.stop()

Getting the sampling rate

fs = camera.cameraFs()

Demo

Just run demo.py. It plots the R,G,B channels in three plot windows.

Troubleshooting

Spyder

Start your program from the (Anaconda-) console / terminal and never within Spyder. Here is an example for Windows

    (base) D:\>
    (base) D:\>cd webcam2rgb
    (base) D:\webcam2rgb>python demo.py

The problem with Spyder is that it won't let your Python program terminate properly which leaves the video camera in an undefined state. If you then re-run your program it won't be able to talk to your camera. In the worst case you need to reboot your computer. Bottomline: use Spyder for editing, run the program from the console / terminal.

Windows

Under Windows, sometimes the camera initilisation does not open the camera correctly - shown by a 0Hz readout from camera.cameraFs(). If this happens the camera needs to be reopened manually. Try using the directShow = True parameter to use the Direct Show backend.

webcam2rgb's People

Contributors

berndporr avatar jamielee183 avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar Elliott Lawrence 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.