Dokumentation
libMPTStereo.h
00001 #ifndef LIBMPTSTEREO_H
00002 #define LIBMPTSTEREO_H
00003 
00004 # ifdef LIBMPTSTEREO_EXPORT
00005 #   ifdef __cplusplus
00006 #     define MPT_API  extern "C" __declspec(dllexport)
00007 #   else
00008 #     define MPT_API  __declspec(dllexport)
00009 #   endif
00010 # else
00011 #   ifdef __cplusplus
00012 #     define MPT_API  extern "C" __declspec(dllimport)
00013 #   else
00014 #     define MPT_API  __declspec(dllimport)
00015 #   endif
00016 # endif
00017 
00018 #define MPT_NO_ERROR 0
00019 #define MPT_ERR_IMAGE_DIM_MISMATCH 100
00020 #define MPT_ERR_IMAGE_TYPE_MISMATCH 101
00021 #define MPT_ERR_IMAGE_GRAY_EXPECTED 102
00022 #define MPT_ERR_IMAGE_INVALID 103
00023 
00024 #define MPT_ERR_MEMORY_TO_SMALL 200
00025 
00026 #define MPT_ERR_IO 300
00027 #define MPT_ERR_FILE_OPEN 301
00028 #define MPT_ERR_FILE_FORMAT 302
00029 
00030 #define MPT_ERR_CORRELATION 400
00031 
00032 #define MPT_ERR_POSITION 500
00033 
00034 #define MPT_ERR_ALG_INTERNAL_PLUGINS 600
00035 #define MPT_ERR_ALG_INTERNAL_CREATE 601
00036 #define MPT_ERR_ALG_INTERNAL_CALC 602
00037 
00038 #define MPT_ERR_CALIBRATION_INVALID 700
00039 #define MPT_ERR_CALIBRATION_IMAGE_DIM_MISMATCH 701
00040 
00041 #define MPT_MAX_CAMERA_ID_LENGTH 64
00042 
00043 
00044 enum MPTenImageType { mptImgInvalid, mptImgGray, mptImgBGR,};
00045 enum MPTenCoorType {mptCorrCross, mptCorrCrossZeroMean, mptCorrMoravec, mptCorrPearson,};
00046 
00047 typedef struct MPTPoint2i
00048 {
00049   int x;
00050   int y;
00051 } MPTPoint2i;
00052 
00053 typedef struct MPTPoint2d
00054 {
00055   double x;
00056   double y;
00057 } MPTPoint2d;
00058 
00059 typedef struct MPTPoint3d
00060 {
00061   double x;
00062   double y;
00063   double z;
00064 } MPTPoint3d;
00065 
00066 typedef struct MPTImage
00067 {
00068   int     width;
00069   int     height;
00070   int     bpsl;
00071   enum MPTenImageType type;
00072   unsigned char* data;
00073 } MPTImage;
00074 
00075 typedef struct MPTMatrix3x3
00076 {
00077   double m[9];
00078 } MPTMatrix3x3;
00079 
00080 typedef struct MPTMatrix4x4
00081 {
00082   double m[16];
00083 } MPTMatrix4x4;
00084 
00085 typedef struct MPTCamera
00086 {  
00087   char id[MPT_MAX_CAMERA_ID_LENGTH];
00088   int res_width;
00089   int res_height;
00090   double f;
00091   double px_size_x;
00092   double px_size_y;
00093 
00094   struct MPTMatrix3x3  intrinsic;
00095   struct MPTMatrix4x4  transform;
00096 
00097   double dist_coeffs[12];
00098 } MPTCamera;
00099 
00100 typedef void* MPTRectifier ;
00101 
00102 MPT_API const char* getErrorText(int errCode);
00103 
00104 MPT_API MPTImage* createImage(enum MPTenImageType type, int width, int height);
00105 MPT_API void releaseImage(MPTImage** img);
00106 MPT_API MPTImage* readImage(const char* fileName);
00107 MPT_API int writeImage(const char* fileName, const MPTImage* img, int comprLevel);
00108 
00109 MPT_API int readCalibration(const char* fileName, MPTCamera* cam);
00110 MPT_API int writeCalibration(const char* fileName, const MPTCamera* cam);
00111 MPT_API int calcIntrinsicCalibration(const char** fileNames, int fileCount, int markerSizeMin, int markerSizeMax, MPTCamera* cam);
00112 MPT_API int calcStereoCalibration(const char** fileNames, int fileCount, int markerSizeMin, int markerSizeMax, const MPTCamera* camLeft, MPTCamera* camRight);
00113 
00114 MPT_API int calcRectification(const MPTCamera* camLeft, const MPTCamera* camRight, MPTMatrix3x3* rectMatrixLeft, MPTMatrix3x3* rectMatrixRight);
00115 
00116 MPT_API MPTRectifier createRectifier(const MPTCamera* camLeft, const MPTCamera* camRight);
00117 MPT_API int deleteRectifier(MPTRectifier handle);
00118 MPT_API int setCalibrations(MPTRectifier handle, const MPTCamera* camLeft, const MPTCamera* camRight);
00119 MPT_API int undistRectifyLeftImage(MPTRectifier handle, const MPTImage* imgDeRectDist, MPTImage* imgUndistRect);
00120 MPT_API int undistRectifyRightImage(MPTRectifier handle, const MPTImage* imgDeRectDist, MPTImage* imgUndistRect);
00121 MPT_API int resectForwardRectifier(MPTRectifier handle, const MPTPoint2i* pointsLeft,
00122                                    const MPTPoint2d* pointsRight, MPTPoint3d* pointsWorld, double* err, int pointCount);
00123 
00124 MPT_API int undistortCoords(const MPTCamera* cam, const MPTPoint2d* pointsDist, MPTPoint2d* pointsUndist, int pointCount);
00125 MPT_API int undistortPixels(const MPTCamera* cam, const MPTPoint2d* pixelsDist, MPTPoint2d* pixelsUndist, int pixelCount);
00126 MPT_API int undistortImage(const MPTCamera* cam, const MPTImage* imgDist, MPTImage* imgUndist);
00127 MPT_API int distortCoords(const MPTCamera* cam, const MPTPoint2d* pointsUndist, MPTPoint2d* pointsDist, int pointCount);
00128 MPT_API int distortPixels(const MPTCamera* cam, const MPTPoint2d* pixelsUndist, MPTPoint2d* pixelsDist, int pixelCount);
00129 MPT_API int distortImage(const MPTCamera* cam, const MPTImage* imgUndist, MPTImage* imgDist);
00130 
00131 MPT_API int rectifyCoords(const MPTMatrix3x3* rect, const MPTCamera* cam, const MPTPoint2d* pointsDeRect, MPTPoint2d* pointsRect, int pointCount);
00132 MPT_API int rectifyPixels(const MPTMatrix3x3* rect, const MPTPoint2d* pixelsDeRect, MPTPoint2d* pixelsRect, int pixelCount);
00133 MPT_API int rectifyImage(const MPTMatrix3x3* rect, const MPTImage* imgDeRect, MPTImage* imgRect);
00134 MPT_API int deRectifyCoords(const MPTMatrix3x3* rect, const MPTCamera* cam, const MPTPoint2d* pointsRect, MPTPoint2d* pointsDerect, int pointCount);
00135 MPT_API int deRectifyPixels(const MPTMatrix3x3* rect, const MPTPoint2d* pixelsRect, MPTPoint2d* pixelsDeRect, int pixelCount);
00136 MPT_API int deRectifyImage(const MPTMatrix3x3* rect, const MPTImage* imgRect, MPTImage* imgDeRect);
00137 
00138 MPT_API int undistRectifyCoords(const MPTCamera* cam, const MPTMatrix3x3* rect, const MPTPoint2d* pixelsDeRectDist, MPTPoint2d* pixelsUndistRect, int pointCount);
00139 MPT_API int undistRectifyPixels(const MPTCamera* cam, const MPTMatrix3x3* rect, const MPTPoint2d* pixelsDeRectDist, MPTPoint2d* pixelsUndistRect, int pixelCount);
00140 MPT_API int undistRectifyImage(const MPTCamera* cam, const MPTMatrix3x3* rect, const MPTImage* imgDeRectDist, MPTImage* imgUndistRect);
00141 MPT_API int deRectifyDistCoords(const MPTCamera* cam, const MPTMatrix3x3* rect, const MPTPoint2d* pixelsUndistRect, MPTPoint2d* pixelsDeRectDist, int pointCount);
00142 MPT_API int deRectifyDistPixels(const MPTCamera* cam, const MPTMatrix3x3* rect, const MPTPoint2d* pixelsUndistRect, MPTPoint2d* pixelsDeRectDist, int pixelCount);
00143 MPT_API int deRectifyDistImage(const MPTCamera* cam, const MPTMatrix3x3* rect, const MPTImage* imgUndistRect, MPTImage* imgDeRectDist);
00144 
00145 MPT_API int searchStereoFeaturesEdges(const MPTImage* img, MPTPoint2i* featurePoints, int* pointCount);
00146 MPT_API int calculateOffset(const MPTImage* img, const MPTImage* imgRef, int* offset);
00147 
00148 MPT_API int calcEpiLine(MPTPoint2i point, int imageWidth, int offset, int length, int step, int windowSize, MPTPoint2i* epiPoints, int* pointCount);
00149 MPT_API int correlate(const MPTImage* img, const MPTImage* imgRef, MPTPoint2d point, const MPTPoint2i* epiPoints, int pointCount, int windowSize,
00150                       enum MPTenCoorType corr, double* corrValues);
00151 
00152 MPT_API int calculateMaximum(const double* corrValues, int pointCount, int smooth, double thresh, double* maxIndex);
00153 MPT_API int calculatePosition(const MPTPoint2i* epiPoints, int pointCount, double maxIndex, MPTPoint2d* point);
00154 
00155 MPT_API int calculateMatching(const MPTImage* img, const MPTImage* imgRef, MPTPoint2i point, const MPTPoint2i* epiPoints, int pointCount, 
00156                               int windowSize, int smooth, double thresh, enum MPTenCoorType corr, MPTPoint2d* match);
00157 
00158 MPT_API int filterPoints(const MPTPoint2i* points, const MPTPoint2d* pointsRef, int* pointCount, MPTPoint2i* filteredPoints, MPTPoint2d* filteredRefPoints);
00159 
00160 MPT_API int resectForward(const MPTCamera* camLeft, const MPTCamera* camRight,
00161                           const MPTPoint2d* pointsLeft, const MPTPoint2d* pointsRight,
00162                           MPTPoint3d* pointsWorld, double* err, int pointCount);
00163 MPT_API int resectForwardRect(const MPTCamera* camLeft, const MPTCamera* camRight,
00164                               const MPTMatrix3x3* rectLeft, const MPTMatrix3x3* rectRight,
00165                               const MPTPoint2d* pointsLeft,  const MPTPoint2d* pointsRight, 
00166                               MPTPoint3d* pointsWorld, double* err, int pointCount);
00167 
00168 #endif // LIBMPTSTEREO_H


Copyright © 2012 Fraunhofer IFF
Version 1.0