本文整理汇总了C++中cv::Ptr::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::clear方法的具体用法?C++ Ptr::clear怎么用?C++ Ptr::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::Ptr
的用法示例。
在下文中一共展示了Ptr::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: quality_test
inline void quality_test(cv::Ptr<quality::QualityBase> ptr, const TMat& cmp, const Scalar& expected, const std::size_t quality_maps_expected = 1, const bool empty_expected = false )
{
std::vector<cv::Mat> qMats = {};
ptr->getQualityMaps(qMats);
EXPECT_TRUE( qMats.empty());
quality_expect_near( expected, ptr->compute(cmp));
if (empty_expected)
EXPECT_TRUE(ptr->empty());
else
EXPECT_FALSE(ptr->empty());
ptr->getQualityMaps(qMats);
EXPECT_EQ( qMats.size(), quality_maps_expected);
for (auto& qm : qMats)
{
EXPECT_GT(qm.rows, 0);
EXPECT_GT(qm.cols, 0);
}
ptr->clear();
EXPECT_TRUE(ptr->empty());
}
示例2:
std::vector< cv::DMatch > SequenceAnalyzer::simple_matching(
cv::Ptr<PointsMatcher> point_matcher,
cv::Ptr<PointsMatcher> point_matcher1,
unsigned int mininum_points_matches)
{
vector< cv::DMatch > matches_i_j;
point_matcher->crossMatch( point_matcher1, matches_i_j );
//First compute points matches:
unsigned int size_match=matches_i_j.size( );
vector<cv::Point2f> srcP;
vector<cv::Point2f> destP;
vector<uchar> status;
//vector<KeyPoint> points1 = point_matcher->;
for( size_t cpt = 0; cpt < size_match; ++cpt ){
const cv::KeyPoint &key1 = point_matcher1->getKeypoint(
matches_i_j[ cpt ].queryIdx );
const cv::KeyPoint &key2 = point_matcher->getKeypoint(
matches_i_j[ cpt ].trainIdx );
srcP.push_back( cv::Point2f( key1.pt.x,key1.pt.y ) );
destP.push_back( cv::Point2f( key2.pt.x,key2.pt.y ) );
status.push_back( 1 );
}
//free some memory:
point_matcher->clear();
point_matcher1->clear();
if( srcP.size()< mininum_points_matches )
return matches_i_j;
cv::Mat fundam = cv::findFundamentalMat( srcP, destP, status, cv::FM_RANSAC, 1 );
unsigned int nbErrors = 0, nb_iter=0;
//refine the mathing :
size_match = status.size( );
for( size_t cpt = 0; cpt < size_match; ++cpt ){
if( status[ cpt ] == 0 )
{
size_match--;
status[ cpt ] = status[ size_match ];
status.pop_back( );
srcP[ cpt ] = srcP[ size_match ];
srcP.pop_back( );
destP[ cpt ] = destP[ size_match ];
destP.pop_back( );
matches_i_j[ cpt ] = matches_i_j[ size_match ];
matches_i_j.pop_back( );
cpt--;
++nbErrors;
}
}
if( srcP.size()< mininum_points_matches )
return matches_i_j;
//refine the mathing:
fundam = cv::findFundamentalMat( srcP, destP, status, cv::FM_LMEDS );
size_match = status.size( );
for( size_t cpt = 0; cpt < size_match; ++cpt ){
if( status[ cpt ] == 0 )
{
size_match--;
status[ cpt ] = status[ size_match ];
status.pop_back( );
srcP[ cpt ] = srcP[ size_match ];
srcP.pop_back( );
destP[ cpt ] = destP[ size_match ];
destP.pop_back( );
matches_i_j[ cpt ] = matches_i_j[ size_match ];
matches_i_j.pop_back( );
cpt--;
++nbErrors;
}
}
return matches_i_j;
};