PyDetector: adding check if returned descriptors are empty (#1715)

* PyDetector: adding check if returned descriptors are empty (addressing #1714)

* Throwing error instead of asserting if keypoints and descriptors mistmatch

* ading error instead of warning

* lets do warnings instead (could be possible that images are blanck)
This commit is contained in:
matlabbe
2026-06-01 21:04:08 -07:00
committed by GitHub
parent 6f34498651
commit f29676deb0
3 changed files with 38 additions and 12 deletions
+8 -3
View File
@@ -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>();
}
}