android - Using OpenCV4Android, how to create an ROI (Region-Of-Interest or a submat) from a contour? -
given image mat, , contour (which matofpoint) in it, how can create roi (region of interest)/submat?
i can see 3 interesting methods on docs of mat,
mat submat(int rowstart, int rowend, int colstart, int colend) extracts rectangular submatrix.
mat submat(range rowrange, range colrange) extracts rectangular submatrix.
mat submat(rect roi) extracts rectangular submatrix.
- is there way find out
rowstart,rowend,colstart,colendcontour?
or
- is there way
rowrange,colrangecontour?
or
- can make
rectcontour?
use imgproc.boundingrect(matofpoint contour) method. way can use third of submat() methods have listed:
rect roirect = imgproc.boundingrect(contour); mat roisubmat = originalmat.submat(roirect); roisubmat region of interest (stored in mat).
Comments
Post a Comment