24 #include <fvcams/pike.h>
25 #include <fvcams/cam_exceptions.h>
27 #include <fvutils/system/camargp.h>
33 using namespace fawkes;
35 namespace firevision {
48 #define AVT_WHITE_BALANCE_REGISTER (0x0F0080C)
51 #define AVT_AUTOFNC_AOI_REGISTER (0x0390)
52 #define AVT_AF_AREA_POSITION_REGISTER (0x0394)
53 #define AVT_AF_AREA_SIZE_REGISTER (0x0398)
56 #define AVT_VERSION_INFO1_REGISTER (0x1000010)
57 #define AVT_VERSION_INFO3_REGISTER (0x1000018)
76 uint32_t reserved3 : 1;
78 uint32_t reserved2 : 1;
79 uint32_t show_work_area : 1;
80 uint32_t reserved1 : 3;
81 uint32_t presence_inq : 1;
98 uint32_t uc_version : 16;
99 uint32_t uc_type_id : 16;
104 uint32_t fpga_version : 16;
105 uint32_t camera_type_id : 16;
119 __aoi_show_work_area =
false;
121 __set_autofnc_aoi =
false;
123 if ( cap->
has(
"autofnc_aoi" ) )
125 __set_autofnc_aoi =
true;
145 {
throw Exception(
"PikeCamera::open: FirewireCamera::open dit not succed" ); }
148 __aoi_show_work_area ) )
150 throw Exception(
"PikeCamera::PikeCamera: setting autofnc AOI failed." );
160 dc1394error_t err = dc1394_get_register(
_camera,
161 AVT_VERSION_INFO1_REGISTER,
164 if ( err != DC1394_SUCCESS )
166 throw Exception(
"Pike::print_info; dc1394_get_register(AVT_VERSION_INFO1_REGISTER) failed\n" );
170 memcpy( (
void*) &version1, (
void*) &value,
sizeof(uint32_t) );
172 err = dc1394_get_register(
_camera,
173 AVT_VERSION_INFO3_REGISTER,
176 if ( err != DC1394_SUCCESS )
178 throw Exception(
"Pike::print_info; dc1394_get_register(AVT_VERSION_INFO3_REGISTER) failed\n" );
182 memcpy( (
void*) &version3, (
void*) &value,
sizeof(uint32_t) );
184 printf(
"uC type ID: %d uC version: %x camera type id: %d FPGA version: %x\n",
201 bool show_work_area )
206 if ( !__set_autofnc_aoi )
216 position.
left = left;
225 memcpy( (
void*) &value, (
void*) &aoi,
sizeof( value ) );
227 err = dc1394_set_adv_control_register(
_camera,
228 AVT_AUTOFNC_AOI_REGISTER,
231 if ( err != DC1394_SUCCESS )
233 throw Exception(
"Pike::set_autofunction_aoi; dc1394_set_register(AVT_AUTOFNC_AOI_REGISTER) failed\n" );
236 memcpy( (
void*) &value, (
void*) &position,
sizeof( value ) );
237 err = dc1394_set_adv_control_register(
_camera,
238 AVT_AF_AREA_POSITION_REGISTER,
241 if ( err != DC1394_SUCCESS )
243 throw Exception(
"Pike::set_autofunction_aoi; dc1394_set_register(AVT_AF_AREA_POSITION_REGISTER) failed\n" );
246 memcpy( (
void*) &value, (
void*) &size,
sizeof( value ) );
247 err = dc1394_set_adv_control_register(
_camera,
248 AVT_AF_AREA_SIZE_REGISTER,
251 if ( err != DC1394_SUCCESS )
253 throw Exception(
"Pike::set_autofunction_aoi; dc1394_set_register(AVT_AF_AREA_SIZE_REGISTER) failed\n" );
256 err = dc1394_get_adv_control_register(
_camera,
257 AVT_AUTOFNC_AOI_REGISTER,
259 if ( err != DC1394_SUCCESS )
261 throw Exception(
"Pike::set_autofunction_aoi; dc1394_get_register(AVT_AUTOFNC_AOI_REGISTER) failed\n" );
264 memcpy ( (
void*) &aoi, (
void*) &value,
sizeof( value ) );
281 string::size_type pos;
283 pos = a.find(
"x", 0 );
284 if ( pos == string::npos )
285 {
throw Exception(
"Illegal autofnc AOI parameter" ); }
286 string left = a.substr( 0, pos );
287 a = a.substr( pos + 1 );
289 pos = a.find(
"+", 0 );
290 if ( pos == string::npos )
291 {
throw Exception(
"Illegal autofnc AOI parameter" ); }
292 string top = a.substr( 0, pos );
293 a = a.substr( pos + 1 );
295 pos = a.find(
"x", 0 );
296 if ( pos == string::npos )
297 {
throw Exception(
"Illegal autofnc AOI parameter" ); }
298 string width = a.substr( 0, pos );
299 a = a.substr( pos + 1 );
303 pos = a.find(
"-", 0 );
304 if ( pos == string::npos )
307 __aoi_show_work_area =
false;
311 height = a.substr( 0, pos );
312 show = a.substr( pos + 1 );
314 __aoi_show_work_area = ( show ==
"show" ) ?
true :
false;
317 __aoi_left = atoi( left.c_str() );
318 __aoi_top = atoi( top.c_str() );
319 __aoi_width = atoi( width.c_str() );
320 __aoi_height = atoi( height.c_str() );