OpenCV KeyPoint: information about angle and octave

前端 未结 5 1028
时光说笑
时光说笑 2021-02-09 08:31

I want to know more about KeyPoints, so can anyone told me what are


KeyPoint::angle

In OpenCV docs was mentioned that angle is computed orientation of the

5条回答
  •  日久生厌
    2021-02-09 08:58

    Even though I know conceptual about the angle and octave, I wonder what the float angle mean, so I look in the source code of OpenCV2.3.1
    in sift.cpp

    inline KeyPoint featureToKeyPoint( const feature& feat )
    {
        float size = (float)(feat.scl * SIFT::DescriptorParams::GET_DEFAULT_MAGNIFICATION() * 4); // 4==NBP
        float angle = (float)(feat.ori * a_180divPI);
        return KeyPoint( (float)feat.x, (float)feat.y, size, angle, feat.response, feat.feature_data->octv, feat.class_id );
    }
    

    ok, I get the angle definition, but what is feat.ori and a_180divPI
    the latter is easy to find

    const double a_180divPI = 180./CV_PI;
    

    the former needs some effort, after look through several methods, I get

    struct feature
    {
        double x;                      /**< x coord */
        double y;                      /**< y coord */
    
        double scl;                    /**< scale of a Lowe-style feature */
        double ori;                    /**< orientation of a Lowe-style feature */
    
        ...
    };
    

    and the feat.ori is computed through several steps according to Lowe's Paper ( http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf ), including calculate ori_hist, smooth the histogram and add_good_ori_feature.
    I am not 100% sure about the exactly meaning of the ori, but I strongly doubt that OpenCV have turned the ori to an proper arc representation, and the final result angle is the normal meaning angel range from -180 degree to 180 degree. The evidences are

    1) ori = arctan2( dy, dx)
    2) bin = cvRound( n * ( ori * CV_PI ) / PI_2 )
    3) new_feat->ori = ( ( PI2 * bin ) / n ) - CV_PI; 
    

    hope help you

提交回复
热议问题