diff --git a/.svn/wc.db b/.svn/wc.db index 1cb2af3..ec0bfde 100644 Binary files a/.svn/wc.db and b/.svn/wc.db differ diff --git a/include/scanserver/sharedScan.h b/include/scanserver/sharedScan.h index 9b24d38..ad98d40 100644 --- a/include/scanserver/sharedScan.h +++ b/include/scanserver/sharedScan.h @@ -112,7 +112,12 @@ public: //! Create a new set of reduced points DataXYZ createXYZReduced(unsigned int size); + + + //! Create a new set of reflectance + DataReflectance createReflectance(unsigned int size); + //! Reduced untransformed points DataXYZ getXYZReducedOriginal(); diff --git a/include/slam6d/fbr/fbr_global.h b/include/slam6d/fbr/fbr_global.h index b9193ac..8aebb0a 100644 --- a/include/slam6d/fbr/fbr_global.h +++ b/include/slam6d/fbr/fbr_global.h @@ -12,6 +12,10 @@ #include #include #include +//for opencv 2.4 +#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 4) +#include +#endif #include #include #include "slam6d/io_types.h" diff --git a/include/slam6d/fbr/scan_cv.h b/include/slam6d/fbr/scan_cv.h index 1cdc3d6..bb9b88f 100644 --- a/include/slam6d/fbr/scan_cv.h +++ b/include/slam6d/fbr/scan_cv.h @@ -34,6 +34,7 @@ namespace fbr{ double zMax; double zMin; IOType sFormat; + bool scanserver; public: /** @@ -41,8 +42,9 @@ namespace fbr{ * @param dir directory of the input scan file * @param number input scan number * @param format input scan file format + * @param scanServer */ - scan_cv (string dir, unsigned int number, IOType format); + scan_cv (string dir, unsigned int number, IOType format, bool scanServer); /** * @brief read scan file and convert it to open cv Mat */ diff --git a/src/scanserver/CMakeLists.txt b/src/scanserver/CMakeLists.txt index 3dfa927..fc59256 100644 --- a/src/scanserver/CMakeLists.txt +++ b/src/scanserver/CMakeLists.txt @@ -18,7 +18,7 @@ set(CLIENT_LIBS ${Boost_LIBRARIES} pointfilter) if(UNIX AND NOT APPLE) # boost::interprocess uses pthread, requiring librt - #set(CLIENT_LIBS ${CLIENT_LIBS} rt) + set(CLIENT_LIBS ${CLIENT_LIBS} rt) endif(UNIX AND NOT APPLE) target_link_libraries(scanclient ${CLIENT_LIBS}) @@ -40,10 +40,10 @@ add_executable(scanserver ${SERVER_SRCS}) # scanio for ScanHandler input set(SERVER_LIBS ${Boost_LIBRARIES} scanclient scanio) -if(UNIX) +if(UNIX AND NOT APPLE) # boost::interprocess uses pthread, requiring librt set(SERVER_LIBS ${SERVER_LIBS} rt) -endif(UNIX) +endif(UNIX AND NOT APPLE) if(WIN32) # 3rd party getopt library diff --git a/src/scanserver/sharedScan.cc b/src/scanserver/sharedScan.cc index 93ede82..49bed21 100644 --- a/src/scanserver/sharedScan.cc +++ b/src/scanserver/sharedScan.cc @@ -238,6 +238,13 @@ DataXYZ SharedScan::createXYZReduced(unsigned int size) { return m_xyz_reduced->createCacheData(size*3*sizeof(double)); } + +DataReflectance SharedScan::createReflectance(unsigned int size) { + // size is in units of double[1], scale to bytes + return m_reflectance->createCacheData(size*1*sizeof(double)); +} + + DataXYZ SharedScan::getXYZReducedOriginal() { return m_xyz_reduced_original->getCacheData(); } diff --git a/src/slam6d/fbr/CMakeLists.txt b/src/slam6d/fbr/CMakeLists.txt index e6f5206..1353805 100644 --- a/src/slam6d/fbr/CMakeLists.txt +++ b/src/slam6d/fbr/CMakeLists.txt @@ -4,7 +4,9 @@ SET(FBR_IO_SRC scan_cv.cc) add_library(fbr_cv_io STATIC ${FBR_IO_SRC}) SET(FBR_PANORAMA_SRC panorama.cc) -add_library(fbr_panorama STATIC ${FBR_PANORAMA_SRC} fbr_global.cc) +add_library(fbr_panorama STATIC ${FBR_PANORAMA_SRC}) +#add_library(fbr_panorama STATIC ${FBR_PANORAMA_SRC} fbr_global.cc) + SET(FBR_FEATURE_SRC feature.cc) add_library(fbr_feature STATIC ${FBR_FEATURE_SRC}) @@ -15,9 +17,12 @@ add_library(fbr_feature_matcher STATIC ${FBR_FEATURE_MATCHER_SRC}) SET(FBR_REGISTRATION_SRC registration.cc) add_library(fbr_registration STATIC ${FBR_REGISTRATION_SRC}) +add_library(fbr STATIC ${FBR_IO_SRC} ${FBR_PANORAMA_SRC} ${FBR_FEATURE_SRC} ${FBR_FEATURE_MATCHER_SRC} ${FBR_REGISTRATION_SRC} fbr_global.cc) + IF(WITH_FBR) SET(FBR_LIBS scan ANN ${OpenCV_LIBS}) add_executable(featurebasedregistration feature_based_registration.cc fbr_global.cc) -target_link_libraries(featurebasedregistration fbr_cv_io fbr_panorama fbr_feature fbr_feature_matcher fbr_registration ${FBR_LIBS}) +#target_link_libraries(featurebasedregistration fbr_cv_io fbr_panorama fbr_feature fbr_feature_matcher fbr_registration ${FBR_LIBS}) +target_link_libraries(featurebasedregistration fbr ${FBR_LIBS}) ENDIF(WITH_FBR) diff --git a/src/slam6d/fbr/feature_based_registration.cc b/src/slam6d/fbr/feature_based_registration.cc index 9bb4638..b3c0966 100644 --- a/src/slam6d/fbr/feature_based_registration.cc +++ b/src/slam6d/fbr/feature_based_registration.cc @@ -30,6 +30,7 @@ struct information{ feature_descriptor_method dMethod; matcher_method mMethod; registration_method rMethod; + bool scanServer; int fSPoints, sSPoints, fFNum, sFNum, mNum, filteredMNum; double fSTime, sSTime, fPTime, sPTime, fFTime, sFTime, fDTime, sDTime, mTime, rTime; @@ -60,6 +61,7 @@ void usage(int argc, char** argv){ printf("\t\t-r registration \t registration method [ALL|ransac]\n"); printf("\t\t-V verbose \t\t level of verboseness\n"); printf("\t\t-O outDir \t\t output directory if not stated same as input\n"); + printf("\t\t-S scanServer \t\t Scan Server\n"); printf("\n"); printf("\tExamples:\n"); printf("\tUsing Bremen City dataset:\n"); @@ -101,11 +103,12 @@ void parssArgs(int argc, char** argv, information& info){ info.mMethod = RATIO; info.rMethod = RANSAC; info.outDir = ""; + info.scanServer = false; int c; opterr = 0; //reade the command line and get the options - while ((c = getopt (argc, argv, "F:W:H:p:N:P:f:d:m:D:E:I:M:r:V:O:s:e:")) != -1) + while ((c = getopt (argc, argv, "F:W:H:p:N:P:f:d:m:D:E:I:M:r:V:O:s:e:S")) != -1) switch (c) { case 's': @@ -162,6 +165,9 @@ void parssArgs(int argc, char** argv, information& info){ case 'O': info.outDir = optarg; break; + case 'S': + info.scanServer = true; + break; case '?': cout<<"Unknown option character "<= 1) informationDescription(info); - scan_cv fScan (info.dir, info.fScanNumber, info.sFormat); + scan_cv fScan (info.dir, info.fScanNumber, info.sFormat, info.scanServer); if(info.verbose >= 4) info.fSTime = (double)cv::getTickCount(); fScan.convertScanToMat(); if(info.verbose >= 4) info.fSTime = ((double)cv::getTickCount() - info.fSTime)/cv::getTickFrequency(); @@ -328,7 +335,7 @@ int main(int argc, char** argv){ if(info.verbose >= 4) info.fDTime = ((double)cv::getTickCount() - info.fDTime)/cv::getTickFrequency(); if(info.verbose >= 2) fFeature.getDescription(); - scan_cv sScan (info.dir, info.sScanNumber, info.sFormat); + scan_cv sScan (info.dir, info.sScanNumber, info.sFormat, info.scanServer); if(info.verbose >= 4) info.sSTime = (double)cv::getTickCount(); sScan.convertScanToMat(); if(info.verbose >= 4) info.sSTime = ((double)cv::getTickCount() - info.sSTime)/cv::getTickFrequency(); @@ -358,7 +365,7 @@ int main(int argc, char** argv){ sFeature.featureDescription(sPanorama.getReflectanceImage(), info.dMethod); if(info.verbose >= 4) info.sDTime = ((double)cv::getTickCount() - info.sDTime)/cv::getTickFrequency(); if(info.verbose >= 2) sFeature.getDescription(); - + feature_matcher matcher (info.mMethod, info.mParam); if(info.verbose >= 4) info.mTime = (double)cv::getTickCount(); matcher.match(fFeature, sFeature); diff --git a/src/slam6d/fbr/feature_matcher.cc b/src/slam6d/fbr/feature_matcher.cc index cd0b3fa..188bc1d 100644 --- a/src/slam6d/fbr/feature_matcher.cc +++ b/src/slam6d/fbr/feature_matcher.cc @@ -46,6 +46,11 @@ namespace fbr{ void feature_matcher::match(feature qFeature, feature tFeature){ vector< cv::DMatch > qtInitialMatches, tqInitialMatches, gMatches; vector > qtInitialMatchesVector, tqInitialMatchesVector; + if(qFeature.getFeatures().size() == 0 || tFeature.getFeatures().size() == 0){ + cout<<"No features has found in one or both scans!!"<= 2) && (CV_MINOR_VERSION >= 4) + cv::BFMatcher matcher (cv::NORM_L2); +#else //older version of opencv than 2.4 cv::BruteForceMatcher< cv::L2 > matcher; +#endif matcher.match(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatches); matcher.match(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatches); - } + } if(mMethod == FLANN){ cv::FlannBasedMatcher matcher; matcher.match(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatches); @@ -123,12 +133,22 @@ namespace fbr{ //Matching descriptors using BruteFore with Hamming distance for ORB descriptor else if(qFeature.getDescriptorMethod() == ORB_DES){ if(mMethod == KNN){ + //opencv 2.4 +#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 4) + cv::BFMatcher matcher (cv::NORM_HAMMING); +#else //older version of opencv than 2.4 cv::BruteForceMatcher< cv::Hamming > matcher; +#endif matcher.knnMatch(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatchesVector, knn); matcher.knnMatch(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatchesVector, knn); } if(mMethod == RADIUS){ + //opencv 2.4 +#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 4) + cv::BFMatcher matcher (cv::NORM_HAMMING); +#else //older version of opencv than 2.4 cv::BruteForceMatcher< cv::Hamming > matcher; +#endif matcher.radiusMatch(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatchesVector, radius); matcher.radiusMatch(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatchesVector, radius); } @@ -146,7 +166,12 @@ namespace fbr{ } } if(mMethod == RATIO){ + //opencv 2.4 +#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 4) + cv::BFMatcher matcher (cv::NORM_HAMMING); +#else //older version of opencv than 2.4 cv::BruteForceMatcher< cv::Hamming > matcher; +#endif matcher.knnMatch(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatchesVector, 2); for(unsigned int i = 0; i < qtInitialMatchesVector.size(); i++){ float ratio = qtInitialMatchesVector[i][0].distance/qtInitialMatchesVector[i][1].distance; @@ -167,7 +192,12 @@ namespace fbr{ } } if(mMethod == BRUTEFORCE){ + //opencv 2.4 +#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 4) + cv::BFMatcher matcher (cv::NORM_HAMMING); +#else //older version of opencv than 2.4 cv::BruteForceMatcher< cv::Hamming > matcher; +#endif matcher.match(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatches); matcher.match(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatches); for(unsigned int i = 0; i < qtInitialMatches.size(); i++){ @@ -206,7 +236,7 @@ namespace fbr{ vector feature_matcher::getMatches(){ return matches; } - + matcher_method feature_matcher::getMatcherMethod(){ return mMethod; } diff --git a/src/slam6d/fbr/panorama.cc b/src/slam6d/fbr/panorama.cc index 6dbf896..e488f0b 100644 --- a/src/slam6d/fbr/panorama.cc +++ b/src/slam6d/fbr/panorama.cc @@ -678,7 +678,7 @@ namespace fbr{ float x = col * 1. / xFactor - fabs(xmin); float y = (heightMax - row) * 1. / yFactor - fabs(ymin); float theta = asin((C - (x*x + (Rho0 - y) * (Rho0 - y)) * n * n) / (2 * n)); - float phi = Long0 + (1./n) * atan2(x, Rho0 - y); + float phi = Long0 + (1./n) * ::atan2(x, Rho0 - y); phi *= 180.0 / M_PI; phi = 360.0 - phi; diff --git a/src/slam6d/fbr/scan_cv.cc b/src/slam6d/fbr/scan_cv.cc index 112eed9..35c5f8f 100644 --- a/src/slam6d/fbr/scan_cv.cc +++ b/src/slam6d/fbr/scan_cv.cc @@ -13,17 +13,17 @@ using namespace std; namespace fbr{ - scan_cv::scan_cv(string dir, unsigned int number, IOType format){ + scan_cv::scan_cv(string dir, unsigned int number, IOType format, bool scanServer){ sDir = dir; sNumber = number; sFormat = format; zMax = numeric_limits::min(); zMin = numeric_limits::max(); nPoints = 0; - } - + scanserver = scanServer; + } + void scan_cv::convertScanToMat(){ - bool scanserver = false; Scan::openDirectory(scanserver, sDir, sFormat, sNumber, sNumber); if(Scan::allScans.size() == 0){ cerr << "No scans found. Did you use the correct format?" <createXYZReducedOriginal(size / (3*sizeof(double))); } else - { - throw runtime_error(string("Identifier '") + identifier + "' not compatible with ManagedScan::create. Upgrade SharedScan for this data field."); + if(identifier == "reflectance") { + return m_shared_scan->createReflectance(size / (1*sizeof(double))); + } else + { + throw runtime_error(string("Identifier '") + identifier + "' not compatible with ManagedScan::create. Upgrade SharedScan for this data field."); } }