update svn to revision 719

This commit is contained in:
Razvan Mihalyi 2012-10-15 12:08:21 +02:00
parent b135839c2a
commit efb86ac6fd
12 changed files with 83 additions and 20 deletions

Binary file not shown.

View file

@ -113,6 +113,11 @@ public:
//! Create a new set of reduced points //! Create a new set of reduced points
DataXYZ createXYZReduced(unsigned int size); DataXYZ createXYZReduced(unsigned int size);
//! Create a new set of reflectance
DataReflectance createReflectance(unsigned int size);
//! Reduced untransformed points //! Reduced untransformed points
DataXYZ getXYZReducedOriginal(); DataXYZ getXYZReducedOriginal();

View file

@ -12,6 +12,10 @@
#include <vector> #include <vector>
#include <fstream> #include <fstream>
#include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
//for opencv 2.4
#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 4)
#include <opencv2/nonfree/nonfree.hpp>
#endif
#include <math.h> #include <math.h>
#include <string> #include <string>
#include "slam6d/io_types.h" #include "slam6d/io_types.h"

View file

@ -34,6 +34,7 @@ namespace fbr{
double zMax; double zMax;
double zMin; double zMin;
IOType sFormat; IOType sFormat;
bool scanserver;
public: public:
/** /**
@ -41,8 +42,9 @@ namespace fbr{
* @param dir directory of the input scan file * @param dir directory of the input scan file
* @param number input scan number * @param number input scan number
* @param format input scan file format * @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 * @brief read scan file and convert it to open cv Mat
*/ */

View file

@ -18,7 +18,7 @@ set(CLIENT_LIBS ${Boost_LIBRARIES} pointfilter)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
# boost::interprocess uses pthread, requiring librt # boost::interprocess uses pthread, requiring librt
#set(CLIENT_LIBS ${CLIENT_LIBS} rt) set(CLIENT_LIBS ${CLIENT_LIBS} rt)
endif(UNIX AND NOT APPLE) endif(UNIX AND NOT APPLE)
target_link_libraries(scanclient ${CLIENT_LIBS}) target_link_libraries(scanclient ${CLIENT_LIBS})
@ -40,10 +40,10 @@ add_executable(scanserver ${SERVER_SRCS})
# scanio for ScanHandler input # scanio for ScanHandler input
set(SERVER_LIBS ${Boost_LIBRARIES} scanclient scanio) set(SERVER_LIBS ${Boost_LIBRARIES} scanclient scanio)
if(UNIX) if(UNIX AND NOT APPLE)
# boost::interprocess uses pthread, requiring librt # boost::interprocess uses pthread, requiring librt
set(SERVER_LIBS ${SERVER_LIBS} rt) set(SERVER_LIBS ${SERVER_LIBS} rt)
endif(UNIX) endif(UNIX AND NOT APPLE)
if(WIN32) if(WIN32)
# 3rd party getopt library # 3rd party getopt library

View file

@ -238,6 +238,13 @@ DataXYZ SharedScan::createXYZReduced(unsigned int size) {
return m_xyz_reduced->createCacheData<SharedScan::onAllocation>(size*3*sizeof(double)); return m_xyz_reduced->createCacheData<SharedScan::onAllocation>(size*3*sizeof(double));
} }
DataReflectance SharedScan::createReflectance(unsigned int size) {
// size is in units of double[1], scale to bytes
return m_reflectance->createCacheData<SharedScan::onAllocation>(size*1*sizeof(double));
}
DataXYZ SharedScan::getXYZReducedOriginal() { DataXYZ SharedScan::getXYZReducedOriginal() {
return m_xyz_reduced_original->getCacheData<SharedScan::onCacheMiss>(); return m_xyz_reduced_original->getCacheData<SharedScan::onCacheMiss>();
} }

View file

@ -4,7 +4,9 @@ SET(FBR_IO_SRC scan_cv.cc)
add_library(fbr_cv_io STATIC ${FBR_IO_SRC}) add_library(fbr_cv_io STATIC ${FBR_IO_SRC})
SET(FBR_PANORAMA_SRC panorama.cc) 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) SET(FBR_FEATURE_SRC feature.cc)
add_library(fbr_feature STATIC ${FBR_FEATURE_SRC}) 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) SET(FBR_REGISTRATION_SRC registration.cc)
add_library(fbr_registration STATIC ${FBR_REGISTRATION_SRC}) 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) IF(WITH_FBR)
SET(FBR_LIBS scan ANN ${OpenCV_LIBS}) SET(FBR_LIBS scan ANN ${OpenCV_LIBS})
add_executable(featurebasedregistration feature_based_registration.cc fbr_global.cc) 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) ENDIF(WITH_FBR)

View file

@ -30,6 +30,7 @@ struct information{
feature_descriptor_method dMethod; feature_descriptor_method dMethod;
matcher_method mMethod; matcher_method mMethod;
registration_method rMethod; registration_method rMethod;
bool scanServer;
int fSPoints, sSPoints, fFNum, sFNum, mNum, filteredMNum; int fSPoints, sSPoints, fFNum, sFNum, mNum, filteredMNum;
double fSTime, sSTime, fPTime, sPTime, fFTime, sFTime, fDTime, sDTime, mTime, rTime; 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-r registration \t registration method [ALL|ransac]\n");
printf("\t\t-V verbose \t\t level of verboseness\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-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("\n");
printf("\tExamples:\n"); printf("\tExamples:\n");
printf("\tUsing Bremen City dataset:\n"); printf("\tUsing Bremen City dataset:\n");
@ -101,11 +103,12 @@ void parssArgs(int argc, char** argv, information& info){
info.mMethod = RATIO; info.mMethod = RATIO;
info.rMethod = RANSAC; info.rMethod = RANSAC;
info.outDir = ""; info.outDir = "";
info.scanServer = false;
int c; int c;
opterr = 0; opterr = 0;
//reade the command line and get the options //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) switch (c)
{ {
case 's': case 's':
@ -162,6 +165,9 @@ void parssArgs(int argc, char** argv, information& info){
case 'O': case 'O':
info.outDir = optarg; info.outDir = optarg;
break; break;
case 'S':
info.scanServer = true;
break;
case '?': case '?':
cout<<"Unknown option character "<<optopt<<endl; cout<<"Unknown option character "<<optopt<<endl;
usage(argc, argv); usage(argc, argv);
@ -292,12 +298,13 @@ void info_yml(information info, double bError, double bErrorIdx, double* bAlign)
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
cout<<CV_VERSION<<endl;
string out; string out;
cv::Mat outImage; cv::Mat outImage;
parssArgs(argc, argv, info); parssArgs(argc, argv, info);
if(info.verbose >= 1) informationDescription(info); if(info.verbose >= 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(); if(info.verbose >= 4) info.fSTime = (double)cv::getTickCount();
fScan.convertScanToMat(); fScan.convertScanToMat();
if(info.verbose >= 4) info.fSTime = ((double)cv::getTickCount() - info.fSTime)/cv::getTickFrequency(); 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 >= 4) info.fDTime = ((double)cv::getTickCount() - info.fDTime)/cv::getTickFrequency();
if(info.verbose >= 2) fFeature.getDescription(); 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(); if(info.verbose >= 4) info.sSTime = (double)cv::getTickCount();
sScan.convertScanToMat(); sScan.convertScanToMat();
if(info.verbose >= 4) info.sSTime = ((double)cv::getTickCount() - info.sSTime)/cv::getTickFrequency(); if(info.verbose >= 4) info.sSTime = ((double)cv::getTickCount() - info.sSTime)/cv::getTickFrequency();

View file

@ -46,6 +46,11 @@ namespace fbr{
void feature_matcher::match(feature qFeature, feature tFeature){ void feature_matcher::match(feature qFeature, feature tFeature){
vector< cv::DMatch > qtInitialMatches, tqInitialMatches, gMatches; vector< cv::DMatch > qtInitialMatches, tqInitialMatches, gMatches;
vector<vector<cv::DMatch> > qtInitialMatchesVector, tqInitialMatchesVector; vector<vector<cv::DMatch> > qtInitialMatchesVector, tqInitialMatchesVector;
if(qFeature.getFeatures().size() == 0 || tFeature.getFeatures().size() == 0){
cout<<"No features has found in one or both scans!!"<<endl;
exit(-1);
}
//Matching descriptors using one of the mMethods for SURF and SIFT feature descriptors //Matching descriptors using one of the mMethods for SURF and SIFT feature descriptors
if(qFeature.getDescriptorMethod() != tFeature.getDescriptorMethod()){ if(qFeature.getDescriptorMethod() != tFeature.getDescriptorMethod()){
cout<<"inputs features don't have the same descriptors!"<<endl; cout<<"inputs features don't have the same descriptors!"<<endl;
@ -99,7 +104,12 @@ namespace fbr{
} }
} }
if(mMethod == BRUTEFORCE){ if(mMethod == BRUTEFORCE){
//opencv 2.4
#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 4)
cv::BFMatcher matcher (cv::NORM_L2);
#else //older version of opencv than 2.4
cv::BruteForceMatcher< cv::L2<float> > matcher; cv::BruteForceMatcher< cv::L2<float> > matcher;
#endif
matcher.match(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatches); matcher.match(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatches);
matcher.match(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatches); matcher.match(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatches);
} }
@ -123,12 +133,22 @@ namespace fbr{
//Matching descriptors using BruteFore with Hamming distance for ORB descriptor //Matching descriptors using BruteFore with Hamming distance for ORB descriptor
else if(qFeature.getDescriptorMethod() == ORB_DES){ else if(qFeature.getDescriptorMethod() == ORB_DES){
if(mMethod == KNN){ 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; cv::BruteForceMatcher< cv::Hamming > matcher;
#endif
matcher.knnMatch(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatchesVector, knn); matcher.knnMatch(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatchesVector, knn);
matcher.knnMatch(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatchesVector, knn); matcher.knnMatch(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatchesVector, knn);
} }
if(mMethod == RADIUS){ 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; cv::BruteForceMatcher< cv::Hamming > matcher;
#endif
matcher.radiusMatch(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatchesVector, radius); matcher.radiusMatch(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatchesVector, radius);
matcher.radiusMatch(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatchesVector, radius); matcher.radiusMatch(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatchesVector, radius);
} }
@ -146,7 +166,12 @@ namespace fbr{
} }
} }
if(mMethod == RATIO){ 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; cv::BruteForceMatcher< cv::Hamming > matcher;
#endif
matcher.knnMatch(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatchesVector, 2); matcher.knnMatch(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatchesVector, 2);
for(unsigned int i = 0; i < qtInitialMatchesVector.size(); i++){ for(unsigned int i = 0; i < qtInitialMatchesVector.size(); i++){
float ratio = qtInitialMatchesVector[i][0].distance/qtInitialMatchesVector[i][1].distance; float ratio = qtInitialMatchesVector[i][0].distance/qtInitialMatchesVector[i][1].distance;
@ -167,7 +192,12 @@ namespace fbr{
} }
} }
if(mMethod == BRUTEFORCE){ 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; cv::BruteForceMatcher< cv::Hamming > matcher;
#endif
matcher.match(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatches); matcher.match(qFeature.getDescriptors(), tFeature.getDescriptors(), qtInitialMatches);
matcher.match(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatches); matcher.match(tFeature.getDescriptors(), qFeature.getDescriptors(), tqInitialMatches);
for(unsigned int i = 0; i < qtInitialMatches.size(); i++){ for(unsigned int i = 0; i < qtInitialMatches.size(); i++){

View file

@ -678,7 +678,7 @@ namespace fbr{
float x = col * 1. / xFactor - fabs(xmin); float x = col * 1. / xFactor - fabs(xmin);
float y = (heightMax - row) * 1. / yFactor - fabs(ymin); float y = (heightMax - row) * 1. / yFactor - fabs(ymin);
float theta = asin((C - (x*x + (Rho0 - y) * (Rho0 - y)) * n * n) / (2 * n)); 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 *= 180.0 / M_PI;
phi = 360.0 - phi; phi = 360.0 - phi;

View file

@ -13,17 +13,17 @@ using namespace std;
namespace fbr{ 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; sDir = dir;
sNumber = number; sNumber = number;
sFormat = format; sFormat = format;
zMax = numeric_limits<double>::min(); zMax = numeric_limits<double>::min();
zMin = numeric_limits<double>::max(); zMin = numeric_limits<double>::max();
nPoints = 0; nPoints = 0;
scanserver = scanServer;
} }
void scan_cv::convertScanToMat(){ void scan_cv::convertScanToMat(){
bool scanserver = false;
Scan::openDirectory(scanserver, sDir, sFormat, sNumber, sNumber); Scan::openDirectory(scanserver, sDir, sFormat, sNumber, sNumber);
if(Scan::allScans.size() == 0){ if(Scan::allScans.size() == 0){
cerr << "No scans found. Did you use the correct format?" <<endl; cerr << "No scans found. Did you use the correct format?" <<endl;

View file

@ -225,6 +225,9 @@ DataPointer ManagedScan::create(const std::string& identifier, unsigned int size
} else } else
if(identifier == "xyz reduced original") { if(identifier == "xyz reduced original") {
return m_shared_scan->createXYZReducedOriginal(size / (3*sizeof(double))); return m_shared_scan->createXYZReducedOriginal(size / (3*sizeof(double)));
} else
if(identifier == "reflectance") {
return m_shared_scan->createReflectance(size / (1*sizeof(double)));
} else } else
{ {
throw runtime_error(string("Identifier '") + identifier + "' not compatible with ManagedScan::create. Upgrade SharedScan for this data field."); throw runtime_error(string("Identifier '") + identifier + "' not compatible with ManagedScan::create. Upgrade SharedScan for this data field.");