Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CH8 编译运行时候出错,对应书中210页实践LK光流。详细见下 #57

Closed
SangTaoQAQ opened this issue Dec 13, 2019 · 2 comments

Comments

@SangTaoQAQ
Copy link

(1)使用pkg-config --modversion opencv 查看opencv版本:
3.1.0
(2)cmake..后正常
(3)make后出现下述问题:猜想有可能是OpenCV版本问题,望高博解答如何修改该函数的初始化。
/home/sangtao/Desktop/ch8/optical_flow.cpp: In function ‘void OpticalFlowSingleLevel(const cv::Mat&, const cv::Mat&, const std::vectorcv::KeyPoint&, std::vectorcv::KeyPoint&, std::vector&, bool, bool)’:
/home/sangtao/Desktop/ch8/optical_flow.cpp:188:28: error: invalid initialization of reference of type ‘const cv::ParallelLoopBody&’ from expression of type ‘std::_Bind_helper<false, void (OpticalFlowTracker::)(const cv::Range&), OpticalFlowTracker, const std::_Placeholder<1>&>::type {aka std::_Bind<void (OpticalFlowTracker::(OpticalFlowTracker, std::Placeholder<1>))(const cv::Range&)>}’
std::bind(&OpticalFlowTracker::calculateOpticalFlow, &tracker, placeholders::1));
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/opencv2/core.hpp:3165:0,
from /usr/local/include/opencv2/opencv.hpp:46,
from /home/sangtao/Desktop/ch8/optical_flow.cpp:5:
/usr/local/include/opencv2/core/utility.hpp:356:17: note: in passing argument 2 of ‘void cv::parallel_for
(const cv::Range&, const cv::ParallelLoopBody&, double)’
CV_EXPORTS void parallel_for
(const Range& range, const ParallelLoopBody& body, double nstripes=-1.);
^~~~~~~~~~~~~
CMakeFiles/optical_flow.dir/build.make:62: recipe for target 'CMakeFiles/optical_flow.dir/optical_flow.cpp.o' failed
make[2]: *** [CMakeFiles/optical_flow.dir/optical_flow.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/optical_flow.dir/all' failed
make[1]: *** [CMakeFiles/optical_flow.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

@gaoxiang12
Copy link
Owner

parallel_for需要opencv 4以上,写书的时候忘提这件事了,后来在勘误里加上了。
可以自己安装opencv 4,或者自行改写下parallel_for函数。

@SangTaoQAQ
Copy link
Author

谢谢~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants