4

I want to make a program in Python that can take video input from a webcam and display it. And I also want the program to be able to identify colors. So the program can identify where all the reds are. Is this possible to be made in Python?

What library or libraries could I use for this? If it is not possible, is there a better language to use for this?

I'm making this program for Linux.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
enrique2334
  • 1,021
  • 3
  • 17
  • 32

2 Answers2

4

Then OpenCV is the way to go, http://opencv.willowgarage.com/wiki/InstallGuide , this might also help you Displaying a webcam feed using OpenCV and Python

And I also want the program to be able to identify colors. I wouldn't recommend doing image processing natively in python, since it can be quite intensive, theres numpy which is really great for general numeric operations or PIL which focuses on images.

In most cases screenshots will be taken as 3d matrices image[xloc][yloc][rgbcolor] depending on the format that opencv returns. If you want to check for red then simply check image[xloc][yloc][red] is 255 or a value near that to see what kind of intensity you are looking for and the other two colors are zero or low, ie the color red, but try doing this using matrix operators in numpy a standard for loop in python will take considerably longer.

Community
  • 1
  • 1
Samy Vilar
  • 10,800
  • 2
  • 39
  • 34
1

OpenCV has a Python interface.

See Stack Overflow question Displaying a webcam feed using OpenCV and Python for a starter program that captures webcam data and displays it in a window.

Community
  • 1
  • 1
lnmx
  • 10,846
  • 3
  • 40
  • 36