Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

So I didn't have an problems, using the latest version. Only very small errors, e-5, and e-6. Are you sure you are passing the correct inputs and normalizing the outputs?

Mat_< float > Cam1 = ( Mat_< float >( 3, 4 ) << 1000 , 0 , 500 , 0 , 0 , 1000 , 500 , 0 , 0 , 0 , 1 , 0 );
Mat_< float > Cam2 = ( Mat_< float >( 3, 4 ) << 720.6221455223817 , -103.3307817561171 , 848.5437366007654 , -
                       951.8867514749264 , -177.5149711798716 , 950.5881039101392 , 561.1333992122866 , -
                       148.7626862924559 , -0.3953628981993094 , -0.08757713995677291 , 0.9143404307392484 ,
                       0.0602672098669313 );
vector< Point2f > ptsA{
    Point2f( 363, 240 ), 
    Point2f( 226, 308 ), 
    Point2f( 204, 308 ), 
    Point2f( 217, 310 ), 
    Point2f( 260, 281 )
};
vector< Point2f > ptsB{
    Point2f( 325.2, 264 ),
    Point2f( 157.2, 324 ), 
    Point2f( 132, 324 ), 
    Point2f( 147, 325 ), 
    Point2f( 198, 301.2 )
};
vector< Point3f > expected{
    Point3f( -0.2931, -0.55565, 2.1387 ), 
    Point3f( -0.5184, -0.36494, 1.893 ), 
    Point3f( -0.54948, -0.35738, 1.8569 ), 
    Point3f( -0.53127, -0.35903, 1.8787 ), 
    Point3f( -0.46763, -0.42688, 1.9486 )
};
Mat exp(expected);
exp = exp.reshape( 1, expected.size() );

Mat res;
triangulatePoints( Cam1, Cam2, ptsA, ptsB, res );
res.row( 0 ) /= res.row( 3 );
res.row( 1 ) /= res.row( 3 );
res.row( 2 ) /= res.row( 3 );
res.row( 3 ) /= res.row( 3 );
res = res.rowRange( 0, 3 ).t();
for ( int i = 0; i < res.rows; ++i )
    cout << norm( res.row( i ), exp.row( i ) ) << "\n";