00001 00006 //============================================================================= 00007 // Copyright © 2004 Point Grey Research, Inc. All Rights Reserved. 00008 // 00009 // This software is the confidential and proprietary information of Point 00010 // Grey Research, Inc. ("Confidential Information"). You shall not 00011 // disclose such Confidential Information and shall use it only in 00012 // accordance with the terms of the license agreement you entered into 00013 // with Point Grey Research, Inc. (PGR). 00014 // 00015 // PGR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE 00016 // SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 00017 // IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 00018 // PURPOSE, OR NON-INFRINGEMENT. PGR SHALL NOT BE LIABLE FOR ANY DAMAGES 00019 // SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING 00020 // THIS SOFTWARE OR ITS DERIVATIVES. 00021 // 00022 //============================================================================= 00023 //============================================================================= 00024 // $Id: triclopsimageio.h,v 2.6 2007/11/30 00:43:03 soowei Exp $ 00025 //============================================================================= 00026 #ifndef TRICLOPSIMAGEIO_H 00027 #define TRICLOPSIMAGEIO_H 00028 00029 //============================================================================= 00030 // 00031 // This file defines the API for the Triclops Stereo Vision SDK 00032 // for functions that deal with saving and loading images 00033 // 00034 //============================================================================= 00035 00036 00037 //============================================================================= 00038 // Defines 00039 //============================================================================= 00040 00041 //============================================================================= 00042 // System Includes 00043 //============================================================================= 00044 00045 #include <triclops.h> 00046 00047 #ifdef __cplusplus 00048 extern "C" 00049 { 00050 #endif 00051 00052 //============================================================================= 00053 // Macros 00054 //============================================================================= 00055 00056 //============================================================================= 00057 // Enumerations 00058 //============================================================================= 00059 00060 //============================================================================= 00061 // Types 00062 //============================================================================= 00063 // 00064 // Group = Types 00065 00066 // 00067 // Name: RectifiedImageInfo 00068 // 00069 // Description: 00070 // Information that is stored in a Pgm file created using 00071 // triclopsSaveImageExtra when passed the TriclopsImageType TriImg_RECTIFIED 00072 // as the second parameter. 00073 // 00074 typedef struct 00075 { 00076 TriclopsRectImgQuality rectQuality; 00077 } RectifiedImageInfo; 00078 00079 // 00080 // Name: EdgeImageInfo 00081 // 00082 // Description: 00083 // Information that is stored in a Pgm file created using 00084 // triclopsSaveImageExtra when passed the TriclopsImageType TriImg_EDGE 00085 // as the second parameter. 00086 // 00087 typedef struct 00088 { 00089 TriclopsRectImgQuality rectQuality; 00090 int edgeMaskSize; 00091 bool lowpassOn; 00092 } EdgeImageInfo; 00093 00094 // 00095 // Name: DisparityImageInfo 00096 // 00097 // Description: 00098 // Information that is stored in a Pgm file created using 00099 // triclopsSaveImageExtra when passed the TriclopsImageType TriImg_DISPARITY 00100 // as the second parameter. 00101 // 00102 typedef struct 00103 { 00104 TriclopsRectImgQuality rectQuality; 00105 bool edgeCorrelationOn; 00106 int edgeMaskSize; 00107 bool lowpassOn; 00108 TriclopsStereoQuality stereoQuality; 00109 TriclopsCameraConfiguration camConfig; 00110 int stereoMaskSize; 00111 int minDisparity; 00112 int maxDisparity; 00113 int nDisparityOffset; 00114 bool disparityMappingOn; 00115 int minDispMapping; 00116 int maxDispMapping; 00117 bool textureValidOn; 00118 double textureValidThreshold; 00119 unsigned char textureValidMapping; 00120 bool uniqueValidOn; 00121 double uniqueValidThreshold; 00122 unsigned char uniqueValidMapping; 00123 bool backForthValidOn; 00124 unsigned char backForthValidMapping; 00125 bool surfaceValidOn; 00126 double surfaceValidDiff; 00127 int surfaceValidSize; 00128 unsigned char surfaceValidMapping; 00129 } DisparityImageInfo; 00130 00131 // 00132 // Name: TriclopsImageInfo 00133 // 00134 // Description: 00135 // This structure is used to hold any image information available when an 00136 // image is read in to the triclopsLibrary. It currently works with the 00137 // function calls triclopsReadImage[16]Extra. Different information is available 00138 // depending on the TriclopsImageType of the image -- that is the function 00139 // of the union. The information will be available if the image was created 00140 // using the triclopsSaveImage[16]Extra function. 00141 typedef struct 00142 { 00143 bool commentFound; 00144 char product[100]; 00145 int serialNumber; 00146 TriclopsCamera nCamera; 00147 union 00148 { 00149 TriclopsImageType imageType; 00150 TriclopsImage16Type image16Type; 00151 } type; 00152 union 00153 { 00154 RectifiedImageInfo rectified; 00155 EdgeImageInfo edge; 00156 DisparityImageInfo disparity; 00157 } info; 00158 00159 } TriclopsImageInfo; 00160 00161 00162 //============================================================================= 00163 // Image I/O Operations 00164 //============================================================================= 00165 // Group = Image I/O Operations 00166 00167 // 00168 // Name: triclopsSaveImageExtra 00169 // 00170 // Synopsis: 00171 // Saves the specified type of image associated with the specified camera to a 00172 // file named "filename". Currently, the only output file format supported is PGM. 00173 // 00174 // Input: 00175 // context - The context. 00176 // imageType - The image type requested. 00177 // camera - The camera that generated the requested image. 00178 // filename - The file name in which to save the image. 00179 // 00180 // Returns: 00181 // TriclopsErrorOk - The operation succeeded. 00182 // SystemError - The file could not be opened 00183 // InvalidContext - The input context was invalid. 00184 // InvalidCamera - The camera does not match a camera in this configuration. 00185 // InvalidRequest - The image type does not match the camera or is not being 00186 // generated by this system with the current context options. 00187 // ErrorUnknown - The image was unable to be written properly for an unknown 00188 // reason. 00189 // 00190 // Description: 00191 // Saves the specified type of image associated with the specified camera to a 00192 // file named "filename". Depending on the image type, certain useful 00193 // comments are filled in to the header. 00194 // For all images, the camera type and serial number are filled in. For each 00195 // image type, only relevant parameters are filled in. E.g., for the 00196 // TriImg_RECTIFIED type, the only additional comment is the rectification 00197 // quality. 00198 // 00199 TriclopsError 00200 triclopsSaveImageExtra( const TriclopsContext context, 00201 TriclopsImageType imageType, 00202 TriclopsCamera camera, 00203 char* filename); 00204 00205 // 00206 // Name: triclopsSaveImage16Extra 00207 // 00208 // Synopsis: 00209 // Saves the specified type of 16-bit image associated with the specified 00210 // camera to a file named "filename". Currently, the only output file format 00211 // supported is PGM. 00212 // 00213 // Input: 00214 // context - The context. 00215 // image16Type - The 16-bit image type requested. 00216 // camera - The camera that generated the requested image. 00217 // filename - The file name in which to save the image. 00218 // 00219 // Returns: 00220 // TriclopsErrorOk - The operation succeeded. 00221 // SystemError - The file could not be opened 00222 // InvalidContext - The input context was invalid. 00223 // InvalidCamera - The camera does not match a camera in this configuration. 00224 // InvalidRequest - The image type does not match the camera or is not being 00225 // generated by this system with the current context options. 00226 // ErrorUnknown - The image was unable to be written properly for an unknown 00227 // reason. 00228 // 00229 // Description: 00230 // Saves the specified type of 16-bit image associated with the specified camera 00231 // to a file named "filename". Depending on the image type, certain useful 00232 // comments are filled in to the header. 00233 // For all images, the camera type and serial number are filled in. 00234 // 00235 // See Also: 00236 // triclopsSaveImageExtra() 00237 // 00238 TriclopsError 00239 triclopsSaveImage16Extra( const TriclopsContext context, 00240 TriclopsImage16Type image16Type, 00241 TriclopsCamera camera, 00242 char* filename ); 00243 00244 // 00245 // Name: triclopsReadImageExtra 00246 // 00247 // Synopsis: 00248 // Reads an image from a file named "filename" into a triclopsImage, 00249 // filling in as much of the imageInfo structure as possible from the input 00250 // file's header. Currently, the only input file format supported is PGM. 00251 // 00252 // Input: 00253 // filename - The name of the file from which the image is read. 00254 // triclopsImage - The image that gets read. 00255 // imageInfo - Relevant information about the image that is read. 00256 // 00257 // Returns: 00258 // TriclopsErrorOk - The operation succeeded. 00259 // TriclopsErrorFileRead - Could not read in the specified file (not 00260 // found, or corrupted). 00261 // TriclopsErrorCorruptPGRComment - The PGR comment in the header was 00262 // corrupted. The imageInfo is invalid, but the file body ("the image") 00263 // was read in successfully. 00264 // 00265 // Description: 00266 // Reads an image from a file named "filename" into a triclopsImage. If 00267 // the image was created using the triclopsSaveImageExtra function, it should 00268 // contain information about the image, depending on the image type. This 00269 // information is parsed from the header and placed into the imageInfo 00270 // structure. If the image is a rectified, edge, or disparity image, the 00271 // appropriate parameter in the TriclopsImageInfo union will be filled in. 00272 // ** NOTE: Even if the function returns triclopsErrorOk, you still need to 00273 // check the TriclopsImageInfo "commentFound" boolean field, in case there 00274 // was no PGRComment associated with the input file. 00275 // 00276 // See Also: 00277 // triclopsReadImage16Extra() 00278 // 00279 TriclopsError 00280 triclopsReadImageExtra( char* filename, 00281 TriclopsImage* triclopsImage, 00282 TriclopsImageInfo* imageInfo); 00283 00284 // 00285 // Name: triclopsReadImage16Extra 00286 // 00287 // Synopsis: 00288 // Reads an image from a file named "filename" into a TriclopsImage16, 00289 // filling in as much of the imageInfo structure as possible from the input 00290 // file's header. Currently, the only input file format supported is PGM. 00291 // 00292 // Input: 00293 // filename - The name of the file from which the image is read. 00294 // triclopsImage16 - The 16-bit image that gets read. 00295 // imageInfo - Relevant information about the image that is read. 00296 // 00297 // Returns: 00298 // TriclopsErrorOk - The operation succeeded. 00299 // TriclopsErrorFileRead - Could not read in the specified file 00300 // (not found, or corrupted). 00301 // TriclopsErrorCorruptPGRComment - The PGR comment in the header was 00302 // corrupted. The imageInfo is invalid, but the file body ("the image") 00303 // was read in successfully. 00304 // 00305 // Description: 00306 // Reads a 16-bit image from a file named "filename" into a triclopsImage. 00307 // If the image was created using the triclopsSaveImage16Extra function, it should 00308 // contain information about the image, depending on the image type. This 00309 // information is parsed from the header and placed into the imageInfo 00310 // structure. If the image is a rectified, edge, or disparity image, the 00311 // appropriate parameter in the TriclopsImageInfo union will be filled in. 00312 // ** NOTE: Even if the function returns triclopsErrorOk, you still need to 00313 // check the TriclopsImageInfo "commentFound" boolean field, in case there 00314 // was no PGRComment associated with the input file. 00315 // 00316 // See Also: 00317 // triclopsReadImageExtra() 00318 // 00319 TriclopsError 00320 triclopsReadImage16Extra( char* filename, 00321 TriclopsImage16* triclopsImage16, 00322 TriclopsImageInfo* imageInfo); 00323 00324 00325 // 00326 // Name: triclopsSaveColorImage 00327 // 00328 // Synopsis: 00329 // Saves an image to the specified filename. The file format currently 00330 // supported is PGM format. 00331 // 00332 // Input: 00333 // image - The TriclopsColorImage to be saved. 00334 // filename - The file name in which to save the image. 00335 // 00336 // Returns: 00337 // SystemError - The file could not be opened 00338 // TriclopsErrorOk - The operation succeeded. 00339 // 00340 // Description: 00341 // This function saves the input image to the requested file. Currently, this 00342 // function will not detect if the file could not be opened, and will always 00343 // return successful. Color images are saved in PPM format. 00344 // 00345 // See Also: 00346 // triclopsSaveImage() 00347 // 00348 TriclopsError 00349 triclopsSaveColorImage( TriclopsColorImage* image, 00350 char* filename ); 00351 00352 // 00353 // Name: triclopsSavePackedColorImage 00354 // 00355 // Description: 00356 // Allows the user to save a packed color image to the given file. 00357 // 00358 // Input: 00359 // image - A pointer to the buffer containing the image. 00360 // filename - The name of the file to be written to. 00361 // 00362 // Returns: 00363 // SystemError - The file could not be opened 00364 // TriclopsErrorOk - Upon the successful completion of the operation. 00365 // 00366 TriclopsError 00367 triclopsSavePackedColorImage( TriclopsPackedColorImage* image, 00368 char* filename ); 00369 00370 00371 00372 00373 00374 #ifdef __cplusplus 00375 } 00376 #endif 00377 00378 #endif // #ifndef TRICLOPSIMAGEIO_H 00379