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?
unfortunately no idea, why you can't access your cam, but rebuilding the libs most probably won't help.
also you might want to change to the newer cv2 python api, the old cv one will go away pretty soon.
Thanks for the reply. So I will look at other possible solutions before trying rebuilding the sources. I will see if I can just get a picture taken using the camera in the tablet computer by using the underlying API (eg. VFW, DirectShow seems more work than it should be to just try something out quickly so will do that after VFW). I guess I am puzzled why they get listed in the video source dialog but not created.
Regarding the use from python, yes I know about the new python bindings but the binary ones are only for python2 and we want to use python3 for all projects, hence why I am just doing custom things of my own with ctypes. Also the use of python here is only to quickly try OpenCV to check it does what I want before writing it in a more difficult language.
I have tried using the camera of the tablet directly through VFW from VB.net (http://anoriginalidea.wordpress.com/2010/10/04/capturing-a-still-image-from-a-webcam-in-net/). Again this works on the MacBookPro but not on the tablet. It seems like the video source dialog I have mentioned is part of the VFW driver for the camera as it appears when using VFW directly.
So may be the problem is not in OpenCV. Surely though all the driver interfaces cannot be broken on this tablet, although that is what OpenCV is suggesting.
After a bit more research, it appears the problem comes from the Intel imaging signal processor 2300 which is used in this tablet. While referring to different tablets the cameras and imaging processor is the same http://stackoverflow.com/questions/13885729/x86-windows-8-tablet-running-pro-cant-access-integrated-cameras-with-emgu-openc
I have tried OpenCV 2.1.0 on the Lenovo tablet and this works, OpenCV 2.2.0 does not.
When using OpenCV 2.1.0 it appears only the DirectShow driver works, the VFW driver still does not.
What changed in OpenCV 2.2.0 DirectShow support?