From 84166e6ddcf595bf5bf30a1797ee5d4bad20d12c Mon Sep 17 00:00:00 2001 From: matlabbe Date: Mon, 5 Jan 2015 23:11:15 +0000 Subject: [PATCH] fixed Debug build errors, changed all Q_ASSERT to UASSERT git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@417 620bd6b2-0a58-f614-fd9a-1bd335dccda9 --- src/AddObjectDialog.cpp | 2 +- src/FindObject.cpp | 12 ++++++------ src/MainWindow.cpp | 8 ++++---- src/Settings.cpp | 16 ++++++++-------- src/Vocabulary.cpp | 18 ++++++++++-------- 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/AddObjectDialog.cpp b/src/AddObjectDialog.cpp index 9a8c643e..1e134829 100644 --- a/src/AddObjectDialog.cpp +++ b/src/AddObjectDialog.cpp @@ -58,7 +58,7 @@ AddObjectDialog::AddObjectDialog(Camera * camera, const cv::Mat & image, bool mi detector_ = Settings::createKeypointDetector(); extractor_ = Settings::createDescriptorExtractor(); - Q_ASSERT(detector_ != 0 && extractor_ != 0); + UASSERT(detector_ != 0 && extractor_ != 0); connect(ui_->pushButton_cancel, SIGNAL(clicked()), this, SLOT(cancel())); connect(ui_->pushButton_back, SIGNAL(clicked()), this, SLOT(back())); diff --git a/src/FindObject.cpp b/src/FindObject.cpp index 34efc36d..f72ce7f9 100644 --- a/src/FindObject.cpp +++ b/src/FindObject.cpp @@ -49,7 +49,7 @@ FindObject::FindObject(QObject * parent) : extractor_(Settings::createDescriptorExtractor()) { qRegisterMetaType("find_object::DetectionInfo"); - Q_ASSERT(detector_ != 0 && extractor_ != 0); + UASSERT(detector_ != 0 && extractor_ != 0); } FindObject::~FindObject() { @@ -117,7 +117,7 @@ const ObjSignature * FindObject::addObject(const QString & filePath) const ObjSignature * FindObject::addObject(const cv::Mat & image, int id, const QString & filename) { - Q_ASSERT(id >= 0); + UASSERT(id >= 0); ObjSignature * s = new ObjSignature(id, image, filename); if(!this->addObject(s)) { @@ -129,7 +129,7 @@ const ObjSignature * FindObject::addObject(const cv::Mat & image, int id, const bool FindObject::addObject(ObjSignature * obj) { - Q_ASSERT(obj != 0 && obj->id() >= 0); + UASSERT(obj != 0 && obj->id() >= 0); if(obj->id() && objects_.contains(obj->id())) { UERROR("object with id %d already added!", obj->id()); @@ -171,7 +171,7 @@ void FindObject::updateDetectorExtractor() delete extractor_; detector_ = Settings::createKeypointDetector(); extractor_ = Settings::createDescriptorExtractor(); - Q_ASSERT(detector_ != 0 && extractor_ != 0); + UASSERT(detector_ != 0 && extractor_ != 0); } std::vector limitKeypoints(const std::vector & keypoints, int maxKeypoints) @@ -664,7 +664,7 @@ public: minMatchedDistance_(-1.0f), maxMatchedDistance_(-1.0f) { - Q_ASSERT(index && descriptors); + UASSERT(descriptors); } virtual ~SearchThread() {} @@ -760,7 +760,7 @@ public: kptsB_(kptsB), code_(DetectionInfo::kRejectedUndef) { - Q_ASSERT(matches && kptsA && kptsB); + UASSERT(matches && kptsA && kptsB); } virtual ~HomographyThread() {} diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 969312b1..04ace05b 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -84,7 +84,7 @@ MainWindow::MainWindow(FindObject * findObject, Camera * camera, QWidget * paren objectsModified_(false), tcpServer_(0) { - Q_ASSERT(findObject_ != 0); + UASSERT(findObject_ != 0); ui_ = new Ui_mainWindow(); ui_->setupUi(this); @@ -565,7 +565,7 @@ void MainWindow::addObjectFromScene() ObjWidget * obj = 0; ObjSignature * signature = 0; dialog->retrieveObject(&obj, &signature); - Q_ASSERT(obj!=0 && signature!=0); + UASSERT(obj!=0 && signature!=0); findObject_->addObject(signature); obj->setId(signature->id()); objWidgets_.insert(obj->id(), obj); @@ -1028,7 +1028,7 @@ void MainWindow::update(const cv::Mat & image) label->setText(QString("%1 matches").arg(jter.value().size())); ObjWidget * obj = objWidgets_.value(id); - Q_ASSERT(obj != 0); + UASSERT(obj != 0); for(QMultiMap::const_iterator iter = jter.value().constBegin(); iter!= jter.value().constEnd(); ++iter) { @@ -1084,7 +1084,7 @@ void MainWindow::update(const cv::Mat & image) { int id = iter.key(); ObjWidget * obj = objWidgets_.value(id); - Q_ASSERT(obj != 0); + UASSERT(obj != 0); // COLORIZE (should be done in the GUI thread) QTransform hTransform = iter.value(); diff --git a/src/Settings.cpp b/src/Settings.cpp index 055f729f..8ba568b9 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -332,7 +332,7 @@ public: descriptors = cv::Mat(); else { - Q_ASSERT(descriptorsGPU.type() == CV_32F); + UASSERT(descriptorsGPU.type() == CV_32F); descriptors = cv::Mat(descriptorsGPU.size(), CV_32F); descriptorsGPU.download(descriptors); } @@ -444,7 +444,7 @@ protected: descriptors = cv::Mat(); else { - Q_ASSERT(descriptorsGPU.type() == CV_8U); + UASSERT(descriptorsGPU.type() == CV_8U); descriptors = cv::Mat(descriptorsGPU.size(), CV_8U); descriptorsGPU.download(descriptors); } @@ -626,7 +626,7 @@ KeypointDetector * Settings::createKeypointDetector() } } - Q_ASSERT(detectorGPU!=0 || detector!=0); + UASSERT(detectorGPU!=0 || detector!=0); if(detectorGPU) { return new KeypointDetector(detectorGPU); @@ -760,7 +760,7 @@ DescriptorExtractor * Settings::createDescriptorExtractor() } } - Q_ASSERT(extractorGPU!=0 || extractor!=0); + UASSERT(extractorGPU!=0 || extractor!=0); if(extractorGPU) { return new DescriptorExtractor(extractorGPU); @@ -987,13 +987,13 @@ KeypointDetector::KeypointDetector(cv::FeatureDetector * featureDetector) : featureDetector_(featureDetector), gpuFeature2D_(0) { - Q_ASSERT(featureDetector_!=0); + UASSERT(featureDetector_!=0); } KeypointDetector::KeypointDetector(GPUFeature2D * gpuFeature2D) : featureDetector_(0), gpuFeature2D_(gpuFeature2D) { - Q_ASSERT(gpuFeature2D_!=0); + UASSERT(gpuFeature2D_!=0); } void KeypointDetector::detect(const cv::Mat & image, std::vector & keypoints, @@ -1013,13 +1013,13 @@ DescriptorExtractor::DescriptorExtractor(cv::DescriptorExtractor * descriptorExt descriptorExtractor_(descriptorExtractor), gpuFeature2D_(0) { - Q_ASSERT(descriptorExtractor_!=0); + UASSERT(descriptorExtractor_!=0); } DescriptorExtractor::DescriptorExtractor(GPUFeature2D * gpuFeature2D) : descriptorExtractor_(0), gpuFeature2D_(gpuFeature2D) { - Q_ASSERT(gpuFeature2D_!=0); + UASSERT(gpuFeature2D_!=0); } void DescriptorExtractor::compute(const cv::Mat & image, std::vector & keypoints, diff --git a/src/Vocabulary.cpp b/src/Vocabulary.cpp index 6dcd269d..d7ec44c1 100644 --- a/src/Vocabulary.cpp +++ b/src/Vocabulary.cpp @@ -27,6 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "find_object/Settings.h" +#include "find_object/utilite/ULogger.h" #include "Vocabulary.h" #include #include @@ -67,7 +68,7 @@ QMultiMap Vocabulary::addWords(const cv::Mat & descriptors, int object bool globalSearch = false; if(!indexedDescriptors_.empty() && indexedDescriptors_.rows >= (int)k) { - Q_ASSERT(indexedDescriptors_.type() == descriptors.type() && indexedDescriptors_.cols == descriptors.cols); + UASSERT(indexedDescriptors_.type() == descriptors.type() && indexedDescriptors_.cols == descriptors.cols); this->search(descriptors, results, dists, k); if( dists.type() == CV_32S ) @@ -88,7 +89,7 @@ QMultiMap Vocabulary::addWords(const cv::Mat & descriptors, int object QMultiMap fullResults; // nearest descriptors sorted by distance if(notIndexedDescriptors_.rows) { - Q_ASSERT(newWords.type() == descriptors.type() && newWords.cols == descriptors.cols); + UASSERT(notIndexedDescriptors_.type() == descriptors.type() && notIndexedDescriptors_.cols == descriptors.cols); // Check if this descriptor matches with a word not already added to the vocabulary // Do linear search only @@ -198,9 +199,12 @@ void Vocabulary::update() { if(!notIndexedDescriptors_.empty()) { - Q_ASSERT(indexedDescriptors_.cols == notIndexedDescriptors_.cols && - indexedDescriptors_.type() == notIndexedDescriptors_.type() ); - + if(!indexedDescriptors_.empty()) + { + UASSERT(indexedDescriptors_.cols == notIndexedDescriptors_.cols && + indexedDescriptors_.type() == notIndexedDescriptors_.type() ); + } + //concatenate descriptors indexedDescriptors_.push_back(notIndexedDescriptors_); @@ -218,11 +222,9 @@ void Vocabulary::update() void Vocabulary::search(const cv::Mat & descriptors, cv::Mat & results, cv::Mat & dists, int k) { - Q_ASSERT(notIndexedDescriptors_.empty() && notIndexedWordIds_.size() == 0); - if(!indexedDescriptors_.empty()) { - Q_ASSERT(descriptors.type() == indexedDescriptors_.type() && descriptors.cols == indexedDescriptors_.cols); + UASSERT(descriptors.type() == indexedDescriptors_.type() && descriptors.cols == indexedDescriptors_.cols); if(Settings::isBruteForceNearestNeighbor()) {