void computeSeqReprojError( CvSeq *seq, CvMat *model, double *error ) { CvSeqReader reader; Match_t match; cvStartReadSeq( seq, &reader, 0 ); for( int i = 0; i < seq->total; i ++ ) { CV_READ_SEQ_ELEM( match, reader ); error[i] = computeReprojError( &match, model ); } }
int OptimizationRANSAC::findInliers( const cv::Mat& m1, const cv::Mat& m2, const cv::Mat& model, cv::Mat& err, cv::Mat& mask, double threshold ) { const int count = err.rows; int good_count = 0; const double* _err = reinterpret_cast<double *>(err.data); uchar* _mask = (uchar *)mask.data; threshold *= threshold; computeReprojError( m1, m2, model, err ); for(int i = 0; i < count; i++ ) { //std::cout << _err[i] << ", "; good_count += _mask[i] = _err[i] <= threshold; } //std::cout << std::endl; return good_count; }
void computeSetReprojError( MatchSet_t *set, CvMat *model ) { for( int i = 0; i < set->length; i ++ ) { set->error[i] = computeReprojError( &(set->d[i]), model ); } }