Ask Your Question

Revision history [back]

OpenCV 2.4.5 not giving CvCapture for camera on win8 although camera shown in video source dialog

I am trying to access the camera on a 32-bit Windows 8 tablet (A Lenovo Thinkpad Tablet 2) using OpenCV 2.4.5 but a call to cvCreateCameraCapture returns a null pointer even when OpenCV gives me a video source dialog and I choose the camera from the list presented.

I am using the C API from Python3 with ctypes (the existing OpenCV python bindings are not listed as working with python3, hence why I am doing this with ctypes). Here is my code:

import ctypes cv = ctypes.cdll.opencv_highgui245 cam = cv.cvCreateCameraCapture(-1)

I use -1 as the index to get the video source dialog (which does show two devices) and after running that code cam = 0 (IE. null pointer).

I have tried the above code with other values for the index (eg. 0 for the first camera, 200 which is listed in the header file for VFW, 700 which is listed for DirectShow, 1400 which is listed for Media Foundation), but all attempts give a null pointer.

I have tried the above code on 32-bit windows7 on a 2010 MacBookPro and I do get a pointer to a CvCapture which I can then go on to use for taking a picture with the camera, so I believe the python code is correct.

So this indicates may be something specific to the tablet hardware or Windows8. I have tried using VFW from python to access the camera on the tablet and this does show a driver although I haven't actually tried using it to take a picture with the camera (yet).

DirectShow looks more complicated than I really want to get, hence why I have looked at these other options and not tried DirectShow directly from my code.

When searching the internet I did find some comments about OpenCV builds from the OpenCV website not containing VideoInput and so not supporting so many cameras, but these comments related to older versions such as OpenCV 2.2. I will admit I do not know whether the windows build of OpenCV 2.4.5 from the downloads section is built with this support. Might I need to rebuild OpenCV 2.4.5 with VideoInput support?

So why might the video source dialog of OpenCV show two devices but return null pointers when selecting one rather than the CvCapture object?