#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
int main(int argc, char** argv) {
cv::Mat img = cv::imread("photo.jpg");
cv::imshow("image", img);
cv::waitKey();
return 0;
}
…我在linux上编译它,GCC7.2.0与OpenCV3.2.0(UbuntuRepository版本)的对比如下:
$ g++ -c -o example_opencv.o example_opencv.cpp
$ g++ -o example_opencv example_opencv.o -lopencv_core -lopencv_imgcodecs -lopencv_highgui
疯狂的
Valgrind检查时的错误数量:
$ valgrind ./example_opencv
(... lengthy error report ...)
==14665== LEAK SUMMARY:
==14665== definitely lost: 34,152 bytes in 434 blocks
==14665== indirectly lost: 0 bytes in 0 blocks
==14665== possibly lost: 1,024 bytes in 14 blocks
==14665== still reachable: 64,144 bytes in 1,328 blocks
==14665== suppressed: 0 bytes in 0 blocks
==14665== Rerun with --leak-check=full to see details of leaked memory
==14665==
==14665== For counts of detected and suppressed errors, rerun with: -v
==14665== Use --track-origins=yes to see where uninitialised values come from
==14665== ERROR SUMMARY: 105422 errors from 1000 contexts (suppressed: 0 from 0)
如果我对一个有真正内存相关错误的程序使用相同的方法,它的错误将在这个混乱中完全丢失。
有没有可能使用Valgrind调试OpenCV程序?