/** \brief Test construction of an empty grid **/ void export_cube_base_test::test_1() { static const char *testname = "export_cube_base_test::test_1()"; try { export_cube_test ex; mat dm1(ex.nao(), ex.nao(), fill::randu); mat dm2(ex.nao(), ex.nao(), fill::randu); mat orb1(ex.nao(), 4, fill::randu); mat orb2(ex.nao(), 5, fill::randu); std::vector<size_t> i1(4, 0), i2(5, 0); for (size_t i = 0; i < 4; i++) i1[i] = 2 * i; for (size_t i = 0; i < 5; i++) i2[i] = i; ex.perform("dm1", "First test density matrix", dm1); ex.perform("dm2", "Second test density matrix", dm2); ex.perform("orb1", "First test density matrix", i1, orb1); ex.perform("orb2", "Second test density matrix", i2, orb2); ex.do_export(); } catch (libwfa_exception &e) { fail_test(testname, __FILE__, __LINE__, e.what()); } }
void ORBStereoInit::triangulateFeatures( std::vector<DepthInitResult> & triangulated, const std::vector<Vector2f> & avoidPositionsImg0, const Image& view0, const Image& view1 ) { Parameters* params = _pset.ptr<Parameters>(); _matcher.setMaxDescDist( params->maxDescriptorDistance ); _matcher.setMaxLineDist( params->maxEpilineDistance ); Rangef depthRange( params->minDepth, params->maxDepth ); ORB orb0( view0, 2, 0.5f, params->fastThreshold, params->orbMaxFeatures, true ); ORB orb1( view1, 2, 0.5f, params->fastThreshold, params->orbMaxFeatures, true ); // find stereoMatches by avoiding already found matches std::set<size_t> doNotUse; for( size_t i = 0; i < orb0.size(); i++ ){ const Vector2f& po = orb0[ i ].pt; for( size_t k = 0; k < avoidPositionsImg0.size(); k++ ){ if( ( po - avoidPositionsImg0[ k ] ).lengthSqr() < Math::sqr( 16.0f ) ){ doNotUse.insert( i ); break; } } } FeatureMatch match; DepthInitResult result; for( size_t i = 0; i < orb0.size(); ++i ){ match.feature0 = &orb0[ i ]; size_t idx = _matcher.matchEpipolar( match, orb1, doNotUse ); if( match.feature1 ){ doNotUse.insert( idx ); // TODO: check the SAD between the two features for savety? //if( checkFeatureSAD( match.feature0->pt, match.feature1->pt, first, second ) ) // correct the correspondences result.meas0 = match.feature0->pt; result.meas1 = match.feature1->pt; Vision::correctCorrespondencesSampson( result.meas0, result.meas1, _matcher.fundamental() ); triangulateSinglePoint( result, _stereoCalib.firstCamera().projectionMatrix(), _stereoCalib.secondCamera().projectionMatrix(), depthRange ); if( result.reprojectionError < params->maxReprojectionError ){ triangulated.push_back( result ); } } } }