Ask Your Question
0

Measure Width & Height in marked position of image view using opencv in Android

asked 2017-06-29 06:26:05 -0600

kavie gravatar image

I am working on an android project using opencv.I'm following some tutorial in internet ,have done "How to capture Image using Opencv,show in ImageView,Here is the Code for that ,

https://gist.github.com/manikavi/46cb...

Next my requirement is mark width & height on Captured image and get Size of that .(Image is added here)

image description

Is it possible in opencv,If yes Can I get help to do this?

edit retag flag offensive close merge delete

Comments

Hi do u get any solution. I also facing same problem.

pritul gravatar imagepritul ( 2020-02-21 08:45:12 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-06-29 09:09:23 -0600

KjMag gravatar image

updated 2017-06-30 10:24:14 -0600

Yes, it is possible. Assuming that you have already segmented the image properly, you can fit a bounding rect to the analysed object and get its heght and width, which will be similar to the dimensions you have marked. This docs will get you started:

http://docs.opencv.org/2.4/doc/tutori...

http://docs.opencv.org/2.4/doc/tutori...

Another possibility is to find a pair of points in the segmented contour - one that has the least x coordinate and the other that has the highest x coordinate. Distance between these points if one of the dimensions you seek. Do the same for y coordinate and compare the distances to determine which is height and which is width.

You may also try fitting an ellipse to the segmented contour if all the objects are of a shape that is more or less oval. This may give better results as it's going to account for possible tilt:

http://docs.opencv.org/2.4/modules/im...

Of course these methods won't give you the exact results, but it seems to me that in this case it's not clear what an exact result is (I would say the width could be drawn in several other ways in this image unless I don't know something about the methodology) and every measurement is only an approximation and we are looking for the one that is acceptable.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-06-29 06:26:05 -0600

Seen: 1,414 times

Last updated: Jun 30 '17