2

I'm currently writing an real time application using OpenCV and in the following case: I'm trying to capture an image from a HDV camera plugged in firewire 800. I have tried to loop on index used on cvCaptureFromCam, but no camera can't be found (except the webcam).

there is my code sample, it loop on index (escaping 0 cause it's the webcam's index) :

CvCapture* camera;
int index;
for (index = 1; index < 100; ++index) {
    camera = cvCaptureFromCAM(index);
    if (camera)
        break;
}    
if (!camera)
    abort();

On any time it stops on the abort.

I'm compiling on OSX 10.7 and I have tested :

  • OpenCV 1.2 private framework
  • OpenCV 2.0 private framework (found here : OpenCV2.0.dmg)
  • OpenCV compiled by myself (ver. 2)

I know that the problem is knowned and there is a lot of discussion about this, but I'm not able ti find any solution.

Does anyone have been in the same case ?

Regards.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
T3e
  • 539
  • 1
  • 6
  • 17
  • I have posted some code in edit. For information my camera is a Sony HDV-HC1E. It use an i-link out and I've tried HD, DV, and different resolutions for output video. – T3e Apr 20 '12 at 14:58
  • try this code it might help: http://pastebin.com/i0Kb2xNv this is from @juanchopanza it was for a webcam though, I hope it helps – user1347945 Apr 23 '12 at 19:40

2 Answers2

6

To explicitly select firewire, perhaps you can try to add 300 to your index? At least in OpenCV 2.4, each type of camera is given a specific domain. For example, Video4Linux are given domain 200, so 200 is the first V4L camera, 201 is the second, etc. For Firewire, the domain is 300. If you specify an index less than 100, OpenCV just iterates through each of its domains in order, which may not be the order you expect. For example, it might find your webcam first, and never find the firewire camera. If this is not the issue, please accept my appologies.

Sam
  • 61
  • 1
  • 2
2

index should start at 0 instead of 1.

If that doesn't work, maybe your camera is not supported by OpenCV. I suggest you check if it is in the compatibility list.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • Thanks for helping, As I know the index starts at 0, but this is the index of my webcam, and I want to skip it and get my firewire camera. I've also tried index -1 (for any camera) but the effect is the same : the webcam is found and not my firewire camera. – T3e Apr 20 '12 at 16:39
  • Updated answer (refresh the page). – karlphillip Apr 20 '12 at 16:40
  • Sorry to hear about that. Consider accepting my answer by clicking in the checkbox near it so others can benefit from your question in the future. – karlphillip Apr 20 '12 at 16:45
  • What camera uses people doing real-time ? – T3e Apr 20 '12 at 16:49
  • What defines real-time capture? If it's the ability to provide more than 25 or even 30 frames per second than most cameras supported by OpenCV can do real-time. – karlphillip Apr 20 '12 at 16:55