[libdc] Trouble connecting 3 firewire (point grey) cameras (Cocoa, OSX 10.6)
Capture and control API for IIDC compliant cameras
Brought to you by:
ddouxchamps,
gordp
From: Jabeer A. <jab...@gm...> - 2011-08-17 02:20:00
|
Hi, I am a beginner and this my first attempt at trying to program a device. I cannot thank David and the team of libdc1394 enough for this library. It makes life in the non-pc scientific world survivable. I am working on a computer vision project and would like to connect 3 BW FW cameras for a detailed viewpoint. I have managed to get 2 cameras connected working so far. They are both point grey FW cameras but different models. I am trying to add a 3rd camera to the set, which is also another different model but very similar to cam 2. Each camera exists as an object and only the "camNum" distinguishes them. I try to programmatically assign ISO channels to each camera (ch 0, 1 & 2 respectively) based on the "camNum". If I do not, camera 3 always gets assigned channel 0 along with camera 1. Then I configure each camera differently based on their respective camNum. Then I issue the command "err=dc1394_capture_setup(camera,4, DC1394_CAPTURE_FLAGS_DEFAULT)". The 3rd camera set up fails here. I use an example error message but the entire thing says "*libdc1394 warning: Forcefully killing servicing task...* *libdc1394 error: Not enough iso bandwidth or channels are available to begin capture* *libdc1394 error: Generic failure: in -[IEEEcams setCamera:] (/Commons/Jabeer/3Dscanning/IEEE_stereo copy 2/IEEEcams.m, line 177): Could not setup camera-**make sure that the video mode and framerate are **supported by your camera"* The ERROR MESSAGE ZONE is highlighted below in the source code. I have tried all combinations of 2 camera set up and it works with the code provided below. Prior to setCamera function i initialize with "dc1394_new()" and also get camera list by "dc1394_camera_enumerate (d, &list)", which i do not release or free. I cannot seem to come up with any solution. I tried all the different framerate and videomode settings and I know that as a pair any 2 camera works fine. Any help anybody. The entire project is stuck still on this problem. Thanks Jabeer Ahmed - (int) setCamera:(int) camNum { if (err == DC1394_SUCCESS) { if(camNum<list->num) { camera = dc1394_camera_new(d,list->ids[camNum].guid); if (!camera) { dc1394_log_error("Failed to initialize camera\n"); return 1; } }else return 1; /* Print camera information */ printf("\n\ncam%d\n",camNum+1); printf("model: %s\n",camera->model); /* Get Framerate infomation */ dc1394framerates_t frate; dc1394_video_get_supported_framerates(camera, DC1394_VIDEO_MODE_640x480_MONO8, &frate); printf("frame rates = %u\n",frate.num); for(int i = 0;i<frate.num;i++) { printf("frame Rate = %u\n",frate.framerates[i]); } /* Assign ISO channel */ unsigned int channel; dc1394_video_get_iso_channel(camera, &channel); printf("iso channel = %u\n",channel); dc1394_video_set_iso_channel(camera, camNum); if(camNum == 0) { /* Set Operation mode and framerate*/ dc1394_video_set_operation_mode(camera,DC1394_OPERATION_MODE_1394B); dc1394_video_set_framerate(camera,38); /* Set ISO speed Information*/ dc1394speed_t speeds; err = dc1394_video_get_iso_speed(camera, &speeds); printf("supported iso speed = %u\n",speeds); err=dc1394_video_set_iso_speed(camera, DC1394_ISO_SPEED_800); DC1394_ERR_CLN_RTN(err,cleanup_and_exit(camera),"Could not set iso speed"); /*Set Features Shutter & Exposure */ err=dc1394_feature_set_value(camera, DC1394_FEATURE_SHUTTER, 500); err=dc1394_feature_set_value(camera, DC1394_FEATURE_EXPOSURE, 30); } if(camNum == 1) { /* Set Operation mode and framerate*/ dc1394_video_set_operation_mode(camera,DC1394_OPERATION_MODE_1394B); dc1394_video_set_framerate(camera,36); /* Set ISO speed Information*/ dc1394speed_t speeds; err = dc1394_video_get_iso_speed(camera, &speeds); printf("supported iso speed = %u\n",speeds); err=dc1394_video_set_iso_speed(camera, DC1394_ISO_SPEED_400); DC1394_ERR_CLN_RTN(err,cleanup_and_exit(camera),"Could not set iso speed"); } if(camNum == 2) { /* Set Operation mode and framerate*/ dc1394_video_set_operation_mode(camera,DC1394_OPERATION_MODE_1394B); dc1394_video_set_framerate(camera,36); /* Set ISO speed Information*/ dc1394speed_t speeds; err = dc1394_video_get_iso_speed(camera, &speeds); printf("supported iso speed = %u\n",speeds); err=dc1394_video_set_iso_speed(camera, DC1394_ISO_SPEED_400); DC1394_ERR_CLN_RTN(err,cleanup_and_exit(camera),"Could not set iso speed"); } /* ***** ERROR MESSAGE ZONE ***** */ err=dc1394_capture_setup(camera,4, DC1394_CAPTURE_FLAGS_DEFAULT); DC1394_ERR_CLN_RTN(err,cleanup_and_exit(camera),"Could not setup camera-\nmake sure that the video mode and framerate are\nsupported by your camera\n"); /* ***** End of ERROR MESSAGE ZONE ***** */ /* Get Frame Information */ err=dc1394_video_set_transmission(camera, DC1394_ON); err=dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame);/* Capture */ imgSize.width = frame->size[0]; imgSize.height= frame->size[1]; imgBitDepth = frame->data_depth; imgLength = frame->image_bytes; err=dc1394_capture_enqueue(camera, frame); /* Release the buffer */ err=dc1394_video_set_transmission(camera, DC1394_OFF); /* Stop transmission */ /* Finish initialization */ setupOK = YES; dc1394_camera_free_list (list); frame = NULL; return err; }else return 1; } |