Can any body tell me how to intialize MatOfRect object with MatOfRect Constructor taking Mat object as a parameter?

asked 2016-04-19 00:19:20 -0500

Sandesh14 gravatar image

updated 2016-04-19 00:59:13 -0500

berak gravatar image

I want to store Mat object values in Rect object. To do that I tried to create MatOfRect object with Mat Object values. But it throws an Exception saying Incompatible Mat and then app stops. Can anybody help me to solve this?What am I doing wrong?

edit retag flag offensive close merge delete


"I want to store Mat object values in Rect object." -- wait, this is not possible.

do you want to store submat's somehow ? then use a list or vector of Mat's.

berak gravatar imageberak ( 2016-04-19 00:58:09 -0500 )edit

Can I use Converters class methods for what you have told? What does the following method does public static void Mat_to_vector_Rect(Mat m, java.util.List<rect> rs)? Could you also explain me about the second argument in this method?

Sandesh14 gravatar imageSandesh14 ( 2016-04-19 01:50:08 -0500 )edit
  • do you understand the difference between a Rect and an image ?
  • the converter function converts a MatOfRect into a List of Rects (this just changes the container, not the content)
berak gravatar imageberak ( 2016-04-19 01:55:34 -0500 )edit

Ya I do understand the difference. What I wanted to do is Detected rectangular region coordinates of an image to be stored in Rect.

Sandesh14 gravatar imageSandesh14 ( 2016-04-19 02:19:48 -0500 )edit

oh, ok. then i partly misread your post, apologies.

berak gravatar imageberak ( 2016-04-19 02:43:13 -0500 )edit

When I used cascade classifier it directly stored coordinates in Rect object. I tried template matching there it directly stores the matched template region to another Mat object. But I want those coordinates for further detection of object in this area of interest. So do you know any way I can do this?

Sandesh14 gravatar imageSandesh14 ( 2016-04-19 03:05:26 -0500 )edit