sal3d_def.h
00001 /*
00002  * 3D Shape Analysis Library.
00003  * Copyright 2008 AQSENSE, S.L.
00004  */
00005 #if !defined (AQSENSE_SAL3D_DEF_H)
00006 #define AQSENSE_SAL3D_DEF_H
00007 
00008 #if defined (_MSC_VER) && (_MSC_VER >= 1020)
00009 #pragma once
00010 #endif
00011 
00012 #include <stddef.h>
00013 
00014 #undef STDCALL
00015 #if defined(_WIN32)
00016     #define STDCALL __stdcall
00017 #else /* !_WIN32 */
00018     #define STDCALL
00019 #endif /* _WIN32 */
00020 
00021 #ifndef DECLSPEC
00022 #define DECLSPEC
00023 #endif
00024 
00025 #undef SAL3D_API
00026 #if defined(__cplusplus)
00027     #define SAL3D_API(type) extern "C" DECLSPEC type STDCALL
00028     #define DEFZERO = 0
00029 #else /* __cplusplus */
00030     #define SAL3D_API(type) type STDCALL
00031     #define DEFZERO
00032 #endif /* __cplusplus */
00033 
00034 #define SAL3D_API2(dllname, rettype, funname, parameters, call) \
00035         SAL3D_API(rettype) funname parameters;
00036 
00037 #define SAL3D_DECLARE_LOADERS(postfix) \
00038     SAL3D_API(void)   sal3d_dll_load_##postfix(); \
00039     SAL3D_API(void)   sal3d_dll_unload_##postfix();
00040 
00041 SAL3D_DECLARE_LOADERS(angularmetric)
00042 SAL3D_DECLARE_LOADERS(core3d)
00043 SAL3D_DECLARE_LOADERS(lenscalib)
00044 SAL3D_DECLARE_LOADERS(metric)
00045 SAL3D_DECLARE_LOADERS(merger)
00046 SAL3D_DECLARE_LOADERS(match3d)
00047 SAL3D_DECLARE_LOADERS(match3dcoarse)
00048 SAL3D_DECLARE_LOADERS(geometric)
00049 SAL3D_DECLARE_LOADERS(integrator)
00050 SAL3D_DECLARE_LOADERS(peakfinder)
00051 
00052 enum SAL3D_ERROR
00053 {
00054     /* No error. */
00055     SAL3D_ERROR_OK = 0,
00056 
00057     /* Unknown error. */
00058     SAL3D_ERROR_UNKNOWN = -1,
00059 
00060     /* Memory allocation. */
00061     SAL3D_ERROR_MEMORY = -2,
00062 
00063     /* The pointer passed to the function is not a frame. */
00064     SAL3D_ERROR_NOT_A_FRAME = -3,
00065 
00066     /* The passed plane is not valid. */
00067     SAL3D_ERROR_INVALID_PLANE = -4,
00068 
00069     /* The file is not found or an invalid format. */
00070     SAL3D_ERROR_INVALID_FILE = -5,
00071 
00072     /* The pointer passed to the function is not a peak finder. */
00073     SAL3D_ERROR_NOT_A_PEAK_FINDER = -6,
00074 
00075     /* The pointer passed to the function is not a frame grabber. */
00076     SAL3D_ERROR_NOT_A_FRAME_GRABBER = -7,
00077 
00078     /* The frame grabber has not beeing started to grab yet. */
00079     SAL3D_ERROR_FRAME_GRABBER_NOT_STARTED = -8,
00080 
00081     /* The frame grabber has been stoped while waiting for a frame. */
00082     SAL3D_ERROR_FRAME_GRABBER_STOPPED = -9,
00083 
00084     /* The area is invalid. */
00085     SAL3D_ERROR_INVALID_AREA = -10,
00086 
00087     /* The pointer passed to the function is not a profile. */
00088     SAL3D_ERROR_NOT_A_PROFILE = -11,
00089 
00090     /* The index passed to the function is not valid. */
00091     SAL3D_ERROR_INVALID_PROFILE_INDEX = -12,
00092 
00093     /* The pointer passed to the function is not a range map. */
00094     SAL3D_ERROR_NOT_A_RANGE_MAP = -13,
00095 
00096     /* The profile has an invalid length. */
00097     SAL3D_ERROR_INVALID_PROFILE_LENGTH = -14,
00098 
00099     /* The frame passed is invalid. */
00100     SAL3D_ERROR_INVALID_FRAME = -15,
00101 
00102     /* There was a timeout performing the operation. */
00103     SAL3D_ERROR_TIMEOUT = -16,
00104 
00105     /* The calibration algorithm couldn't work with the pattern's range map. */
00106     SAL3D_ERROR_INVALID_PATTERN_RANGE_MAP = -17,
00107 
00108     /* A frame grabber driver reported some error unknown to the SAL3D API. */
00109     SAL3D_ERROR_FRAME_GRABBER_UNKNOWN = -18,
00110 
00111     /* The pointer passed to the function is not a Match3D object. */
00112     SAL3D_ERROR_NOT_A_MATCH3D = -19,
00113 
00114     /* A problem occurred dealing with serialized data in strings */
00115     SAL3D_ERROR_SERIALIZATION = -20,
00116 
00117     SAL3D_ERROR_NOT_A_COP = -21,
00118 
00119     SAL3D_ERROR_NOT_A_METRIC_CONFIG = -22,
00120 
00121     /* The pointer passed to the function is not a disparity map. */
00122     SAL3D_ERROR_NOT_A_DISPARITY_MAP = -23,
00123 
00124     SAL3D_ERROR_NOT_A_ZMAP = -24,
00125 
00126     SAL3D_ERROR_DIFFERENT_ZMAP_FACTORS = -25,
00127 
00128     SAL3D_ERROR_NOT_A_MERGER_CONFIG = -26,
00129 
00130     /* Could not find a valid license */
00131     SAL3D_ERROR_LICENSE_NOT_FOUND = -27,
00132 
00133     SAL3D_ERROR_INVALID_PATTERN_CROP_AREA = -28,
00134 
00135     SAL3D_ERROR_DETECTING_PATTERN_IN_RANGE_MAP = -29,
00136 
00137     SAL3D_ERROR_NOISY_PATTERN_RANGE_MAP = -30,
00138 
00139     SAL3D_ERROR_NOT_A_THREADPOOL = -31,
00140 
00141     SAL3D_ERROR_NOT_A_HOTPIXEL_CALIBRATION = -32,
00142 
00143     SAL3D_ERROR_INVALID_PATTERN_POINTS = -33,
00144 
00145     SAL3D_ERROR_PROFILES_LIMIT = -34,
00146 
00147     SAL3D_ERROR_BAD_ARGUMENT = -35,
00148 
00149     SAL3D_ERROR_NOT_AN_INTEGRATOR = -36,
00150 
00151     SAL3D_ERROR_NOT_A_MESH = -37,
00152 
00153     SAL3D_ERROR_INVALID_TYPE = -38,
00154 
00155     SAL3D_ERROR_NOT_SUPPORTED = -39,
00156 
00157     SAL3D_ERROR_NO_CAMERAS_FOUND = -40,
00158 
00159     SAL3D_ERROR_NOT_ENOUGH_VALID_POINTS = -41,
00160 
00161     SAL3D_ERROR_NOT_A_POLYGON_2D = -42,
00162 
00163     SAL3D_ERROR_ANGLE_ZERO_NOT_IN_RANGE = -43,
00164 
00165     SAL3D_ERROR_NOT_AN_ANGULAR_METRIC_CONFIG = -44,
00166 
00167     SAL3D_ERROR_INVALID_ZMAP_FACTORS = -45,
00168 
00169     SAL3D_ERROR_CANNOT_LOAD_DL = -46,
00170 };
00171 
00172 struct sal3d_error
00173 {
00174     int value; /* usually, values of enum SAL3D_ERROR, but users can set any
00175                   number */
00176     char text[512];
00177 };
00178 
00179 /* The diferent data types "modifiers" */
00180 #define SAL3D_FLOAT_DATA_TYPE(value) (value + 256 + 512)
00181 #define SAL3D_SIGNED_DATA_TYPE(value) (value + 256)
00182 
00183 /* Some boolean macros to check types. */
00184 #define SAL3D_DATA_TYPE_BPP(value) (value & 255)
00185 #define SAL3D_DATA_TYPE_IS_SIGNED(value) (value & 256)
00186 #define SAL3D_DATA_TYPE_IS_FLOAT(value) (value & 512)
00187 
00188 /* Type definitions */
00189 
00190 typedef struct sal3d_point2d
00191 {
00192     /* array x, y */
00193     float p[2];
00194 } sal3d_point2d;
00195 
00196 typedef struct sal3d_point3d
00197 {
00198     /* array x, y, z */
00199     float p[3];
00200 } sal3d_point3d;
00201 
00207 typedef struct sal3d_pattern_sp_points
00208 {
00209     float p[4][2];
00210     float height;
00211 } sal3d_pattern_sp_points;
00212 
00213 typedef struct sal3d_pattern_stp_points
00214 {
00215     float p[4][2];
00216 } sal3d_pattern_stp_points;
00217 
00218 /* Polygon2D public declaration. */
00219 typedef struct sal3d_polygon2d
00220 {
00221     void *p;
00222 } sal3d_polygon2d;
00223 
00224 /*  Polygon2D functions  */
00225 SAL3D_API(int)
00226 sal3d_polygon2d_new (sal3d_polygon2d *polygon, sal3d_error *e DEFZERO);
00227 
00228 SAL3D_API(int)
00229 sal3d_polygon2d_new_from_points (const sal3d_point2d *points, int n_points,
00230         sal3d_polygon2d *polygon, sal3d_error *e DEFZERO);
00231 
00232 SAL3D_API(int)
00233 sal3d_polygon2d_check_validity (const sal3d_polygon2d polygon, sal3d_error *e
00234         DEFZERO);
00235 
00236 SAL3D_API(int)
00237 sal3d_polygon2d_copy (const sal3d_polygon2d polygon, sal3d_polygon2d *copy,
00238         sal3d_error *e DEFZERO);
00239 
00240 SAL3D_API(int)
00241 sal3d_polygon2d_release (sal3d_polygon2d polygon);
00242 
00243 SAL3D_API(int)
00244 sal3d_polygon2d_num_points (const sal3d_polygon2d polygon, int *num_points,
00245         sal3d_error *e DEFZERO);
00246 
00247 SAL3D_API(int)
00248 sal3d_polygon2d_append_point (const sal3d_polygon2d polygon, const
00249         sal3d_point2d point2d, sal3d_error *e DEFZERO);
00250 
00251 SAL3D_API(int)
00252 sal3d_polygon2d_insert_point (const sal3d_polygon2d polygon, const
00253         sal3d_point2d point2d, int pos, sal3d_error *e DEFZERO);
00254 
00255 SAL3D_API(int)
00256 sal3d_polygon2d_remove_point_back (const sal3d_polygon2d polygon,
00257         sal3d_point2d *point2d, sal3d_error *e DEFZERO);
00258 
00259 SAL3D_API(int)
00260 sal3d_polygon2d_remove_point_pos (const sal3d_polygon2d polygon, int pos,
00261         sal3d_point2d *point2d, sal3d_error *e DEFZERO);
00262 
00263 SAL3D_API(int)
00264 sal3d_polygon2d_remove_points (const sal3d_polygon2d polygon, sal3d_error *e
00265         DEFZERO);
00266 
00267 SAL3D_API(int)
00268 sal3d_polygon2d_set_points (const sal3d_polygon2d polygon,
00269         const sal3d_point2d *points2d, int n_points, sal3d_error *e DEFZERO);
00270 
00271 SAL3D_API(int)
00272 sal3d_polygon2d_get_points (const sal3d_polygon2d polygon,
00273         sal3d_point2d *points2d, sal3d_error *e DEFZERO);
00274 
00275 SAL3D_API(int)
00276 sal3d_polygon2d_get_point (const sal3d_polygon2d polygon, int pos,
00277         sal3d_point2d *point2d, sal3d_error *e DEFZERO);
00278 
00279 SAL3D_API(int)
00280 sal3d_polygon2d_point_inside (const sal3d_point2d point, const sal3d_polygon2d
00281         polygon, int *inside, sal3d_error *e DEFZERO);
00282 
00283 #endif /* AQSENSE_SAL3D_DEF_H */