There is zero picture coordinate in OpenCV notation.

asked 2020-02-27 06:40:48 -0600

Pavel gravatar image

Hi guys, I need to know there is (0,0) point physicaly on image. There are two options: OpenGL (0,0) - is upper left corner of the first pixel naive (0,0) - is center of the first pixel

This should affect on many function in lib. For example if we have perfect centered camera matrix for first notation center pose will be (W/2, H/2), for second It will be (W/2 - 0.5, H/2 - 0.5). This also affect on such function like wrapPerspective etc.

Thanks

edit retag flag offensive close merge delete

Comments

I looked in getDefaultNewCameraMatrix, and it seems that second option is right one, this function sets [(width - 1) *0.5, (height - 1)*0.5 ], as default [cx, cy]. this led to [0,0] = center of first(most left, most upper) image pixel.

I aslo made such test.

  cv::Mat image_test(cv::Size(4,4), CV_8U);
    cv::Mat dst_;
    image_test = 0;
    image_test.at<uchar>(0,0) = 255;
    float32_t alpha = 20.f/M_PI;

    cv::Matx33f affine ={cos(alpha),sin(alpha),0,
                         -sin(alpha),cos(alpha),0,
                                            0,0,1};

    cv::warpPerspective(image_test, dst_, affine,image_test.size(), 1, BORDER_CONSTANT, cv::Scalar(0,0,0) );
std::cout << "Image pixel value " << (float)dst_.at<uint8_t>(0,0) << "\n";

Output:

Image pixel value 255
Pavel gravatar imagePavel ( 2020-02-27 07:04:32 -0600 )edit