The landscape I use myImageView.setImageBitmap(myBitmap)and use a listener ontouchfor getXand getYand tune to the location myImageView(the same as getRawXand getRawY). Then I use bitmapToMatto create MAT for image processing using OpenCV. I found two resizing scenarios in which the location ontouchwould draw a circle exactly where I touched, but from time to time the location would be outside the Mat and cause NPE and fail during processing.
Scenario 1: resize(myImageView.getWidth(), myImageView.getHeight())
Scenario 2: resize(myImageView.getHeight(), myImageView.getWidth())and
x = x(myImage.getHeight()/myImageView.getWidth())
y = y(myImage.getWidth()/myImageView.getHeight())
If I don't change x, y, I can click throughout the image without NPE, but the circle was nowhere near where I touched.
After processing I matToBitmap(myMAT, newBitmap)and myImageView.setImageBitmap(newBitmap).
I am clearly missing something, but is there an easy way to get the contact location and use it in MAT? Any help would be awesome!
source
share