我已经运行了sample code:
#include "cv.h"
#include "highgui.h"
using namespace cv;
int main(int, char**)
{
VideoCapture cap(0);
if(!cap.isOpened()) return -1;
Mat frame, edges;
namedWindow("edges",1);
for(;;)
{
cap >> frame;
cvtColor(frame, edges, CV_BGR2GRAY);
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
Canny(edges, edges, 0, 30, 3);
imshow("edges", edges);
if(waitKey(30) >= 0) break;
}
return 0;
}
它工作正常,但在应用程序关闭后,相机仍然有效。我知道这一点,因为闪存导致一直持续到我杀死HPMediaSmartWebcam.exe进程。
使用完VideoCapture
后如何关闭相机?
答案 0 :(得分:0)
根据文档... here,相机将在类析构函数中自动取消初始化...析构函数调用虚函数cv::VideoCapture.release(
)...运行相机以获得固定数字框架,然后看看网络摄像头的LED是否熄灭..
int frames = 0;
while(frames!=1000)
{
//do frame capture from webcam and image processing...
++frames;
}