i'm trying to take a video with webcam using opencv and python with a simple code
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
print('cap.isOpened')
if cap.isOpened():
print ('cap is opened')
while(True):
re,img=cap.read()
cv2.imshow("video output", img)
k = cv2.waitKey(10)&0xFF
if k==27:
break
cap.release()
cv2.destroyAllWindows()
it's working fine if i try to play an existing video such as .mp4 file. but when i try using a webcam i got an error
GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed cap.isOpened
for more information i'm using odroid xu4 with ubuntu 16.04, webcam i use logitech c170 ( it work properly in webcamtest and using guvcview) thought it doesn't workon cheese and camorama.
need help about this please..
python -c "import cv2; print(cv2.getBuildInformation())" | grep -iP "(v4l|ffmpeg)"
. What is the output? – ScopophiliaException ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'> BrokenPipeError: [Errno 32] Broken pipe
– Willmangst-libav
solve this? See this OpenCV Q&A post. Also, what's the OpenCV version? – Boundless