0

I am running windows 7 64 bit (32 bit python) on an hp touchsmart 600. A while ago I uninstalled then reinstalled opencv 2.4.3. In between the uninstalling and reinstalling I uninstalled some programs I thought weren't being used. Now opencv only displays a black screen when before opencv was able to access my webcam correctly.

However, if I use camera 2 (i.e. cam = create_capture(2,...)) opencv is able to use my webcam correctly. Why did camera 0 suddenly stop working? Did it somehow become camera 2 or could I have uninstalled a dependency that opencv needed to access my webcam? Also, using camera 1 and 3 works as well, even though I only have one webcam.

bab
  • 2,119
  • 3
  • 28
  • 49
  • If you have a single camera, simply pass the value -1 (not zero). For the reason why camera 0 stopped working, I can only guess that under Windows there is no guarantee that the first cam is assigned to 0. But I would suggest moving to the newer OpenCV API. In this new version you would use `VideoCapture` instead of `CaptureFromCam`, and now you specify 0 (to act just like -1 in the older API). – mmgp Dec 29 '12 at 00:44
  • could you explain what you mean by the newer opencv api? Isn't opencv 2.4.3 the latest one? – bab Dec 29 '12 at 00:46
  • 3
    OpenCV 2.4.3 is latest release version. Inside it, python bindings has two API, old `cv` and new `cv2`. Check this:http://stackoverflow.com/questions/10417108/what-is-different-between-all-these-opencv-python-interfaces/10425504#10425504 – Abid Rahman K Dec 29 '12 at 02:06

1 Answers1

0

Camera 0 points to your default camera driver, camera 1 to your secondary driver, camera 2 to your tertiary and so on.

Which means that even with a single camera hardware, you can have multiple drivers that can access it.

Let's assume that your primary cam driver (probably provided by HP) was corrupted during the uninstallation. This would mean that when you call camera 0, you're instantiating the HP driver (now corrupted), which is giving you a black screen.

However, since your camera hardware is unaffected and so are your secondary and tertiary camera drivers, when you access camera 1, your secondary camera driver streams the live feed correctly.

In case you do not have a tertiary camera driver, camera 2 will point to the secondary driver. Hence camera 2 will call the driver corresponding to camera 1 if no driver is associated with camera 2

Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39