I found the following code (on
import cv cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE) camera_index = 0 capture = cv.CaptureFromCAM(camera_index) def repeat(): global capture #declare as globals since we are assigning to them now global camera_index frame = cv.QueryFrame(capture) cv.ShowImage("w1", frame) c = cv.WaitKey(10) if(c=="n"): #in "n" key is pressed while the popup window is in focus camera_index += 1 #try the next camera index capture = cv.CaptureFromCAM(camera_index) if not capture: #if the next camera index didn't work, reset to 0. camera_index = 0 capture = cv.CaptureFromCAM(camera_index) while True: repeat()
The code compiles great when I ran it via the terminal, but there is no video feed. The camera's red light doesn't turn on (I am using Rasp Pi's camera). I get the following warning:
GLib -GObject-WARNING **: Attempt to add property GtkSettings::gtk-label-select-on-focus after class was initialised.
I did try using the camera via the python terminal -- i.e., using
raspistill -- and the camera works. I followed
Do I need to amend the code below with
Can anyone please help me with this?