24 #include <fvcams/cam_exceptions.h>
25 #include <fvcams/pike.h>
26 #include <fvutils/system/camargp.h>
34 namespace firevision {
44 #define AVT_WHITE_BALANCE_REGISTER (0x0F0080C)
47 #define AVT_AUTOFNC_AOI_REGISTER (0x0390)
48 #define AVT_AF_AREA_POSITION_REGISTER (0x0394)
49 #define AVT_AF_AREA_SIZE_REGISTER (0x0398)
52 #define AVT_VERSION_INFO1_REGISTER (0x1000010)
53 #define AVT_VERSION_INFO3_REGISTER (0x1000018)
73 uint32_t reserved3 : 1;
75 uint32_t reserved2 : 1;
76 uint32_t show_work_area : 1;
77 uint32_t reserved1 : 3;
78 uint32_t presence_inq : 1;
98 uint32_t uc_version : 16;
99 uint32_t uc_type_id : 16;
105 uint32_t fpga_version : 16;
119 aoi_show_work_area_ =
false;
121 set_autofnc_aoi_ =
false;
123 if (cap->
has(
"autofnc_aoi")) {
124 set_autofnc_aoi_ =
true;
144 throw Exception(
"PikeCamera::open: FirewireCamera::open dit not succed");
148 throw Exception(
"PikeCamera::PikeCamera: setting autofnc AOI failed.");
158 dc1394error_t err = dc1394_get_register(
_camera, AVT_VERSION_INFO1_REGISTER, &value);
160 if (err != DC1394_SUCCESS) {
161 throw Exception(
"Pike::print_info; dc1394_get_register(AVT_VERSION_INFO1_REGISTER) failed\n");
165 memcpy((
void *)&version1, (
void *)&value,
sizeof(uint32_t));
167 err = dc1394_get_register(
_camera, AVT_VERSION_INFO3_REGISTER, &value);
169 if (err != DC1394_SUCCESS) {
170 throw Exception(
"Pike::print_info; dc1394_get_register(AVT_VERSION_INFO3_REGISTER) failed\n");
174 memcpy((
void *)&version3, (
void *)&value,
sizeof(uint32_t));
176 printf(
"uC type ID: %d uC version: %x camera type id: %d FPGA version: %x\n",
179 version3.camera_type_id,
180 version3.fpga_version);
202 if (!set_autofnc_aoi_) {
213 position.
left = left;
222 memcpy((
void *)&value, (
void *)&aoi,
sizeof(value));
224 err = dc1394_set_adv_control_register(
_camera, AVT_AUTOFNC_AOI_REGISTER, value);
226 if (err != DC1394_SUCCESS) {
228 "Pike::set_autofunction_aoi; dc1394_set_register(AVT_AUTOFNC_AOI_REGISTER) failed\n");
231 memcpy((
void *)&value, (
void *)&position,
sizeof(value));
232 err = dc1394_set_adv_control_register(
_camera, AVT_AF_AREA_POSITION_REGISTER, value);
234 if (err != DC1394_SUCCESS) {
236 "Pike::set_autofunction_aoi; dc1394_set_register(AVT_AF_AREA_POSITION_REGISTER) failed\n");
239 memcpy((
void *)&value, (
void *)&size,
sizeof(value));
240 err = dc1394_set_adv_control_register(
_camera, AVT_AF_AREA_SIZE_REGISTER, value);
242 if (err != DC1394_SUCCESS) {
244 "Pike::set_autofunction_aoi; dc1394_set_register(AVT_AF_AREA_SIZE_REGISTER) failed\n");
247 err = dc1394_get_adv_control_register(
_camera, AVT_AUTOFNC_AOI_REGISTER, &value);
248 if (err != DC1394_SUCCESS) {
250 "Pike::set_autofunction_aoi; dc1394_get_register(AVT_AUTOFNC_AOI_REGISTER) failed\n");
253 memcpy((
void *)&aoi, (
void *)&value,
sizeof(value));
270 string::size_type pos;
272 pos = a.find(
"x", 0);
273 if (pos == string::npos) {
274 throw Exception(
"Illegal autofnc AOI parameter");
276 string left = a.substr(0, pos);
277 a = a.substr(pos + 1);
279 pos = a.find(
"+", 0);
280 if (pos == string::npos) {
281 throw Exception(
"Illegal autofnc AOI parameter");
283 string top = a.substr(0, pos);
284 a = a.substr(pos + 1);
286 pos = a.find(
"x", 0);
287 if (pos == string::npos) {
288 throw Exception(
"Illegal autofnc AOI parameter");
290 string width = a.substr(0, pos);
291 a = a.substr(pos + 1);
295 pos = a.find(
"-", 0);
296 if (pos == string::npos) {
298 aoi_show_work_area_ =
false;
300 height = a.substr(0, pos);
301 show = a.substr(pos + 1);
303 aoi_show_work_area_ = (show ==
"show") ?
true :
false;
306 aoi_left_ = atoi(left.c_str());
307 aoi_top_ = atoi(top.c_str());
308 aoi_width_ = atoi(width.c_str());
309 aoi_height_ = atoi(height.c_str());