0001-operator-Matx-.-Point2-.-fixed-with-a-test.patch

patch - Christoph Siedentop, 2011-08-12 04:56 pm

Download (2.6 kB)

 
b/opencv/modules/core/include/opencv2/core/operations.hpp
639 639
template<typename _Tp> static inline
640 640
Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point_<_Tp>& b)
641 641
{
642
    return Point3_<_Tp>(a*Vec<_Tp,3>(b.x, b.y, 1));
642
    const Matx<_Tp, 3, 1> mat = a * Vec<_Tp,3>(b.x, b.y, 1);
643
    return Point3_<_Tp>(mat(0,0), mat(1,0), mat(2,0));
643 644
}    
644 645

  
645 646
    
b/opencv/modules/core/test/test_operations.cpp
73 73
    bool TestMatND();
74 74
    bool TestSparseMat();
75 75
    bool operations1();
76
    bool TestMatxMultiplication();
76 77

  
77 78
    void checkDiff(const Mat& m1, const Mat& m2, const string& s) { if (norm(m1, m2, NORM_INF) != 0) throw test_excep(s); }
78 79
    void checkDiffF(const Mat& m1, const Mat& m2, const string& s) { if (norm(m1, m2, NORM_INF) > 1e-5) throw test_excep(s); }
......
803 804
    return true;
804 805
}
805 806

  
807
bool CV_OperationsTest::TestMatxMultiplication()
808
{
809
    try
810
    {
811
        Matx33f mat(1, 0, 0, 0, 1, 0, 0, 0, 1); // Identity matrix
812
        Point2f pt(3, 4);
813
        Point3f res = mat * pt; // Correctly assumes homogeneous coordinates
814
        if(res.x != 3.0) throw test_excep();
815
        if(res.y != 4.0) throw test_excep();
816
        if(res.z != 1.0) throw test_excep();
817
    }
818
    catch(const test_excep&)
819
    {
820
        ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
821
        return false;
822
    }
823
    return true;
824
}
825

  
806 826
void CV_OperationsTest::run( int /* start_from */)
807 827
{
808 828
    if (!TestMat())
......
823 843
    if (!operations1())
824 844
        return;
825 845

  
846
    if(!TestMatxMultiplication())
847
        return;
848

  
826 849
    ts->set_failed_test_info(cvtest::TS::OK);
827 850
}
828 851

  
829
-