如何关闭相机(OpenCv Beaglebone)
How to close camera (OpenCv Beaglebone)
大家好,
我正试图找出如何关闭相机上的小猎犬在openCV。我尝试了许多命令,如释放(&camera),但没有一个存在,当我不希望它时,相机继续保持打开。
VideoCapture capture(0);
capture.set(CV_CAP_PROP_FRAME_WIDTH,320);
capture.set(CV_CAP_PROP_FRAME_HEIGHT,240);
if(!capture.isOpened()){
cout << "Failed to connect to the camera." << endl;
}
Mat frame, edges, cont;
while(1){
cout<<sending<<endl;
if(sending){
for(int i=0; i<frames; i++){
capture >> frame;
if(frame.empty()){
cout << "Failed to capture an image" << endl;
return 0;
}
cvtColor(frame, edges, CV_BGR2GRAY);
代码是这样的,在for循环结束时,我想关闭相机,但它仍然是打开的
摄像机将在videoccapture析构函数中自动取消初始化。
查看opencv docu:
int main(int, char**)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat edges;
namedWindow("edges",1);
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
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;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
也cvQueryFrame
从相机或文件中抓取并返回一个帧
IplImage* cvQueryFrame(CvCapture* capture);
捕获视频捕获结构。
cvQueryFrame函数从相机或视频文件中获取帧,解压缩和>返回它。这个函数只是cvGrabFrame和cvRetrieveFrame在一个>呼叫返回的图像不允许用户发布或修改。
也可以查看:http://derekmolloy.ie/beaglebone/beaglebone-video-capture-and-image-processing-on-embedded-linux-using-opencv/
我希望这对你有用。祝你好运。
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将OpenCV C++重写为EmguCV C#-如何使用指针
- OpenCV C++.快速计算混淆矩阵
- 在C++代码中包含opencv时,使用ctypes创建.so文件
- 哪些库可以通过Opencv调整曝光率
- 安装opencv失败-粘贴CMakeError.log的内容
- C++中的openCV Mat访问冲突
- OpenCV Android C++ imwrite not found
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 将 OpenCV 与 CMAKE 中的项目一起构建为第三方库的正确方法
- 为beaglebone black交叉编译c++openCV应用程序时出现问题
- 无法从 beaglebone 运行 OpenCV 代码
- 无法在 beagleBone Black 中运行 OpenCV 示例
- Beaglebone上的OpenCV编译错误
- OpenCV无法识别BeagleBone中的相机
- 如何关闭相机(OpenCv Beaglebone)