~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina5/tina-libs/tina/file/fileCam_util.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-libs/tina/file/fileCam_util.c,v $
 37  * Date    :  $Date: 2009/02/25 16:22:38 $
 38  * Version :  $Revision: 1.6 $
 39  * CVS Id  :  $Id: fileCam_util.c,v 1.6 2009/02/25 16:22:38 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes : tool_util.c tv_screen utilities
 44  *
 45  *********
 46 */
 47 
 48 #include "fileCam_util.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #include <config.h>
 52 #endif
 53 
 54 #include <stdio.h>
 55 #include <stdlib.h>
 56 #include <string.h>
 57 
 58 /* ipoole */
 59 #if HAVE_SYS_PARAM_H
 60 #include <sys/param.h>
 61 #else
 62 #define MAXPATHLEN 255
 63 #endif
 64 
 65 #include <tina/sys/sysDef.h>
 66 #include <tina/sys/sysPro.h>
 67 #include <tina/file/file_UtilPro.h>    /* ipoole */
 68 #include <tina/file/file_CamDef.h>
 69 #include <tina/file/fileCam_io.h>
 70 #include <tina/file/fileCam_distort_r.h>
 71 
 72 #define CAMERA_PATHNAME "/tina/images/calib/default"
 73 
 74 
 75 /* Get a camera filename. Use heirarchy of 4 alternatives: 1. given
 76  * pathname eg /douglas/tnew/images/house/house 2. default.cam file in
 77  * same directory as pathname 3. environmental variable 4. #define Add
 78  * the given extension & test if the resulting pathname is readable. */
 79 char   *camera_filename_get(char *camera_path, char *pathname, char *extn)
 80 {
 81     char    dir[MAXPATHLEN];
 82     char   *env_pathname=NULL;
 83 
 84     /* Test for camera file with given pathname (add extn & .cam) */
 85     if (string_append(camera_path, pathname, extn, ".cam", NULL) &&
 86         file_readable(camera_path));
 87 
 88     /* Test for default camera file in same directory as image,eg
 89      * default.l.cam */
 90     else if (dirname(dir, pathname) &&
 91              string_append(camera_path, dir, "/default", extn, ".cam", NULL) &&
 92              file_readable(camera_path))
 93         format("Loading directory default camera file: %s\n", camera_path);
 94 
 95     /* Test for camera file in environmental variable */
 96     else if ((env_pathname = getenv("TINA_CAMERA_DEFAULT")) &&
 97         string_append(camera_path, env_pathname, extn, ".cam", NULL) &&
 98              file_readable(camera_path))
 99         format("Loading environmental variable default camera file: %s\n",
100                camera_path);
101 
102     /* Test for camera file #define'd */
103     else if (string_append(camera_path, CAMERA_PATHNAME, extn, ".cam", NULL) &&
104              file_readable(camera_path))
105         format("Loading #define'd default camera file: %s\n", camera_path);
106 
107     /* No camera found */
108     else
109     {
110         camera_path = NULL;
111         error("Can't find camera file", warning);
112     }
113     return camera_path;
114 }
115 
116 /* Load a camera. Use camera_filename_get to find file. */
117 Camera *input_camera_file(char *pathname, char *extn)
118 {
119     Camera *camera = NULL;
120     char    camera_path[MAXPATHLEN];
121 
122     if (camera_filename_get(camera_path, pathname, extn))
123         camera = cam_read(camera_path, rdist_read_fp);
124 
125     return camera;
126 }
127 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.