Ask Your Question
0

Copy one OutputArrayOfArrays object to another

asked 2019-04-04 01:37:36 -0600

ansh gravatar image

updated 2019-04-04 01:41:21 -0600

I want to copy one OutputArrayOfArrays object to another. Something like this:

void function(OutputArrayOfArrays contour){ 
std::vector<std::vector<cv::Point>> contours; 
OutputArrayOfArrays _contour(contours);

....Doing something....

contour = _contour; 
}

But I'm getting following error:

no viable overloaded '='
    contour = _contour;
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-04-04 05:30:03 -0600

HYPEREGO gravatar image

updated 2019-04-04 05:57:49 -0600

OutputArrayOfArrays is a wrapper class, I suggest you to take a look in the OpenCV Styling Guide and also check the source code of functions that use this wrapper because at first may can be tricky but at the end is really good. Take into account that wrapper have complexity O(1), so they are nice to be used, but not mandatory.

Also, some users are experiencing problem using them, like here.

If you are writing code for yourself and not something that will be pushed in the official OpenCV repository, I think that you can avoid the use of wrapper classes. I personally only use InputArray and OutputArray, while when I've array I use simply the std::vector. That's because, if you want to write template function it will be more intuitive.

In your case, I personally do the following:

template<typename T>
void function( std::vector<std::vector<cv::Point_<T>>>& _contours)

So in that case, you can use the kind of point that you want, floating, int or double points coordinates, without care about the re-implementation.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-04-04 01:37:36 -0600

Seen: 505 times

Last updated: Apr 04 '19