mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-03 01:50:24 +08:00
Fixed stereo optical flow crash when no keypoints are extracted
This commit is contained in:
@@ -566,12 +566,16 @@ std::vector<cv::KeyPoint> Feature2D::generateKeypoints(const cv::Mat & image, co
|
|||||||
cv::Mat Feature2D::generateDescriptors(
|
cv::Mat Feature2D::generateDescriptors(
|
||||||
const cv::Mat & image,
|
const cv::Mat & image,
|
||||||
std::vector<cv::KeyPoint> & keypoints) const
|
std::vector<cv::KeyPoint> & keypoints) const
|
||||||
|
{
|
||||||
|
cv::Mat descriptors;
|
||||||
|
if(keypoints.size())
|
||||||
{
|
{
|
||||||
UASSERT(!image.empty());
|
UASSERT(!image.empty());
|
||||||
UASSERT(image.type() == CV_8UC1);
|
UASSERT(image.type() == CV_8UC1);
|
||||||
cv::Mat descriptors = generateDescriptorsImpl(image, keypoints);
|
descriptors = generateDescriptorsImpl(image, keypoints);
|
||||||
UASSERT_MSG(descriptors.rows == (int)keypoints.size(), uFormat("descriptors=%d, keypoints=%d", descriptors.rows, (int)keypoints.size()).c_str());
|
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());
|
UDEBUG("Descriptors extracted = %d, remaining kpts=%d", descriptors.rows, (int)keypoints.size());
|
||||||
|
}
|
||||||
return descriptors;
|
return descriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,6 +584,8 @@ std::vector<cv::Point3f> Feature2D::generateKeypoints3D(
|
|||||||
const std::vector<cv::KeyPoint> & keypoints) const
|
const std::vector<cv::KeyPoint> & keypoints) const
|
||||||
{
|
{
|
||||||
std::vector<cv::Point3f> keypoints3D;
|
std::vector<cv::Point3f> keypoints3D;
|
||||||
|
if(keypoints.size())
|
||||||
|
{
|
||||||
if(!data.rightRaw().empty() && !data.imageRaw().empty() && data.stereoCameraModel().isValidForProjection())
|
if(!data.rightRaw().empty() && !data.imageRaw().empty() && data.stereoCameraModel().isValidForProjection())
|
||||||
{
|
{
|
||||||
//stereo
|
//stereo
|
||||||
@@ -622,6 +628,7 @@ std::vector<cv::Point3f> Feature2D::generateKeypoints3D(
|
|||||||
_minDepth,
|
_minDepth,
|
||||||
_maxDepth);
|
_maxDepth);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return keypoints3D;
|
return keypoints3D;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user