0

I am facing issue while accessing USB camera using beagle-bone black wireless. Firstly the error is "select timeout" exception which was resolved by this post

Now I am facing the black screen in output.

Here is the testing code I am using.

from cv2 import *
# initialize the camera
cam = VideoCapture(0)   # 0 -> index of camera
print "Cam capture"
cam.set(3,320)
cam.set(4,240)
print "Cam set"
s, img = cam.read()
print "Cam read"
if s:    # frame captured without any errors
    namedWindow("cam-test",CV_WINDOW_AUTOSIZE)
    imshow("cam-test",img)
    while True:
        key = waitKey(30)
        if key == ord('q') :
                destroyWindow("cam-test")

I have already check that video0 in /dev directory.

Vijay Panchal
  • 317
  • 3
  • 8

1 Answers1

0

The issue is that you need to call 'cam.read()andimshow()` inside the while loop

What you're doing is that you're reading just the first frame, then showing it, and you whileloop isn't doing anything. When the camera boots, the first frame is just a blank screen , which is what you see.

The code should be more like:

    while True:
        s, img = cam.read()
        imshow("cam-test",img)
        key = waitKey(30)
        if key == ord('q') :
                destroyWindow("cam-test")
Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39