opencv实践程序4——canny实现摄像头的边缘检测,高斯背景建模
2014-04-04 16:36
686 查看
/* //原摄像头视频,轮廓,高斯模型 #include <iostream> #include <cv.h> #include <highgui.h> #include"cvaux.h" using namespace std; using namespace cv; int main( int argc, char** argv ) { VideoCapture cap(0); //打开默认的摄像头号 Mat edges,fore; namedWindow("edges",1); //边缘的窗口 int num = 0; cap.open(num); BackgroundSubtractorMOG mog; while(1) { Mat frame; cap >> frame; // 从摄像头中获取新的一帧 if ( !frame.empty() ) imshow("Video", 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); mog(frame,fore,0.01);//封信背景并返回前景 threshold(fore,fore,128,255,THRESH_BINARY_INV);//对图像取反 //imshow("原视频", frame); imshow("提取的前景", fore); if(waitKey(30) >= 0) break; } cap.release(); return 0; }*/
//教材上混合高斯算法 #include <iostream> #include <cv.h> #include <highgui.h> #include "cvaux.h" using namespace std; using namespace cv; int main( int argc, char** argv ) { VideoCapture cap(0); Mat frame,foreground; //前景图像 //namedWindow("video",1); namedWindow("提取的前景",1); //int num = 0; // cap.open(num); BackgroundSubtractorMOG mog; bool stop(false); while(!stop) { // Mat frame; if(!cap.read(frame))break; mog(frame,foreground,0.01);//封信背景并返回前景 threshold(foreground,foreground,128,255,THRESH_BINARY_INV);//对图像取反 imshow("原视频", frame); imshow("提取的前景", foreground); if(waitKey(10) >= 0) stop=true; } //cap.release(); return 0; }
相关文章推荐
- 运动目标的背景建模-混合高斯背景建模和KNN模型建模的OpenCV代码实现
- Canny边缘检测原理及C#程序实现
- opencv程序三:canny边缘检测算法
- opencv读图像C语言实现canny边缘检测
- 混合高斯背景建模的示例程序(VC6.0 + OpenCv 1.0)
- OpenCV-边缘检测算子Canny实现
- opencv2通过使用canny边缘检测使摄像头内的环境边缘化
- OpenCV 摄像头Canny边缘检测 (python)
- opencv实践程序3——打开摄像头视频及轮廓检测的简单程序
- OpenCV,三大边缘检测Canny,Sobel,Laplacian,及MFC实现
- linux+Qt+Opencv实现采集摄像头采集,截图,边缘检测,霍夫变换
- 基于OPENCV的CANNY边缘检测算子详细代码实现
- OpenCV高斯差分技术实现图像边缘检测
- Opencv实现图片素描风(调用摄像头+中值滤波+拉普拉斯边缘检测)
- Canny边缘检测原理及C#程序实现
- OpenCV: Canny边缘检测算法原理及其VC实现详解(转载)
- OpenCV: Canny边缘检测算法原理及其VC实现详解
- OpenCV成长之路1:将canny边缘检测应用于视频的程序
- 高斯背景建模程序分析(OpenCV)--转自 yimi (网易博客) .
- OpenCV 实现canny边缘检测