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 ImageView and i want to be able to select 6 points (3 source and 3 target) and use the warpAffine method on OpenCV like the example before. I'm able to reproduce the example above, but when passing the X,Y coordinates from onTouch event, it doesn't give me what i expect. I think the problem is how to convert the android touch coordinates to OpenCV Mat column/row. Maybe i need to display the image on OpenCV surface? I hope i was clear, Thanks in advance.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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;