00001 00010 #ifndef PGR_STEREOCAM_H_ 00011 #define PGR_STEREOCAM_H_ 00012 00013 //============================================================================= 00014 // Copyright 2007 Point Grey Research, Inc. All Rights Reserved. 00015 // 00016 // This software is the confidential and proprietary information of Point 00017 // Grey Research, Inc. ("Confidential Information"). You shall not 00018 // disclose such Confidential Information and shall use it only in 00019 // accordance with the terms of the license agreement you entered into 00020 // with Point Grey Research Inc. 00021 // 00022 // PGR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE 00023 // SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 00024 // IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 00025 // PURPOSE, OR NON-INFRINGEMENT. PGR SHALL NOT BE LIABLE FOR ANY DAMAGES 00026 // SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING 00027 // THIS SOFTWARE OR ITS DERIVATIVES. 00028 // 00029 //============================================================================= 00030 00031 //============================================================================= 00032 // 00033 // pgr_stereocam.h 00034 // 00035 //============================================================================= 00036 00037 //============================================================================= 00038 // System Includes 00039 //============================================================================= 00040 00041 //#include "/usr/local/include/dc1394/control.h" 00042 //#include "/usr/local/include/dc1394/control.h" 00043 #include <dc1394/control.h> 00044 #include <dc1394/conversions.h> 00045 #include <dc1394/video.h> 00046 //============================================================================= 00047 // PGR Includes 00048 //============================================================================= 00049 #include <triclops.h> 00050 00051 #include <string.h> 00052 00053 00054 // An enum type that itemizes the possible PGR Stereo cameras 00055 typedef enum 00056 { 00057 UNKNOWN_CAMERA, 00058 BUMBLEBEE, 00059 BUMBLEBEE2, 00060 BUMBLEBEEXB3 00061 } PGRStereoCameraModel_t; 00062 00063 // A structure that contains all information you need to access PGR Stereo 00064 // cameras 00065 typedef struct 00066 { 00067 dc1394camera_t* camera; 00068 PGRStereoCameraModel_t model; 00069 dc1394color_filter_t bayerTile; 00070 bool bColor; 00071 unsigned int nRows; 00072 unsigned int nCols; 00073 unsigned int nBytesPerPixel; 00074 } PGRStereoCamera_t; 00075 00076 00077 //============================================================================= 00078 // Name: isStereoCamera 00079 // 00080 // Input: 00081 // camera - The camera to be queried 00082 // 00083 // Return value: 00084 // A boolean value that is "true" if the camera is recognized as a PGR Stereo 00085 // camera and "false" otherwise. 00086 // 00087 // Description: 00088 // This function determines via checking the model string of the camera 00089 // whether it is a known PGR stereo camera model. 00090 // 00091 //============================================================================= 00092 bool 00093 isStereoCamera( dc1394camera_t* camera ); 00094 00095 //============================================================================= 00096 // Name: getCameraModel 00097 // 00098 // Input: 00099 // camera - The camera to be queried 00100 // 00101 // Return value: 00102 // Returns an enum value that defines which camera model this camera is. 00103 // 00104 //============================================================================= 00105 PGRStereoCameraModel_t 00106 getCameraModel( dc1394camera_t* camera ); 00107 00108 //============================================================================= 00109 // Name: queryStereoCamera 00110 // 00111 // Input: 00112 // camera - The camera to be queried 00113 // 00114 // Output: 00115 // stereoCamera - a structure that contains all the required information 00116 // about this stereo camera 00117 // 00118 // Description: 00119 // This function queries information from the stereo camera and determines 00120 // information that is required to populate the PGRStereoCamera_t structure. 00121 // This includes information like what model and resolution the camera is and 00122 // whether the camera is color or B&W. 00123 // 00124 //============================================================================= 00125 dc1394error_t 00126 queryStereoCamera( dc1394camera_t* camera, 00127 PGRStereoCamera_t * stereoCamera ); 00128 00129 //============================================================================= 00130 // Name: setStereoVideoCapture 00131 // 00132 // Input: 00133 // stereoaAmera - The camera to grab from 00134 // 00135 // Description: 00136 // This function figures out based on the model of the stereo camera what 00137 // format and mode the camera should be set up to transfer data in. 00138 // 00139 // Note: currently always sets the maximum framerate. 00140 // 00141 //============================================================================= 00142 dc1394error_t 00143 setStereoVideoCapture( PGRStereoCamera_t* stereoCamera ); 00144 00145 //============================================================================= 00146 // Name: startTransmission 00147 // 00148 // Input: 00149 // stereoCamera - The camera to grab from 00150 // 00151 // Description: 00152 // In the libdc1394 examples, there is a wait loop that waits after transmission 00153 // is requested until the transmission has successfully started. This seemed 00154 // like a nice thing to hide from every program so it is bundled up in here. 00155 //============================================================================= 00156 dc1394error_t 00157 startTransmission( PGRStereoCamera_t* stereoCamera ); 00158 00159 //============================================================================= 00160 // Name: extractImagesColor 00161 // 00162 // Input: 00163 // stereoCamera - The camera to grab from 00164 // bayerMethod - The requested method for performing bayer->color translations 00165 // 00166 // Output: 00167 // pucDeInterleaved - a buffer to hold the de-interleaved bayer images 00168 // size is (nrows * ncols * nimages) 00169 // allocated outside this function 00170 // pucRGB - a buffer to hold the RGB images 00171 // size is (nrows * ncols * nimages * 3) 00172 // allocated outside this function 00173 // pucGreen - a buffer to hold the green channels of the images 00174 // size is (nrows * ncols * nimages) 00175 // allocated outside this function 00176 // ppucRightRGB - a pointer to the right RGB buffer (into pucRGB) 00177 // size is (nrows * ncols * 3) 00178 // points into pucRGB 00179 // ppucLeftRGB - a pointer to the left RGB buffer 00180 // size is (nrows * ncols * 3) 00181 // points into pucRGB 00182 // ppucCenterRGB - a pointer to the center RGB buffer 00183 // size is (nrows * ncols * 3) 00184 // points into pucRGB 00185 // This is only valid for a BB XB3 00186 // pTriclopsInput - the Triclops input 00187 // points into pucGreen 00188 // 00189 // Description: 00190 // A function to extract the grab buffer from the libdc1394 camera, and to 00191 // perform the required de-interleaving and bayer color processing on the 00192 // images to generate a left and right color image and a TriclopsInput for 00193 // stereo processing. 00194 //============================================================================= 00195 void 00196 extractImagesColor( PGRStereoCamera_t* stereoCamera, 00197 dc1394bayer_method_t bayerMethod, 00198 unsigned char* pucDeInterleaved, 00199 unsigned char* pucRGB, 00200 unsigned char* pucGreen, 00201 unsigned char** ppucRightRGB, 00202 unsigned char** ppucLeftRGB, 00203 unsigned char** ppucCenterRGB, 00204 TriclopsInput* pTriclopsInput ); 00205 00206 //============================================================================= 00207 // Name: extractImagesMono 00208 // 00209 // Input: 00210 // stereoCamera - The camera to grab from 00211 // 00212 // Output: 00213 // pucDeInterleaved - a buffer to hold the de-interleaved bayer images 00214 // size is (nrows * ncols * nimages) 00215 // allocated outside this function 00216 // ppucRightMono8 - a pointer to the right RGB buffer (into pucRGB) 00217 // size is (nrows * ncols * 3) 00218 // points into pucRGB 00219 // ppucLeftMono8 - a pointer to the left RGB buffer 00220 // size is (nrows * ncols * 3) 00221 // points into pucRGB 00222 // ppucCenterMono8 - a pointer to the center RGB buffer 00223 // size is (nrows * ncols * 3) 00224 // points into pucRGB 00225 // This is only valid for a BB XB3 00226 // pTriclopsInput - the Triclops input 00227 // points into pucGreen 00228 // 00229 // Description: 00230 // A function to extract the grab buffer from the libdc1394 camera, and to 00231 // perform the required de-interleaving on the images to generate a left 00232 // and right mono image and a TriclopsInput for stereo processing. 00233 //============================================================================= 00234 void 00235 extractImagesMono( PGRStereoCamera_t* stereoCamera, 00236 unsigned char* pucDeInterleaved, 00237 unsigned char** ppucRightMono8, 00238 unsigned char** ppucLeftMono8, 00239 unsigned char** ppucCenterMono8, 00240 TriclopsInput* pTriclopsInput ); 00241 00242 00243 //============================================================================= 00244 // Name: getTriclopsContextFromCamera 00245 // 00246 // Input: 00247 // stereoCamera - The camera to get the TriclopsContext from 00248 // 00249 // Output: 00250 // pTriclops - The retrieved TriclopsContext 00251 // 00252 // Description: 00253 // This function extracts the .cal calibration file from the camera, and writes 00254 // it to a file in /tmp. It then loads the file back into a TriclopsContext. 00255 // 00256 // At the moment it is slow due to inefficient retrieval of the file from the 00257 // camera. 00258 // 00259 // Also, the name of the file is hardcoded and is always the same. This may 00260 // cause permission problems on multi-user systems. Since code is provided, 00261 // however, please feel free to alter. 00262 //============================================================================= 00263 TriclopsError 00264 getTriclopsContextFromCamera( PGRStereoCamera_t* camera, 00265 TriclopsContext* pTriclops ); 00266 00267 00268 00269 void 00270 extractImagesColorXB3( PGRStereoCamera_t* stereoCamera, 00271 dc1394bayer_method_t bayerMethod, 00272 unsigned char* pucDeInterleaved, 00273 unsigned char* pucRGB, 00274 unsigned char* pucGreen, 00275 unsigned char** ppucRightRGB, 00276 unsigned char** ppucLeftRGB, 00277 unsigned char** ppucCenterRGB, 00278 TriclopsInput* pShortInput, 00279 TriclopsInput* pWideInput ); 00280 00281 void 00282 extractImagesColorXB3( PGRStereoCamera_t* stereoCamera, 00283 00284 dc1394bayer_method_t bayerMethod, 00285 00286 unsigned char* pucDeInterleaved, 00287 00288 unsigned char* pucRGB, 00289 00290 unsigned char* pucGreen, 00291 00292 unsigned char** ppucRightRGB, 00293 00294 unsigned char** ppucLeftRGB, 00295 00296 unsigned char** ppucCenterRGB); 00297 00298 void 00299 extractImagesMonoXB3( PGRStereoCamera_t* stereoCamera, 00300 unsigned char* pucDeInterleaved, 00301 unsigned char** ppucRightMono8, 00302 unsigned char** ppucLeftMono8, 00303 unsigned char** ppucCenterMono8, 00304 TriclopsInput* pShortInput, 00305 TriclopsInput* pWideInput ); 00306 00307 #endif 00308 00309 #if 0 00310 #endif 00311 00314 /*Previous 3 lines appended automatically on Wed Jun 9 00:11:56 WEST 2010 */