Fixed dim assert with binary descriptors and fixed dictionary

This commit is contained in:
matlabbe
2019-05-04 14:58:02 -04:00
parent 4675240d6e
commit cc95ca1cf6

View File

@@ -16,6 +16,7 @@ modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
@@ -526,6 +527,7 @@ void VWDictionary::update()
UTimer timer; UTimer timer;
timer.start(); timer.start();
int dim = _visualWords.begin()->second->getDescriptor().cols;
int type; int type;
if(_visualWords.begin()->second->getDescriptor().type() == CV_8U) if(_visualWords.begin()->second->getDescriptor().type() == CV_8U)
{ {
@@ -533,6 +535,7 @@ void VWDictionary::update()
if(_strategy == kNNFlannKdTree) if(_strategy == kNNFlannKdTree)
{ {
type = CV_32F; type = CV_32F;
dim *= 8;
} }
else else
{ {
@@ -543,7 +546,6 @@ void VWDictionary::update()
{ {
type = _visualWords.begin()->second->getDescriptor().type(); type = _visualWords.begin()->second->getDescriptor().type();
} }
int dim = _visualWords.begin()->second->getDescriptor().cols;
UASSERT(type == CV_32F || type == CV_8U); UASSERT(type == CV_32F || type == CV_8U);
UASSERT(dim > 0); UASSERT(dim > 0);
@@ -570,8 +572,8 @@ void VWDictionary::update()
descriptor = iter->second->getDescriptor(); descriptor = iter->second->getDescriptor();
} }
UASSERT(descriptor.cols == dim); UASSERT_MSG(descriptor.type() == type, uFormat("%d vs %d", descriptor.type(), type).c_str());
UASSERT(descriptor.type() == type); UASSERT_MSG(descriptor.cols == dim, uFormat("%d vs %d", descriptor.cols, dim).c_str());
descriptor.copyTo(_dataTree.row(i)); descriptor.copyTo(_dataTree.row(i));
_mapIndexId.insert(_mapIndexId.end(), std::pair<int, int>(i, iter->second->id())); _mapIndexId.insert(_mapIndexId.end(), std::pair<int, int>(i, iter->second->id()));