Ask Your Question

Revision history [back]

Probably the line video_cap.set(CV_CAP_PROP_FOCUS, 14); inside the loop cause the memory leak, you need to set the capture property only at once like,

cv::Mat img;
cv::VideoCapture video_cap(0);
video_cap.set(CV_CAP_PROP_FOCUS, 14);
for(int i = 0; i < 1000; ++i)
{

    video_cap >> img;
    cv::imshow("image",img);
    cv::waitKey(10);
}

Probably the line video_cap.set(CV_CAP_PROP_FOCUS, 14); inside the loop cause the memory leak, you need to set the capture property only at once like,

cv::Mat img;
cv::VideoCapture video_cap(0);
video_cap.set(CV_CAP_PROP_FOCUS, 14);
 for(int i = 0; i < 1000; ++i)
{
     video_cap >> img;
    cv::imshow("image",img);
    cv::waitKey(10);
}

Probably the line video_cap.set(CV_CAP_PROP_FOCUS, 14);14) inside the loop cause the memory leak, here you need to set the capture property only at once like,

cv::Mat img;
cv::VideoCapture video_cap(0);
video_cap.set(CV_CAP_PROP_FOCUS, 14);

for(int i = 0; i < 1000; ++i)
{
    video_cap >> img;
    cv::imshow("image",img);
    cv::waitKey(10);
}