📄 dc1394_format7.c
字号:
if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) { return DC1394_FAILURE; } retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_COLOR_CODING_INQ, value); return retval;} intdc1394_query_format7_pixel_number(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int *pixnum){ int retval; quadlet_t value; if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) { return DC1394_FAILURE; } retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_PIXEL_NUMBER_INQ, &value); *pixnum= (unsigned int) value; return retval;} intdc1394_query_format7_total_bytes(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned long long int *total_bytes){ int retval; unsigned long long int value_hi, value_lo; quadlet_t value; if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) { return DC1394_FAILURE; } retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_TOTAL_BYTES_HI_INQ, &value); value_hi=value; if (retval != DC1394_SUCCESS) return DC1394_FAILURE; retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_TOTAL_BYTES_LO_INQ, &value); value_lo=value; *total_bytes= (value_lo | ( value_hi << 32) ); return retval;} intdc1394_query_format7_packet_para(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int *min_bytes, unsigned int *max_bytes){ int retval; quadlet_t value; if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) { return DC1394_FAILURE; } retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_PACKET_PARA_INQ, &value); *min_bytes= (unsigned int) ( value & 0xFFFF0000UL ) >> 16; *max_bytes= (unsigned int) ( value & 0x0000FFFFUL ); return retval;} intdc1394_query_format7_byte_per_packet(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int *packet_bytes){ int retval; quadlet_t value; if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) { return DC1394_FAILURE; } retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_BYTE_PER_PACKET, &value); *packet_bytes= (unsigned int) ( value & 0xFFFF0000UL ) >> 16; if (packet_bytes==0) { printf("(%s): BYTES_PER_PACKET is zero. This should not happen.\n", __FILE__); return DC1394_FAILURE; } return retval;} intdc1394_set_format7_image_position(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int left, unsigned int top){ if (SetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_IMAGE_POSITION, (quadlet_t)((left << 16) | top)) != DC1394_SUCCESS) { printf("(%s) Format7 image position setting failure \n", __FILE__); return DC1394_FAILURE; } else // IIDC v1.30 handshaking: return _dc1394_v130_handshake(handle, node, mode);} intdc1394_set_format7_image_size(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int width, unsigned int height){ if (SetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_IMAGE_SIZE, (quadlet_t)((width << 16) | height)) != DC1394_SUCCESS) { printf("(%s) Format7 image size setting failure \n", __FILE__); return DC1394_FAILURE; } else // IIDC v1.30 handshaking: return _dc1394_v130_handshake(handle, node, mode);} intdc1394_set_format7_color_coding_id(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int color_id){ if ( (color_id < COLOR_FORMAT7_MIN) || (color_id > COLOR_FORMAT7_MAX) ) { return DC1394_FAILURE; } color_id-= COLOR_FORMAT7_MIN; color_id=color_id<<24; if (SetCameraFormat7Register(handle, node, mode,REG_CAMERA_FORMAT7_COLOR_CODING_ID, (quadlet_t)color_id) != DC1394_SUCCESS) { printf("(%s) Format7 color coding ID setting failure \n", __FILE__); return DC1394_FAILURE; } else // IIDC v1.30 handshaking: return _dc1394_v130_handshake(handle, node, mode);} intdc1394_set_format7_byte_per_packet(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int packet_bytes){ if (SetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_BYTE_PER_PACKET, (quadlet_t)(packet_bytes) << 16 ) != DC1394_SUCCESS) { printf("(%s) Format7 bytes-per-packet setting failure \n", __FILE__); return DC1394_FAILURE; } else // IIDC v1.30 error checking: return _dc1394_v130_errflag2(handle, node, mode);}intdc1394_query_format7_value_setting(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int *present, unsigned int *setting1, unsigned int *err_flag1, unsigned int *err_flag2){ int retval; quadlet_t value; dc1394_camerahandle *camera; camera = (dc1394_camerahandle*) raw1394_get_userdata( handle ); if (camera->sw_version>=IIDC_VERSION_1_30) { if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) { return DC1394_FAILURE; } retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_VALUE_SETTING, &value); *present= (unsigned int) ( value & 0x80000000UL ) >> 31; *setting1= (unsigned int) ( value & 0x40000000UL ) >> 30; *err_flag1= (unsigned int) ( value & 0x00800000UL ) >> 23; *err_flag2= (unsigned int) ( value & 0x00400000UL ) >> 22; } else { *present=0; return DC1394_SUCCESS; } return retval;}intdc1394_set_format7_value_setting(raw1394handle_t handle, nodeid_t node, unsigned int mode){ return SetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_VALUE_SETTING, (quadlet_t)0x40000000UL);} intdc1394_query_format7_recommended_byte_per_packet(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int *bpp){ int retval; quadlet_t value; if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) { return DC1394_FAILURE; } retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_BYTE_PER_PACKET, &value); *bpp= (unsigned int) ( value & 0x0000FFFFUL ); return retval;}intdc1394_query_format7_packet_per_frame(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int *ppf){ int retval; quadlet_t value; unsigned int packet_bytes; unsigned long long int total_bytes; dc1394_camerahandle *camera; camera = (dc1394_camerahandle*) raw1394_get_userdata( handle ); if (camera->sw_version>=IIDC_VERSION_1_30) { if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) { return DC1394_FAILURE; } retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_PACKET_PER_FRAME_INQ, &value); *ppf= (unsigned int) (value); return retval; } else { // return an estimate, NOT TAKING ANY PADDING INTO ACCOUNT if (dc1394_query_format7_byte_per_packet(handle, node, mode, &packet_bytes)!=DC1394_SUCCESS) { return DC1394_FAILURE; } if (packet_bytes==0) { return DC1394_FAILURE; } if (dc1394_query_format7_total_bytes(handle, node, mode, &total_bytes)!=DC1394_SUCCESS) { return DC1394_FAILURE; } if (total_bytes%packet_bytes!=0) *ppf=total_bytes/packet_bytes+1; else *ppf=total_bytes/packet_bytes; return DC1394_SUCCESS; }}intdc1394_query_format7_unit_position(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int *horizontal_pos, unsigned int *vertical_pos){ int retval; quadlet_t value; dc1394_camerahandle *camera; camera = (dc1394_camerahandle*) raw1394_get_userdata( handle ); if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) { return DC1394_FAILURE; } if (camera->sw_version>=IIDC_VERSION_1_30) { retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_UNIT_POSITION_INQ, &value); } else { // if version is not 1.30, use the UNIT_SIZE_INQ register retval= GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_UNIT_SIZE_INQ, &value); } *horizontal_pos = (unsigned int) (( value & 0xFFFF0000UL )>>16); *vertical_pos = (unsigned int) ( value & 0x0000FFFFUL ); return retval;}intdc1394_query_format7_frame_interval(raw1394handle_t handle, nodeid_t node, unsigned int mode, float *interval){ quadlet_t value; if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) return DC1394_FAILURE; if (GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_FRAME_INTERVAL_INQ, &value)==DC1394_FAILURE) return DC1394_FAILURE; *interval=value; return DC1394_SUCCESS;} intdc1394_query_format7_data_depth(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int *data_depth){ quadlet_t value; if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) return DC1394_FAILURE; if (GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_DATA_DEPTH_INQ, &value)==DC1394_FAILURE) return DC1394_FAILURE; *data_depth=value >> 24; return DC1394_SUCCESS;} intdc1394_query_format7_color_filter_id(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int *color_id){ quadlet_t value; if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) return DC1394_FAILURE; if (GetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_COLOR_FILTER_ID, &value)==DC1394_FAILURE) return DC1394_FAILURE; *color_id= (value >> 24)+COLOR_FORMAT7_MIN; return DC1394_SUCCESS;} intdc1394_set_format7_color_filter_id(raw1394handle_t handle, nodeid_t node, unsigned int mode, unsigned int color_id){ if ( (mode > MODE_FORMAT7_MAX) || (mode < MODE_FORMAT7_MIN) ) return DC1394_FAILURE; if (SetCameraFormat7Register(handle, node, mode, REG_CAMERA_FORMAT7_COLOR_FILTER_ID, color_id - COLOR_FORMAT7_MIN)==DC1394_FAILURE) return DC1394_FAILURE; return DC1394_SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -