mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-04 00:57:46 +08:00
Merge branch 'master' of github.com:introlab/rtabmap into gtest
This commit is contained in:
@@ -887,8 +887,17 @@ cv::Mat Feature2D::generateDescriptors(
|
||||
UASSERT(!image.empty());
|
||||
UASSERT(image.type() == CV_8UC1);
|
||||
descriptors = generateDescriptorsImpl(image, keypoints);
|
||||
UASSERT_MSG(descriptors.rows == (int)keypoints.size(), uFormat("descriptors=%d, keypoints=%d", descriptors.rows, (int)keypoints.size()).c_str());
|
||||
UDEBUG("Descriptors extracted = %d, remaining kpts=%d", descriptors.rows, (int)keypoints.size());
|
||||
if(descriptors.rows != (int)keypoints.size())
|
||||
{
|
||||
UWARN("Descriptor extraction returned %d rows for %d keypoints — "
|
||||
"clearing keypoints to keep them in sync.",
|
||||
descriptors.rows, (int)keypoints.size());
|
||||
keypoints.clear();
|
||||
descriptors = cv::Mat();
|
||||
}
|
||||
else {
|
||||
UDEBUG("Descriptors extracted = %d, remaining kpts=%d", descriptors.rows, (int)keypoints.size());
|
||||
}
|
||||
}
|
||||
return descriptors;
|
||||
}
|
||||
|
||||
@@ -113,11 +113,14 @@ ParametersMap Parameters::deserialize(const std::string & parameters)
|
||||
std::list<std::string> tuplets = uSplit(parameters, ';');
|
||||
for(std::list<std::string>::iterator iter=tuplets.begin(); iter!=tuplets.end(); ++iter)
|
||||
{
|
||||
std::list<std::string> p = uSplit(*iter, ':');
|
||||
if(p.size() == 2)
|
||||
// Split on the FIRST ':' only. Using uSplit() here would discard
|
||||
// empty tokens, so a tuplet like "Marker/Lengths:" (legitimate empty
|
||||
// string value) would lose the value side and be dropped entirely.
|
||||
size_t colonPos = iter->find(':');
|
||||
if(colonPos != std::string::npos && colonPos > 0)
|
||||
{
|
||||
std::string key = p.front();
|
||||
std::string value = p.back();
|
||||
std::string key = iter->substr(0, colonPos);
|
||||
std::string value = iter->substr(colonPos + 1);
|
||||
|
||||
// look for old parameter name
|
||||
bool addParameter = true;
|
||||
|
||||
@@ -144,7 +144,12 @@ std::vector<cv::KeyPoint> SPDetector::detect(const cv::Mat &img, const cv::Mat &
|
||||
UASSERT(img.type() == CV_8UC1);
|
||||
UASSERT(mask.empty() || (mask.type() == CV_8UC1 && img.cols == mask.cols && img.rows == mask.rows));
|
||||
detected_ = false;
|
||||
if(model_)
|
||||
if(!model_)
|
||||
{
|
||||
UERROR("No model is loaded!");
|
||||
return std::vector<cv::KeyPoint>();
|
||||
}
|
||||
try
|
||||
{
|
||||
torch::NoGradGuard no_grad_guard;
|
||||
auto x = torch::from_blob(img.data, {1, 1, img.rows, img.cols}, torch::kByte);
|
||||
@@ -199,9 +204,9 @@ std::vector<cv::KeyPoint> SPDetector::detect(const cv::Mat &img, const cv::Mat &
|
||||
detected_ = true;
|
||||
return keypoints;
|
||||
}
|
||||
else
|
||||
catch(const std::exception & e)
|
||||
{
|
||||
UERROR("No model is loaded!");
|
||||
UERROR("SPDetector::detect() threw: %s", e.what());
|
||||
return std::vector<cv::KeyPoint>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user