Ask Your Question
0

Finding the max and min x,y location of a mask

asked 2018-03-13 23:30:11 -0600

changsheng1239 gravatar image

After performing watershed algorithm, it returned me a marker like this (not the rectangle). Right now, I want to find the max,min coordinate of the object boundary (not the rectangle). Is there any method that is capable of doing this without slowing down the system too much? The objective is to resize the rectangle dynamically to improve tracking. This is a real time object tracking + object segmentation so performance is a thing.

Any help is greatly appreciated !

image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-03-14 03:41:00 -0600

VxW gravatar image

Hi,

you can calculate the extreme points of the contour.

leftmost = tuple(cnt[cnt[:,:,0].argmin()][0])
rightmost = tuple(cnt[cnt[:,:,0].argmax()][0])
topmost = tuple(cnt[cnt[:,:,1].argmin()][0])
bottommost = tuple(cnt[cnt[:,:,1].argmax()][0])

See OpenCV documentation

edit flag offensive delete link more

Comments

thanks for your reply but unfortunately currently i am working on android which is java. So python solution is not really workable

changsheng1239 gravatar imagechangsheng1239 ( 2018-03-14 09:01:02 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-03-13 23:30:11 -0600

Seen: 2,056 times

Last updated: Mar 14 '18