在opencv中使用未初始化的值

时间:2016-05-09 14:10:01

标签: c++ opencv valgrind

HY, 在进行一些重构时,我最近在我的程序中遇到了一个错误。用valgrind分析时

valgrind --leak-check=yes --track-origins=yes release/executable -c config.file 2> leakcheck

我得到以下输出:

==16265== Use of uninitialised value of size 8
==16265==    at 0x4F7F090: cv::CvtColorLoop_Invoker<cv::RGB2Gray<unsigned char> >::operator()(cv::Range const&) const (in /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8)
==16265==    by 0x56B808F: ??? (in /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.8)
==16265==    by 0x7293B39: ??? (in /usr/lib/libtbb.so.2)
==16265==    by 0x7291F8F: ??? (in /usr/lib/libtbb.so.2)
==16265==    by 0x56B8360: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.8)
==16265==    by 0x4F88ADB: void cv::CvtColorLoop<cv::RGB2Gray<unsigned char> >(cv::Mat const&, cv::Mat&, cv::RGB2Gray<unsigned char> const&) (in /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8)
==16265==    by 0x4F9601D: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.8)
==16265==    by 0x42A75E: main (main.cpp:104)
==16265==  Uninitialised value was created by a stack allocation
==16265==    at 0xA00D312: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.54.35.0)

即使我将代码缩减为以下最小示例,问题仍然存在:

VideoCapture cap = VideoCapture("../../testdata/synthetic/simple/output/Camera.avi");
Mat frame;
cap >> frame;
cv::cvtColor(frame, frame, CV_RGB2GRAY);
imshow("test", frame);
waitKey(0);

知道可能导致这种情况的原因或我如何解决这个问题? 感谢。

0 个答案:

没有答案