1

I want to process a video using opencv and c++ and the speed of execution really matters. But I saw something that might be a problem, for example canny function for C++ is defined as

void Canny(InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false )

and the equivalent in C is defined as

void cvCanny(const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size=3 )

Obviously, if I use C++, the passed to the function image will be copied every time, that makes at least 24 copies per second since I don't use only that function. If I use C function, I will not run into that problem, because no copies will be made. Is there a way to combine for example IplImage and Mat and how much will it cost me when I cast IplImage to Mat after that? And generally, will it be a good idea to use IplImage ?

2
  • 1
    Obviously, if I use C++, the passed to the function image will be copied every time. Doesn't seem obvious if you read the documentation Commented May 11, 2018 at 20:34
  • I have missed that, thank you ! Commented May 11, 2018 at 20:38

1 Answer 1

4

You might be misinterpreting what the C++ code does. If you take a look at the documentation

You will see that InputArray is a const&

typedef const _InputArray& InputArray;

where InputArray is a class that can be constructed from Mat, Mat_<T>, Matx<T, m, n>, std::vector<T>, std::vector<std::vector<T> >, std::vector<Mat>, std::vector<Mat<T> >, UMat, std::vector<UMat> or double. It can also be constructed from a matrix expression.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.