Ask Your Question
0

Accessing Beaglebone python opencv usb camera but the display showing black screen

asked 2018-05-08 02:08:59 -0600

vkpanchal gravatar image

updated 2018-05-08 02:13:45 -0600

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-05-08 02:41:27 -0600

berak gravatar image

probably your cam needs a "warmup", and the 1st frame(s) are empty/black. you should reorder your statements, to read continuously from the webcam:

namedWindow("cam-test",CV_WINDOW_AUTOSIZE)
while True:
    s, img = cam.read()
    print "Cam read"
    if s:    # frame captured without any errors
        imshow("cam-test",img)
        # ... process img
    key = waitKey(30)
    if key == ord('q') :
        break
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-05-08 02:08:59 -0600

Seen: 773 times

Last updated: May 08 '18