Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV camera just showing black output

I am following these tutorials http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html#display-video Although the code functions properly, but it doesn't show anything except black screen on the frame window. I don't know why is this happening.

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    ret, frame = cap.read()
    if cap.isOpened() == 0:
        cap.open(0)

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break


cap.release()
cv2.destroyAllWindows()

I have read in some posts that OpenCV might not be supporting my camera. So i don't know what is happening exactly?

click to hide/show revision 2
retagged

updated 2014-03-27 13:00:29 -0600

berak gravatar image

OpenCV camera just showing black output

I am following these tutorials http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html#display-video Although the code functions properly, but it doesn't show anything except black screen on the frame window. I don't know why is this happening.

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    ret, frame = cap.read()
    if cap.isOpened() == 0:
        cap.open(0)

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break


cap.release()
cv2.destroyAllWindows()

I have read in some posts that OpenCV might not be supporting my camera. So i don't know what is happening exactly?