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.

  1. is there way find out rowstart, rowend, colstart , colend contour?

or

  1. is there way rowrange , colrange contour?

or

  1. can make rect contour?

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

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -