# Problems with VideoCapture on Windows

**URL:** <https://forum.opencv.org/t/problems-with-videocapture-on-windows/9754>\
**Category:** Python\
**Tags:** qt, videoio\
**Created:** [August 7, 2022, 3:48pm UTC](https://forum.opencv.org/t/problems-with-videocapture-on-windows/9754 "2022-08-07T15:48:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![someoneetc](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@someoneetc](https://forum.opencv.org/u/someoneetc)\
**Post date:** [August 7, 2022, 3:48pm UTC](https://forum.opencv.org/t/problems-with-videocapture-on-windows/9754/1 "2022-08-07T15:48:53Z")

</div>

Hello,

I’m trying to port on Windows an application I wrote on Linux using Python(Qt5 and OpenCV).

The problem is that, when I try to open a webcam using cv2.VideoCapture(camera) where camera is obtained as follows:

```auto
self.available_cameras = QCameraInfo.availableCameras()
#The user select the camera from a QComboBox(shouldn't be important)
camera = self.available_cameras[combo_box_index].deviceName()

```

I get the following error:

```auto
[ERROR:0@14.725] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap.cpp (166) cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): @device:pnp:\\?\usb#vid_045e&pid_076d&mi_00#7&315bdc05&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global in function 'cv::icvExtractPattern'

```

Anybody knows why?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [August 7, 2022, 3:56pm UTC](https://forum.opencv.org/t/problems-with-videocapture-on-windows/9754/2 "2022-08-07T15:56:38Z")

</div>

`cv::VideoCapture`, for video devices, is supposed to get an index, not a “name”. if a “name” ever worked, some system-specific backend felt responsible and accepted that.

You can use Qt to read from your camera. you should. and if you need some sensible way to choose a camera, you _must_.

---

<div class="post-metadata">

**Author:** ![someoneetc](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@someoneetc](https://forum.opencv.org/u/someoneetc)\
**Post date:** [August 7, 2022, 4:12pm UTC](https://forum.opencv.org/t/problems-with-videocapture-on-windows/9754/3 "2022-08-07T16:12:43Z")

</div>

Yes, actually, on Linux, it worked. I was not aware of this issue. I’ll try to do as you suggested. Thanks for your help

---

<div class="post-metadata">

**Author:** ![matti.vuori](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@matti.vuori](https://forum.opencv.org/u/matti.vuori)\
**Post date:** [August 7, 2022, 7:20pm UTC](https://forum.opencv.org/t/problems-with-videocapture-on-windows/9754/4 "2022-08-07T19:20:09Z")

</div>

CameraInfo::availableCameras() returns a list of available cameras and that list obviously has indices starting from zero, so a name is not a necessary representation. Of course that doesn’t mean those ids could be passed to VideoCapture…

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [August 7, 2022, 10:31pm UTC](https://forum.opencv.org/t/problems-with-videocapture-on-windows/9754/5 "2022-08-07T22:31:33Z")

</div>

> [@matti.vuori](#):
>
> that doesn’t mean those ids could be passed to VideoCapture

or that OpenCV would assign indices the same way Qt did, or that OpenCV would see the same cameras that Qt does (various APIs)

---

<div class="post-metadata">

**Author:** ![someoneetc](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@someoneetc](https://forum.opencv.org/u/someoneetc)\
**Post date:** [August 10, 2022, 6:22pm UTC](https://forum.opencv.org/t/problems-with-videocapture-on-windows/9754/6 "2022-08-10T18:22:32Z")

</div>

Hello, I’m still struggling a bit with this problem(I have a related thread on the Qt forum too). The problem is that, it looks like that video capture with Qt is not supported on Windows. The question then is: is there any way to obtain a complete list of available devices(the device’s numbers, in particular) using OpenCV?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [August 10, 2022, 10:11pm UTC](https://forum.opencv.org/t/problems-with-videocapture-on-windows/9754/7 "2022-08-10T22:11:11Z")

</div>

Qt may lack MSMF support but it can do directshow.

“viewfinder” is what you want.

[https://doc.qt.io/qt-5/qtmultimedia-windows.html](https://doc.qt.io/qt-5/qtmultimedia-windows.html)

if that really doesn’t suit you, I’m sure there are recipes for accessing MSMF/DShow directly.

you _can’t_ use OpenCV for the level of flexibility that you require. OpenCV does _not_ have a list of video devices.
