mars_pi
Posts: 1
Joined: Sat Aug 12, 2017 5:47 pm

The window of video from usb camera is empty: python 3, opencv

Sat Aug 12, 2017 6:11 pm

I tried open window window with video from usb camera from python using this code



import cv2



cap=cv2.VideoCapture(0)

while True:
ret, im = cap.read()
cv2.imshow('1',im)





but the window was empty, I use raspberry pi 3 , camera sven ic-300 ,python3 and opencv 3.3


Why?
Sorry for mistaks.
Attachments
video's_problem (1)_300x188.png
video's_problem (1)_300x188.png (42.69 KiB) Viewed 1122 times

fiaraz
Posts: 1
Joined: Wed Nov 21, 2018 2:30 pm

Re: The window of video from usb camera is empty: python 3, opencv

Wed Nov 21, 2018 2:34 pm

I was looking to adjust my python code as I a using a us camera on an old pc.

This line of code here

cap=cv2.VideoCapture(0)

The 0 in parentheses designates an internal webcam not a usb camera so that's what we need to change. If you want to know what to well I will tell you when I try IT!!

il_diavolo
Posts: 134
Joined: Mon Dec 02, 2013 7:56 pm

Re: The window of video from usb camera is empty: python 3, opencv

Wed Nov 21, 2018 10:21 pm

The 0 in parentheses designates an internal webcam not a usb camera so that's what we need to change. If you want to know what to well I will tell you when I try IT!!
Not necessarily true. On my set up with both the official Pi camera and a USB camera the USB camera is index (0) and the Pi camera is index(1) when the Pi is booted with both cameras plugged in. If only one of the two is plugged in at boot then that will be index(0).

Also see my post viewtopic.php?f=43&t=225539&p=1384459#p1384459

Return to “Beginners”