opencv实践程序3——打开摄像头视频及轮廓检测的简单程序
2014-04-03 09:36
621 查看
经过不断的测试终于试验好了 #include <iostream> #include <cv.h> #include <highgui.h> using namespace std; using namespace cv; int main( int argc, char** argv ) { VideoCapture cap(0); //打开默认的摄像头号 Mat edges; namedWindow("edges",1); //边缘的窗口 namedWindow("video",1); //正常摄像头视频 int num = 0; cap.open(num); for(;;) //也可换为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); if(waitKey(30) >= 0) break; } return 0; } 最简单的打开摄像头视频程序 #include <iostream> #include <cv.h> #include <highgui.h> using namespace std; using namespace cv; int main( int argc, char** argv ) { VideoCapture cap(0); cap.open(0); // namedWindow("edges",1); while(1) { Mat frame; cap >> frame; if ( !frame.empty() ) imshow("Video", frame); if(waitKey(30) >= 0) break; } cap.release(); return 0; }
简单视频
#include "cv.h" #include "highgui.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <math.h> #include <float.h> #include <limits.h> #include <time.h> #include <ctype.h> int main() { cv::VideoCapture capture("1.mp4");//dssssssssssss if(!capture.isOpened()) return 1; bool stop(false); cv::Mat frame; cv::namedWindow("extracted"); while(!stop) { if(!capture.read(frame)) break; cv::imshow("extracted frame",frame); if(cv::waitKey(10)>0) stop=true; } capture.release(); }
感谢这位朋友给出了起步代码:http://blog.csdn.net/BrikOff/article/details/21243491
相关文章推荐
- 用 OpenCV 编写一个简单的摄像头视频监控程序
- 用 OpenCV 编写一个简单的摄像头视频监控程序
- opencv程序十五:实时视频轮廓检测
- opencv打开摄像头获取视频程序
- OpenCV 实践程序12——用分类器对视频进行人脸检测
- opencv实践程序4——canny实现摄像头的边缘检测,高斯背景建模
- OpenCv打开摄像头,显示图像,保存视频
- 一个简单的摄像头视频浏览和捕获的程序
- opencv程序五:轮廓检测
- python+opencv打开摄像头,保存视频、拍照功能的实现
- OpenCV学习之寻找轮廓实现视频流的运动目标检测
- 第一个Opencv 程序 对 摄像头视频流 取反
- 一个简单的摄像头视频浏览和捕获的程序
- 最简单的ADABOOST人脸检测程序。COPY执行,前提是你配置OpenCV周围环境
- opencv学习(七)(opencv3.0.0+VS2012+win7)打开摄像头并且进行边缘检测加上了滑动条
- 一个简单的Opencv视频程序
- 使用Opencv进行轮廓检测,字符提取,简单的直方图字符识别!
- opencv 打开摄像头并将视频数据写入文件
- 关于tiny4412自写qt4程序打开摄像头的实践手记
- OpenCV打开摄像头并获取实时视频图像代码