I have one function for calculating the convolution (to check the settings for filter2D ), I think that the body of the function is not important, so here is just the header and end:
template<typename T> cv::Mat conv(const cv::Mat &input, const cv::Mat &kernel) { cv::Mat output(input);
At this moment, I have completely useless results in the result (this is not even random data, they have a strange pattern that repeats every time I run the function).
When I rewrite a function:
template<typename T> void conv(const cv::Mat &input, cv::Mat &output, const cv::Mat &kernel) { ... } cv::Mat result(input); conv( input, result, kernel);
Everything works fine, and the results matrix contains exactly what you need.
So my question is : what is wrong with the first approach? Am I doing something wrong? Why doesn't the operator / return from function work?
* Note: OpenCv version: extra / opencv 2.3.1_a-3 (archlinux package) *
Something similar happened to me when I downloaded external data from opencv storage and the data was lost until I used data( loaded.clone())
source share