pnmutils.h
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
32 //=============================================================================
33 // Copyright © 2000 Point Grey Research, Inc. All Rights Reserved.
34 //
35 // This software is the confidential and proprietary information of Point
36 // Grey Research, Inc. ("Confidential Information"). You shall not
37 // disclose such Confidential Information and shall use it only in
38 // accordance with the terms of the license agreement you entered into
39 // with PGR.
40 //
41 // PGR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
42 // SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
43 // IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
44 // PURPOSE, OR NON-INFRINGEMENT. PGR SHALL NOT BE LIABLE FOR ANY DAMAGES
45 // SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
46 // THIS SOFTWARE OR ITS DERIVATIVES.
47 //=============================================================================
48 //=============================================================================
49 // $Id: pnmutils.h,v 1.14 2008/03/06 23:04:06 donm Exp $
50 //=============================================================================
51 #ifndef _PNMUTILS_H_
52 #define _PNMUTILS_H_
53 
54 
55 //=============================================================================
56 //
57 // pnmutils:
58 //
59 // This file provides functions for reading and writing a PGM and PPM
60 // files from and to a TriclopsImage.
61 // Users are encouraged to modify this source to suit their own needs.
62 //=============================================================================
63 
64 
65 //=============================================================================
66 // System Includes
67 //=============================================================================
68 #include <stdio.h>
69 #include <stdlib.h>
70 #include <string.h>
71 
72 
73 //=============================================================================
74 // PGR Includes
75 //=============================================================================
76 #include "triclops.h"
77 
78 
79 #ifdef __cplusplus
80 extern "C"
81 {
82 #endif
83 
84 
85 //=============================================================================
86 // pgmReadToTriclopsImage()
87 //
88 // This function reads an 8-bit pgm file into a TriclopsImage
89 // structure. It allocates the data within the TriclopsImage to contain
90 // the image data. This data must be freed after it is used by calling
91 // 'freeImage()'
92 //
93 // return codes:
94 // True - the file was successfully read and memory allocated
95 // False - the file read failed (no memory was allocated)
96 //
98 pgmReadToTriclopsImage( const char* filename,
99  TriclopsImage* image );
100 
101 //=============================================================================
102 // pgmReadToTriclopsImage16()
103 //
104 // This function reads an 16-bit pgm file into a TriclopsImage16
105 // structure. It allocates the data within the TriclopsImage16 to
106 // contain the image data. This data must be freed after it is used
107 // by calling 'freeImage16()'
108 //
109 // return codes:
110 // True - the file was successfully read and memory allocated
111 // False - the file read failed (no memory was allocated)
112 //
114 pgmReadToTriclopsImage16( const char* filename,
115  TriclopsImage16* image );
116 
117 
118 //=============================================================================
119 //
120 //
121 //
122 //
124 pgmRead3ToTriclopsInput( const char* redFileName,
125  const char* bluFileName,
126  const char* greFileName,
127  TriclopsInput* pInput );
128 
129 //=============================================================================
130 // pgmReadToTriclopsInput()
131 //
132 // This function reads a pgm file into a TriclopsInput
133 // structure (of type TriInp_RGB).
134 // It allocates the data within the TriclopsInput to
135 // contain the image data. This data must be freed after it is used
136 // by calling 'freeInput()'
137 //
138 // This data is suitable to be be input into the Triclops stereo
139 // library with a call to 'triclopsPreprocess()'
140 //
141 // NOTE: this uses a greyscale image and expects that the red/green
142 // or red/green/blue channels be side by side or "row-interleaved".
143 //
144 // return codes:
145 // True - the file was successfully read and memory allocated
146 // False - the file read failed (no memory was allocated)
147 //
149 pgmReadToTriclopsInput( const char* filename,
150  TriclopsInput* input );
151 
152 
153 //=============================================================================
154 // pgmReadToTriclopsInput()
155 //
156 // This function reads a pgm file into a TriclopsInput
157 // structure (of type TriInp_RGB).
158 // It allocates the data within the TriclopsInput to
159 // contain the image data. This data must be freed after it is used
160 // by calling 'freeInput()'
161 //
162 // This data is suitable to be be input into the Triclops stereo
163 // library with a call to 'triclopsPreprocess()'
164 //
165 // NOTE: this uses a greyscale image and expects that the red/green
166 // or red/green/blue channels be side by side or "row-interleaved".
167 //
168 // return codes:
169 // True - the file was successfully read and memory allocated
170 // False - the file read failed (no memory was allocated)
171 //
173 pgmReadToTriclopsInput( const char* filename,
174  TriclopsInput* input );
175 
176 
177 //=============================================================================
178 // ppmReadToTriclopsInput()
179 //
180 // This function reads a ppm file into a TriclopsInput
181 // structure (of type TriInp_RGB_32BITPACKED).
182 // It allocates the data within the TriclopsInput to
183 // contain the image data. This data must be freed after it is used
184 // by calling 'freeInput()'
185 //
186 // This data is suitable to be be input into the Triclops stereo
187 // library with a call to 'triclopsPreprocess()'
188 //
189 // return codes:
190 // True - the file was successfully read and memory allocated
191 // False - the file read failed (no memory was allocated)
192 //
194 ppmReadToTriclopsInput( const char* filename,
195  TriclopsInput* input );
196 
197 
198 //=============================================================================
199 // ppmReadToTriclopsInputRGB()
200 //
201 // This function reads a ppm file into a TriclopsInput
202 // structure (of type TriInp_RGB).
203 // It allocates the data within the TriclopsInput to
204 // contain the image data. This data must be freed after it is used
205 // by calling 'freeInput()'
206 //
207 // This data is suitable to be be input into the Triclops stereo
208 // library with a call to 'triclopsPreprocess()'
209 //
210 // return codes:
211 // True - the file was successfully read and memory allocated
212 // False - the file read failed (no memory was allocated)
213 //
215 ppmReadToTriclopsInputRGB( const char* filename,
216  TriclopsInput* input );
217 
218 
219 //=============================================================================
220 // freeInput()
221 //
222 // This function frees the image memory associated with a TriclopsInput.
223 // This needs to be called after the user is finished with a
224 // TriclopsInput structure that was created from a called to
225 // 'ppmReadToTriclopsInput()'
226 //
227 // return codes:
228 // True - the memory was freed
229 //
231 freeInput( TriclopsInput* input );
232 
233 
234 //=============================================================================
235 // freeImage()
236 //
237 // This function frees the image memory associated with a TriclopsImage.
238 // This needs to be called after the user is finished with a
239 // TriclopsImage structure that was created from a called to
240 // 'pgmReadToTriclopsImage()'
241 //
242 // return codes:
243 // True - the memory was freed
244 //
246 freeImage( TriclopsImage* pimage );
247 
248 
249 //=============================================================================
250 // freeImage16()
251 //
252 // This function frees the image memory associated with a
253 // TriclopsImage16.
254 // This needs to be called after the user is finished with a
255 // TriclopsImage structure that was created from a called to
256 // 'pgmReadToTriclopsImage16()'
257 //
258 // return codes:
259 // True - the memory was freed
260 //
262 freeImage16( TriclopsImage16* pimage );
263 
264 
265 //=============================================================================
266 // pgmWriteFromTriclopsImage()
267 //
268 // This function writes an 8-bit pgm file from a TriclopsImage
269 // structure.
270 //
271 // return codes:
272 // True - the file was successfully written
273 // False - 'filename' could not be opened for writing
274 //
276 pgmWriteFromTriclopsImage( const char* filename,
277  TriclopsImage* image );
278 
279 
280 //=============================================================================
281 // ppmWriteFromTriclopsColorImage()
282 //
283 // This function writes an 24-bit ppm file from a TriclopsColorImage
284 // structure.
285 //
286 // return codes:
287 // True - the file was successfully written
288 // False - 'filename' could not be opened for writing
289 //
291 ppmWriteFromTriclopsColorImage( const char* filename,
292  TriclopsColorImage* image );
293 
294 
295 //=============================================================================
296 // pgmWrite3FromTriclopsInput()
297 //
298 // This function writes 3 8-bit pgm files from a TriclopsInput structure.
299 // These correspond to the appropriate channels of the image.
300 //
301 // return codes:
302 // True - the file was successfully written
303 // False - 'filename' could not be opened for writing
304 //
306 pgmWrite3FromTriclopsInput( const char* redFilename,
307  const char* greFilename,
308  const char* bluFilename,
309  TriclopsInput* input );
310 
311 
312 //=============================================================================
313 // pgmWrite3FromTriclopsInputWithComment()
314 //
315 // This function writes 3 8-bit pgm files from a TriclopsInput structure.
316 // These correspond to the appropriate channels of the image. The comment
317 // will be stored in each file (pass in NULL if no comment is desired).
318 //
319 // return codes:
320 // True - the file was successfully written
321 // False - 'filename' could not be opened for writing
322 //
324 pgmWrite3FromTriclopsInputWithComment( const char* redFilename,
325  const char* greFilename,
326  const char* bluFilename,
327  const char* comment,
328  TriclopsInput* input );
329 
330 
331 //=============================================================================
332 // pgmWriteFromTriclopsImage16()
333 //
334 // This function writes an 16-bit pgm file from a TriclopsImage
335 // structure.
336 //
337 // return codes:
338 // True - the file was successfully written
339 // False - 'filename' could not be opened for writing
340 //
342 pgmWriteFromTriclopsImage16( const char* filename,
343  TriclopsImage16* image );
344 
345 
346 //=============================================================================
347 // ppmWriteFromTriclopsInput()
348 //
349 // This function writes an 24-bit ppm file from a TriclopsInput
350 // structure.
351 //
352 // return codes:
353 // True - the file was successfully written
354 // False - 'filename' could not be opened for writing
355 // - or the TriclopsInput was not in a supported format
356 //
358 ppmWriteFromTriclopsInput( const char* filename,
359  TriclopsInput* input );
360 
361 
362 //=============================================================================
363 //
364 //
365 //
366 //
368 ppmWriteFromTriclopsInputWithComment( const char* filename,
369  const char* comment,
370  TriclopsInput* input );
371 
372 //=============================================================================
373 // pgmWriteFromTriclopsInput()
374 //
375 // This function writes an 24-bit ppm file from a TriclopsInput
376 // structure.
377 //
378 // nCameras - if it is known that the Input has only 2 cameras,
379 // this can be changed to a value of 2. Otherwise it should
380 // be 3
381 //
382 // return codes:
383 // True - the file was successfully written
384 // False - 'filename' could not be opened for writing
385 // - or the TriclopsInput was not in a supported format
386 //
388 pgmWriteFromTriclopsInput( const char* filename,
389  TriclopsInput* input,
390  int nCameras );
391 
392 
393 //=============================================================================
394 //
395 //
396 //
397 //
399 pgmWriteFromTriclopsInputWithComment( const char* filename,
400  const char* comment,
401  TriclopsInput* input,
402  int nCameras = 3 );
403 
404 
405 
406 //=============================================================================
407 // pgmWriteFromTriclopsInput()
408 //
409 // This function writes an 8-bit pgm file from a TriclopsInput
410 // structure.
411 //
412 // nCameras - if it is known that the Input has only 2 cameras,
413 // this can be changed to a value of 2. Otherwise it should
414 // be 3.
415 //
416 // return codes:
417 // True - the file was successfully written
418 // False - 'filename' could not be opened for writing
419 // - or the TriclopsInput was not in a supported format
420 //
422 pgmWriteFromTriclopsInput( const char* filename,
423  TriclopsInput* input,
424  int nCameras );
425 
426 
427 //=============================================================================
428 // pgmWriteFromTriclopsInputWithComment()
429 //
430 // This function writes an 8-bit pgm file from a TriclopsInput
431 // structure. The comment may be NULL.
432 //
433 // nCameras - if it is known that the Input has only 2 cameras,
434 // this can be changed to a value of 2. Otherwise it should
435 // be 3.
436 //
437 // return codes:
438 // True - the file was successfully written
439 // False - 'filename' could not be opened for writing
440 // - or the TriclopsInput was not in a supported format
441 //
443 pgmWriteFromTriclopsInputWithComment( const char* filename,
444  const char* comment,
445  TriclopsInput* input,
446  int nCameras );
447 
448 
449 #ifdef __cplusplus
450 }
451 #endif
452 
453 
454 #endif //#ifndef _PNMUTILS_H_
TriclopsBool ppmReadToTriclopsInputRGB(const char *filename, TriclopsInput *input)
int TriclopsBool
Definition: triclops.h:262
TriclopsBool pgmWriteFromTriclopsImage16(const char *filename, TriclopsImage16 *image)
TriclopsBool pgmWriteFromTriclopsInput(const char *filename, TriclopsInput *input, int nCameras)
TriclopsBool ppmWriteFromTriclopsInputWithComment(const char *filename, const char *comment, TriclopsInput *input)
TriclopsBool ppmWriteFromTriclopsInput(const char *filename, TriclopsInput *input)
TriclopsBool freeInput(TriclopsInput *input)
TriclopsBool pgmReadToTriclopsInput(const char *filename, TriclopsInput *input)
TriclopsBool pgmWrite3FromTriclopsInput(const char *redFilename, const char *greFilename, const char *bluFilename, TriclopsInput *input)
TriclopsBool freeImage(TriclopsImage *pimage)
This is from point grey. Check the manual for instructions.
TriclopsBool pgmWrite3FromTriclopsInputWithComment(const char *redFilename, const char *greFilename, const char *bluFilename, const char *comment, TriclopsInput *input)
TriclopsBool pgmReadToTriclopsImage(const char *filename, TriclopsImage *image)
TriclopsBool freeImage16(TriclopsImage16 *pimage)
TriclopsBool ppmWriteFromTriclopsColorImage(const char *filename, TriclopsColorImage *image)
TriclopsBool pgmWriteFromTriclopsImage(const char *filename, TriclopsImage *image)
TriclopsBool pgmReadToTriclopsImage16(const char *filename, TriclopsImage16 *image)
TriclopsBool ppmReadToTriclopsInput(const char *filename, TriclopsInput *input)
TriclopsBool pgmWriteFromTriclopsInputWithComment(const char *filename, const char *comment, TriclopsInput *input, int nCameras=3)
TriclopsBool pgmRead3ToTriclopsInput(const char *redFileName, const char *bluFileName, const char *greFileName, TriclopsInput *pInput)


xb3
Author(s): Miguel Oliveira, Tiago Talhada
autogenerated on Mon Mar 2 2015 01:33:02