Is it possible to use the same variable as input and output in C ++ OpenCV?

Many OpenCV features are defined as

function(InputArray src, OutputArray dst, otherargs..)

So, if I want to process and overwrite the same image, can I do this:

function(myImg, myImg);

Is it safe to do this?

thanks

Edit:

I ask for standard features in OpenCV, such as threshold, bluretc. So I think they should have been implemented accordingly, right?

+4
source share
2 answers

Yes, it is safe in OpenCV.


Inside, a function like:

void somefunction(InputArray _src, OutputArray _dst);

will do something like:

Mat src = _src.getMat();
_dst.create( src.size(), src.type() );
Mat dst = _dst.getMat();

// dst filled with values

So, if srcand dst:

  • , create , . clone src , (, findConturs OpenCV > 3.2), .
  • create dst src.

, .

findContours, src. , src.clone() , , , .

OpenCV 3.2, findContours .


+6

EDIT: , , , . , - .


++, , . , .

, , .

, . , , , . (, ). , , .

, .

+2

Source: https://habr.com/ru/post/1610461/


All Articles