I try to convert my C++ code, based on OpenCV 4, for use in Python programs. I have read
and
but, when extending C++ functions using CV_EXPORTS_W macro and others, I’ve seen in example, in arguments sometimes we stay cv::Mat, sometimes change it for InputArray or OutputArray. What is the rule?
IMHO Inputarray or outputarray are generic types ( proxy class ). If your algorithm always uses Mat you don’t need it.
Opencv mainteners like InputArray outputArray in opencv pull request (not opencv_contrib)
Essentially the bindings generator needs to know if the argument is an input, output or inputoutput array when it generates the bindings. This is so the arguments can be placed correctly in the python call. From memory it goes something like
CV_EXPORTS_W void python_func(InputArray in, OutputArray out, _InputOutputArray inout)
out,inout= python_func(in,[inout])
If you had a function where “out” can only be a Mat then you would use
CV_EXPORTS_W void python_func(InputArray in, CV_OUT Mat out, InputOutputArray inout)