How to convert android touch coordinates to OpenCV image cordinates?

后端 未结 1 1770
情深已故
情深已故 2021-01-16 03:47

I am trying to do something simillar to this, but on Android: http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html I have an image drawn to Ima

1条回答
  •  情话喂你
    2021-01-16 04:10

    The touch coordinate refer to a point that belongs to your Android's screen resolution (Samsung Galaxy S3 is 720x1280). On the other hand, the OpenCV image could be larger or smaller than that, meaning that a touch coordinate can't be mapped directly into an image coordinate.

    What needs to be done to convert from one resolution to the other, is the normalization of the touch coordinate from 720x1280 to the 640x480 range. Therefore, to find the real coordinates on the image you would do:

    real_x = (touch_x * 640) / 720;
    real_y = (touch_y * 480) / 1280;
    

    0 讨论(0)
提交回复
热议问题