96 if (mode >= DC1394_VIDEO_MODE_MIN
97 && mode <= DC1394_VIDEO_MODE_MAX)
98 return video_mode_names_[mode - DC1394_VIDEO_MODE_MIN];
126 if (mode >= DC1394_COLOR_CODING_MIN
127 && mode <= DC1394_COLOR_CODING_MAX)
128 return color_coding_names_[mode - DC1394_COLOR_CODING_MIN];
149 dc1394video_mode_t video_mode,
150 std::string &color_coding)
152 for (
int ccode = DC1394_COLOR_CODING_MIN;
153 ccode <= DC1394_COLOR_CODING_MAX;
156 if (color_coding_names_[ccode-DC1394_COLOR_CODING_MIN] == color_coding)
159 dc1394color_codings_t ccs;
161 dc1394_format7_get_color_codings(camera, video_mode, &ccs);
162 if (err != DC1394_SUCCESS)
164 ROS_FATAL(
"unable to get supported color codings");
166 return (dc1394color_coding_t) 0;
170 for (uint32_t i = 0; i < ccs.num; ++i)
172 if (ccs.codings[i] == ccode)
173 return (dc1394color_coding_t) ccode;
178 <<
" not supported by this camera");
179 dc1394color_coding_t current_mode;
180 err = dc1394_format7_get_color_coding(camera, video_mode,
182 if (err != DC1394_SUCCESS)
184 ROS_FATAL(
"unable to get current color coding");
186 return (dc1394color_coding_t) 0;
201 return (dc1394color_coding_t) DC1394_COLOR_CODING_MONO8;
217 dc1394video_mode_t video_mode,
221 dc1394framerates_t avail_rates;
223 dc1394_video_get_supported_framerates(camera, video_mode, &avail_rates);
224 if (err != DC1394_SUCCESS)
226 ROS_FATAL(
"getFrameRate() cannot be used for Format7 modes");
227 return (dc1394framerate_t) DC1394_FRAMERATE_NUM;
230 int result = DC1394_FRAMERATE_240;
234 while (result >= DC1394_FRAMERATE_MIN)
236 for (uint32_t i = 0; i < avail_rates.num; ++i)
238 if (avail_rates.framerates[i] == result
239 && rate <= frame_rate)
243 return (dc1394framerate_t) result;
253 ROS_ERROR(
"requested frame_rate (%.3f) not available", frame_rate);
254 return (dc1394framerate_t) DC1394_FRAMERATE_NUM;
266 std::string &video_mode)
268 for (
int vm = DC1394_VIDEO_MODE_MIN;
269 vm <= DC1394_VIDEO_MODE_MAX;
272 if (video_mode_names_[vm-DC1394_VIDEO_MODE_MIN] == video_mode)
275 dc1394video_modes_t vmodes;
277 dc1394_video_get_supported_modes(camera, &vmodes);
278 if (err != DC1394_SUCCESS)
280 ROS_FATAL(
"unable to get supported video modes");
282 return (dc1394video_mode_t) 0;
286 for (uint32_t i = 0; i < vmodes.num; ++i)
288 if (vmodes.modes[i] == vm)
289 return (dc1394video_mode_t) vm;
294 <<
" not supported by this camera");
295 dc1394video_mode_t current_mode;
296 err = dc1394_video_get_mode(camera, ¤t_mode);
297 if (err != DC1394_SUCCESS)
299 ROS_FATAL(
"unable to get current video mode");
301 return (dc1394video_mode_t) 0;
317 return (dc1394video_mode_t) 0;
333 dc1394video_mode_t video_mode,
336 dc1394framerate_t rate =
getFrameRate(camera, video_mode, frame_rate);
337 if (DC1394_FRAMERATE_NUM == rate)
342 if (DC1394_SUCCESS != dc1394_video_set_framerate(camera, rate))
344 ROS_WARN(
"Failed to set frame rate");
363 bool bmode = camera->bmode_capable;
365 && (DC1394_SUCCESS !=
366 dc1394_video_set_operation_mode(camera,
367 DC1394_OPERATION_MODE_1394B)))
370 ROS_WARN(
"failed to set IEEE1394b mode");
374 dc1394speed_t request = DC1394_ISO_SPEED_3200;
379 request = DC1394_ISO_SPEED_400;
384 while (rate > iso_speed)
386 if (request <= DC1394_ISO_SPEED_MIN)
389 dc1394speed_t curSpeed;
390 if (DC1394_SUCCESS == dc1394_video_get_iso_speed(camera, &curSpeed)
391 && curSpeed <= DC1394_ISO_SPEED_MAX)
397 rate = 100 << (curSpeed - DC1394_ISO_SPEED_MIN);
401 ROS_WARN(
"Unable to get ISO speed; assuming 400Mb/s");
403 request = DC1394_ISO_SPEED_400;
409 request = (dc1394speed_t) ((
int) request - 1);
417 if (DC1394_SUCCESS != dc1394_video_set_iso_speed(camera, request))
419 ROS_WARN(
"Failed to set iso speed");
libdc1394 enumerated modes interface
const std::string videoModeName(dc1394video_mode_t mode)
const std::string colorCodingName(dc1394color_coding_t mode)
bool setIsoSpeed(dc1394camera_t *camera, int &iso_speed)
dc1394color_coding_t getColorCoding(dc1394camera_t *camera, dc1394video_mode_t video_mode, std::string &color_coding)
static const std::string video_mode_names_[DC1394_VIDEO_MODE_NUM]
#define ROS_FATAL_STREAM(args)
bool setFrameRate(dc1394camera_t *camera, dc1394video_mode_t video_mode, double &frame_rate)
#define ROS_ERROR_STREAM(args)
dc1394framerate_t getFrameRate(dc1394camera_t *camera, dc1394video_mode_t video_mode, double &frame_rate)
static const std::string color_coding_names_[DC1394_COLOR_CODING_NUM]
driver parameter names, corresponding to DC1394 color codings
dc1394video_mode_t getVideoMode(dc1394camera_t *camera, std::string &video_mode)