00001 00011 //============================================================================= 00012 // Copyright © 2006 Point Grey Research, Inc. All Rights Reserved. 00013 // 00014 // This software is the confidential and proprietary information of Point 00015 // Grey Research, Inc. ("Confidential Information"). You shall not 00016 // disclose such Confidential Information and shall use it only in 00017 // accordance with the terms of the license agreement you entered into 00018 // with Point Grey Research Inc. 00019 // 00020 // PGR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE 00021 // SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 00022 // IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 00023 // PURPOSE, OR NON-INFRINGEMENT. PGR SHALL NOT BE LIABLE FOR ANY DAMAGES 00024 // SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING 00025 // THIS SOFTWARE OR ITS DERIVATIVES. 00026 // 00027 //============================================================================= 00028 00029 //============================================================================= 00030 // 00031 // pgr_registers.cpp 00032 // 00033 //============================================================================= 00034 00035 //============================================================================= 00036 // System Includes 00037 //============================================================================= 00038 #include <stdio.h> 00039 #include <errno.h> 00040 #include <dc1394/dc1394.h> 00041 00042 //============================================================================= 00043 // PGR Includes 00044 //============================================================================= 00045 #include "pgr_registers.h" 00046 00047 //============================================================================= 00048 // Implementation 00049 //============================================================================= 00050 00051 00052 //============================================================================= 00053 // getBayerTile() 00054 // Query the PGR specific register that indicates the Bayer tile pattern 00055 // color coding for this camera. 00056 // 00057 // For more information check the PGR IEEE-1394 Digital Camera Register 00058 // Reference 00059 // 00060 dc1394error_t 00061 getBayerTile( dc1394camera_t* camera, 00062 dc1394color_filter_t* bayerPattern ) 00063 { 00064 00065 uint32_t value; 00066 dc1394error_t err; 00067 00068 // query register 0x1040 00069 // This register is an advanced PGR register called BAYER_TILE_MAPPING 00070 // For more information check the PGR IEEE-1394 Digital Camera Register Reference 00071 err = dc1394_get_control_register( camera, BAYER_TILE_MAPPING_REGISTER, &value ); 00072 if ( err != DC1394_SUCCESS ) 00073 { 00074 return err; 00075 } 00076 00077 // Ascii R = 52 G = 47 B = 42 Y = 59 00078 switch( value ) 00079 { 00080 default: 00081 case 0x59595959: // YYYY 00082 // no bayer 00083 *bayerPattern = (dc1394color_filter_t) 0; 00084 break; 00085 case 0x52474742: // RGGB 00086 *bayerPattern = DC1394_COLOR_FILTER_RGGB; 00087 break; 00088 case 0x47425247: // GBRG 00089 *bayerPattern = DC1394_COLOR_FILTER_GBRG; 00090 break; 00091 case 0x47524247: // GRBG 00092 *bayerPattern = DC1394_COLOR_FILTER_GRBG; 00093 break; 00094 case 0x42474752: // BGGR 00095 *bayerPattern = DC1394_COLOR_FILTER_BGGR; 00096 break; 00097 } 00098 00099 return err; 00100 } 00101 00102 //============================================================================= 00103 // setEndian() 00104 // Set the endian-ness of 16-bit data coming from the camera. 00105 // 00106 // This is a PGR camera specific register 00107 // For more information check the PGR IEEE-1394 Digital Camera Register 00108 // Reference 00109 // 00110 dc1394error_t 00111 setEndian( dc1394camera_t* camera, 00112 bool bBigEndian ) 00113 { 00114 00115 uint32_t value; 00116 dc1394error_t err; 00117 00118 if ( bBigEndian ) 00119 { 00120 // use 16-bit modes in big endian (default 1394) format 00121 value = 0x80000001; 00122 } 00123 else 00124 { 00125 // use 16-bit modes in little endian (pgr default) format 00126 value = 0x80000000; 00127 } 00128 00129 00130 err = dc1394_set_control_register( camera, 00131 IMAGE_DATA_FORMAT_REGISTER, 00132 value ); 00133 return err; 00134 } 00135 00136 00137 //============================================================================= 00138 // getSensorInfo() 00139 // This function queries the SENSOR BOARD INFO register and extracts 00140 // the sensor resolution and whether it is color or monochrome from the 00141 // register 00142 // 00143 // This is a PGR camera specific register 00144 // For more information check the PGR IEEE-1394 Digital Camera Register 00145 // Reference 00146 // 00147 dc1394error_t 00148 getSensorInfo( dc1394camera_t* camera, 00149 bool* pbColor, 00150 unsigned int* pnRows, 00151 unsigned int* pnCols ) 00152 { 00153 00154 uint32_t value; 00155 dc1394error_t err; 00156 00157 // This register is an advanced PGR register called SENSOR_BOARD_INFO 00158 err = dc1394_get_control_register( camera, SENSOR_BOARD_INFO_REGISTER, &value ); 00159 if ( err != DC1394_SUCCESS ) 00160 { 00161 return err; 00162 } 00163 00164 unsigned char ucSensorInfo = 0xf & value; 00165 00166 switch( ucSensorInfo ) 00167 { 00168 default: 00169 // unknown sensor! 00170 printf( "Illegal sensor board info detected!\n" ); 00171 return DC1394_FAILURE; 00172 case 0xA: // color 640x480 00173 *pbColor = true; 00174 *pnRows = 480; 00175 *pnCols = 640; 00176 break; 00177 case 0xB: // mono 640x480 00178 *pbColor = false; 00179 *pnRows = 480; 00180 *pnCols = 640; 00181 break; 00182 case 0xC: // color 1024x768 00183 *pbColor = true; 00184 *pnRows = 768; 00185 *pnCols = 1024; 00186 break; 00187 case 0xD: // mono 1024x768 00188 *pbColor = false; 00189 *pnRows = 768; 00190 *pnCols = 1024; 00191 break; 00192 case 0xE: // color 1280x960 00193 *pbColor = true; 00194 *pnRows = 960; 00195 *pnCols = 1280; 00196 break; 00197 case 0xF: // mono 1280x960 00198 *pbColor = false; 00199 *pnRows = 960; 00200 *pnCols = 1280; 00201 break; 00202 } 00203 00204 return err; 00205 } 00206 00207 00211 /*Previous 3 lines appended automatically on Wed Jun 9 00:11:56 WEST 2010 */