how to compile forEach doc example?
Hi,
I want to try forEach method. I can compile and execute example using C++11 lambda. NowI want to try example given in doc. It is more readable than C++11 lambda I cannot compile this example :
Mat image(1920, 1080, CV_8UC3);
typedef cv::Point3_<uint8_t> Pixel;
// Parallel execution with function object.
struct Operator {
void operator ()(Pixel &pixel, const int * position) {
pixel.x = 255;
}
};
image.forEach<Pixel>(Operator());
error message (windows 10 gcc version 6.2.0 (x86_64-posix-sjlj-rev1, Built by MinGW-W64 project)):
[In file included from F:/lib/opencv/modules/core/include/opencv2/core.hpp:3197:0,
from F:/lib/opencv/modules/imgproc/include/opencv2/imgproc.hpp:46,
from F:/lib/opencv/modules/imgproc/include/opencv2/imgproc/imgproc.hpp:48,
fromch3ex1/main.cpp:1:
F:/lib/opencv/modules/core/include/opencv2/core/utility.hpp: In instantiation of 'void cv::Mat::forEach_impl(const Functor&) [with _Tp = cv::Point3_<unsigned char>; Functor = main(int, char**)::Operator]':
F:/lib/opencv/modules/core/include/opencv2/core/mat.inl.hpp:1067:5: required from 'void cv::Mat::forEach(const Functor&) [with _Tp = cv::Point3_<unsigned char>; Functor = main(int, char**)::Operator]'
ch3ex1/main.cpp:80:36: required from here
F:/lib/opencv/modules/core/include/opencv2/core/utility.hpp:484:18: error: no match for call to '(const main(int, char**)::Operator) (cv::Point3_<unsigned char>&, int*)'
operation(*reinterpret_cast<_Tp*>(0), reinterpret_cast<int*>(0));
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ch3ex1/main.cpp:76:14: note: candidate: void main(int, char**)::Operator::operator()(Pixel&, const int*) <near match>
void operator ()(Pixel &pixel, const int * position) {
^~~~~~~~
ch3ex1/main.cpp:76:14: note: passing 'const main(int, char**)::Operator*' as 'this' argument discards qualifiers
In file included from F:/lib/opencv/modules/core/include/opencv2/core.hpp:3197:0,
from F:/lib/opencv/modules/imgproc/include/opencv2/imgproc.hpp:46,
from F:/lib/opencv/modules/imgproc/include/opencv2/imgproc/imgproc.hpp:48,
from ch3ex1/main.cpp:1:
F:/lib/opencv/modules/core/include/opencv2/core/utility.hpp:497:9: warning: 'cv::Mat::forEach_impl(const Functor&)::PixelOperationWrapper::PixelOperationWrapper(cv::Mat_<_Tp>*, const Functor&) [with _Tp = cv::Point3_<unsigned char>; Functor = main(int, char**)::Operator]' used but never defined
PixelOperationWrapper(Mat_<_Tp>* const frame, const Functor& _operation)
^~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/ch3ex1.dir/build.make:64: CMakeFiles/ch3ex1.dir/main.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/ch3ex1.dir/all] Error 2
make: *** [Makefile:84: all] Error 2