00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef mrpt_vision_utils_H
00030 #define mrpt_vision_utils_H
00031
00032 #include <mrpt/vision/CFeature.h>
00033 #include <mrpt/utils/CMRPTImage.h>
00034 #include <mrpt/math/utils.h>
00035 #include <mrpt/utils/CLoadableOptions.h>
00036 #include <mrpt/slam/CMetricMap.h>
00037
00038 namespace mrpt
00039 {
00040 namespace slam
00041 {
00042 class CLandmarksMap;
00043 class CObservationVisualLandmarks;
00044 }
00045 namespace poses
00046 {
00047 class CPoint3D;
00048 }
00049
00052 namespace vision
00053 {
00054 using namespace mrpt::math;
00055
00056
00057
00058
00061 typedef uint64_t TLandmarkID;
00062
00065 struct MRPTDLLIMPEXP TStereoSystemParams : public mrpt::utils::CLoadableOptions
00066 {
00069 TStereoSystemParams( );
00070
00073 void loadFromConfigFile(
00074 const mrpt::utils::CConfigFileBase &source,
00075 const std::string §ion);
00076
00079 void dumpToTextStream(utils::CStream &out);
00080
00083 enum TUnc_Prop_Method
00084 {
00087 Prop_Linear = -1,
00090 Prop_UT,
00093 Prop_SUT
00094 };
00095
00096 TUnc_Prop_Method uncPropagation;
00097
00100 CMatrix K;
00103 float baseline;
00106 float stdPixel;
00109 float stdDisp;
00112 float maxZ;
00115 float minZ;
00118 float maxY;
00121 float factor_k;
00124 float factor_a;
00127 float factor_b;
00128
00131
00132
00133 };
00134
00137 struct MRPTDLLIMPEXP TROI
00138 {
00139
00140 TROI();
00141 TROI(float x1, float x2, float y1, float y2, float z1, float z2);
00142
00143
00144 float xMin;
00145 float xMax;
00146 float yMin;
00147 float yMax;
00148 float zMin;
00149 float zMax;
00150 };
00151
00154 struct MRPTDLLIMPEXP TImageROI
00155 {
00156
00157 TImageROI();
00158 TImageROI( float x1, float x2, float y1, float y2 );
00159
00160
00163 float xMin, xMax;
00166 float yMin, yMax;
00167 };
00168
00171 struct MRPTDLLIMPEXP TMatchingOptions : public mrpt::utils::CLoadableOptions
00172 {
00173
00176 enum TMatchingMethod
00177 {
00180 mmCorrelation = 0,
00183 mmDescriptorSIFT,
00186 mmDescriptorSURF
00187 };
00188
00189
00190 TMatchingMethod matching_method;
00191 float epipolar_TH;
00192 float rowCheck_TH;
00193 float ccCheck_TH;
00194
00195
00196 float maxEDD_TH;
00197 float EDD_RATIO;
00198
00199
00200 float minCC_TH;
00201 float minDCC_TH;
00202 float rCC_TH;
00203
00204
00205
00208 TMatchingOptions( );
00209
00212 void loadFromConfigFile(
00213 const mrpt::utils::CConfigFileBase &source,
00214 const std::string §ion);
00215
00218 void dumpToTextStream(utils::CStream &out);
00219
00220 };
00221
00235 void MRPTDLLIMPEXP openCV_cross_correlation(
00236 const CMRPTImage &img,
00237 const CMRPTImage &patch_img,
00238 size_t &x_max,
00239 size_t &y_max,
00240 double &max_val,
00241 int x_search_ini=-1,
00242 int y_search_ini=-1,
00243 int x_search_size=-1,
00244 int y_search_size=-1);
00245
00249 void MRPTDLLIMPEXP flip(CMRPTImage &img);
00250
00258 poses::CPoint3D MRPTDLLIMPEXP pixelTo3D(float x,float y, const CMatrix &A);
00259
00275 CMatrix MRPTDLLIMPEXP buildIntrinsicParamsMatrix(
00276 float focalLengthX,
00277 float focalLengthY,
00278 float centerX,
00279 float centerY);
00280
00325 CMatrix MRPTDLLIMPEXP defaultIntrinsicParamsMatrix(
00326 unsigned int camIndex = 0,
00327 unsigned int resolutionX = 320,
00328 unsigned int resolutionY = 240 );
00329
00333 void MRPTDLLIMPEXP deleteRepeatedFeats( CFeatureList &list );
00334
00352 void MRPTDLLIMPEXP rowChecking( CFeatureList &leftList,
00353 CFeatureList &rightList,
00354 float threshold = 0.0);
00355
00359 void MRPTDLLIMPEXP checkTrackedFeatures( CFeatureList &leftList,
00360 CFeatureList &rightList,
00361 vision::TMatchingOptions options);
00362
00363
00369 void MRPTDLLIMPEXP getDispersion( const CFeatureList &list,
00370 vector_float &std,
00371 vector_float &mean );
00372
00375 void MRPTDLLIMPEXP trackFeatures( const CMRPTImage &inImg1,
00376 const CMRPTImage &inImg2,
00377 vision::CFeatureList &featureList,
00378 const unsigned int &window_width = 7,
00379 const unsigned int &window_height = 7);
00380
00384 void MRPTDLLIMPEXP filterBadCorrsByDistance( mrpt::slam::CMetricMap::TMatchingPairList &list,
00385 unsigned int numberOfSigmas );
00386
00387
00392 void MRPTDLLIMPEXP correctDistortion(
00393 CMRPTImage &in_img,
00394 CMRPTImage &out_img,
00395 CMatrix A,
00396 CMatrix dist_coeffs );
00397
00401 void MRPTDLLIMPEXP hsv2rgb(
00402 float h,
00403 float s,
00404 float v,
00405 float &r,
00406 float &g,
00407 float &b);
00408
00412 void MRPTDLLIMPEXP rgb2hsv(
00413 float r,
00414 float g,
00415 float b,
00416 float &h,
00417 float &s,
00418 float &v );
00419
00423 enum TColormap
00424 {
00425 cmGRAYSCALE = 0,
00426 cmJET
00427 };
00428
00431 void MRPTDLLIMPEXP colormap(
00432 const TColormap &color_map,
00433 const float &color_index,
00434 float &r,
00435 float &g,
00436 float &b);
00437
00441 void MRPTDLLIMPEXP jet2rgb(
00442 const float &color_index,
00443 float &r,
00444 float &g,
00445 float &b);
00446
00451 enum TInterpolationMethod
00452 {
00453 imNEAREST = 0,
00454 imBILINEAR,
00455 imBICUBIC,
00456 imAREA
00457 };
00458
00459
00463 double MRPTDLLIMPEXP computeMsd( const mrpt::slam::CMetricMap::TMatchingPairList &list,
00464 const mrpt::poses::CPose3D &Rt );
00465
00469 void MRPTDLLIMPEXP cloudsToMatchedList( const mrpt::slam::CObservationVisualLandmarks &cloud1,
00470 const mrpt::slam::CObservationVisualLandmarks &cloud2,
00471 mrpt::slam::CMetricMap::TMatchingPairList &outList);
00472
00479 float MRPTDLLIMPEXP computeMainOrientation( const CMRPTImage &image,
00480 const unsigned int &x,
00481 const unsigned int &y );
00482
00489 size_t MRPTDLLIMPEXP matchFeatures( const CFeatureList &list1,
00490 const CFeatureList &list2,
00491 CMatchedFeatureList &matches,
00492 const TMatchingOptions &options = TMatchingOptions() );
00493
00499 void MRPTDLLIMPEXP projectMatchedFeatures(
00500 CMatchedFeatureList &mfList,
00501 const vision::TStereoSystemParams ¶m,
00502 mrpt::slam::CLandmarksMap &landmarks );
00503
00504 }
00505 }
00506
00507
00508 #endif