Repeated _COM error with VidCap in vs17

I have upgraded to v4.12.0 (from v3 after several years break - new machine) and although everything still appears to work ok, I get this exception repeated many times when executing frame capture and/or imshow functions:

Exception thrown at 0x00007FFBD37A7F9A in VidCap.exe: Microsoft C++ exception: _com_error at memory location 0x0000005D01EFE990.
(exact location varies )

Using VS 17.14.11 (latest community edition).

To eliminate any of my errors, I have compiled & run the sample “videocapture_camera.cpp” and I get the same behaviour.

The stack trace gives me this:

[External Code]	

ucrtbase.dll!00007ffbd33fe086() Unknown
d3d11.dll!ThrowFailure(long) Unknown
d3d11.dll!CDevice::CreateTexture2D_Worker(struct D3D11_TEXTURE2D_DESC1 const *,struct D3D11_SUBRESOURCE_DATA const *,enum CreateTex2DFlags,struct ID3D11Texture2D1 * *,struct SD3D11SharedResourceCreationArgs *,struct ID3D11LayeredUseCounted *) Unknown
d3d11.dll!CDevice::CreateTexture2D(struct D3D11_TEXTURE2D_DESC const *,struct D3D11_SUBRESOURCE_DATA const *,struct ID3D11Texture2D * *) Unknown
mfplat.dll!00007ffbcc7a1926() Unknown
mfplat.dll!00007ffbcc7a1b3c() Unknown
mfplat.dll!00007ffbcc770c6a() Unknown
mfplat.dll!00007ffbcc774e5a() Unknown
FrameServerClient.dll!00007ffb7661e911() Unknown
FrameServerClient.dll!00007ffb765f3b08() Unknown
FrameServerClient.dll!00007ffb765ed2bf() Unknown
FrameServerClient.dll!00007ffb765ebf35() Unknown
FrameServerClient.dll!00007ffb765ebba3() Unknown
FrameServerClient.dll!00007ffb765d382b() Unknown
FrameServerClient.dll!00007ffb765d33dc() Unknown
FrameServerClient.dll!00007ffb765f4af5() Unknown
RTWorkQ.dll!00007ffbcc6dda4f() Unknown
RTWorkQ.dll!00007ffbcc6dc8d1() Unknown
ntdll.dll!00007ffbd613b5f0() Unknown
ntdll.dll!00007ffbd61529f1() Unknown
kernel32.dll!00007ffbd5abe8d7() Unknown
ntdll.dll!00007ffbd60fc34c() Unknown

Addendum: OpenCV was installed from “opencv-4.12.0-windows.exe“ which refers to vc16….

Any ideas gratefully received.

that stack trace shows a bunch of interesting names but nothing related to OpenCV.

what is this video device?

the sample source you talk about can be viewed at opencv/samples/cpp/videocapture_camera.cpp at master · opencv/opencv · GitHub

The video device is a simple vga usb webcam.

Other webcams give same result.

puzzling.

got any virus scanner software on your system that is not Windows’ own? these third party scanners like to interfere in normal system operation, such as using a webcam.

I see signs of the “Media Foundation” API being used. you could try modifying the VideoCapture instantiation to use CAP_DSHOW instead (apiPreference argument).

I’m not using a 3rd party virus scanner.

CAP_DSHOW - that has cured the exceptions being thrown:

  • any explanation as to why?
  • interesting that the exceptions weren’t obviously causing a problem, behaviour was as expected, only showed in the debugger.

the code connecting OpenCV to MSMF (media foundation) is not as “trodden” as the DSHOW backend.

please feel free to post your situation as an issue on OpenCV’s github. such issues can only get fixed if they know about it.

Thanks - will look at github.