OpenCV 例程
采集图片显示视频:
- #include <iostream>
- #include <opencv2/opencv.hpp>
- using namespace std;
- using namespace cv;
- int main ()
- {
- CvCapture *cap = cvCaptureFromCAM(); //CvCapture* capture = cvCaptureFromAVI("infile.avi");
- IplImage* img;
- cvNamedWindow("showImg");
- while()
- {
- img = cvQueryFrame(cap);
- if (!img)
- break;
- cvShowImage("showImg", img);
- char key = cvWaitKey();
- if (key == )
- break;
- }
- cvDestroyWindow("showImg");
- cvReleaseCapture(&cap);
- return ;
- }
按s键将图片存储到目录e:/src/cam/下
- #include <iostream>
- #include <opencv2/opencv.hpp>
- using namespace std;
- using namespace cv;
- char path[];
- int main ()
- {
- char num[] = {};
- int i = ;
- CvCapture *cap = cvCaptureFromCAM();
- IplImage* img;
- cvNamedWindow("showImg");
- while()
- {
- img = cvQueryFrame(cap);
- if (!img)
- break;
- cvShowImage("showImg", img);
- char key = cvWaitKey();
- if (key == )
- break;
- if (key == 's')
- {
- itoa(i++, num, );
- strcpy(path, "e:/src/cam/img_");
- strcat(path,num);
- strcat(path, ".bmp");
- cvSaveImage(path, img);
- cout<< path <<endl;
- }
- }
- cvDestroyWindow("showImg");
- cvReleaseCapture(&cap);
- return ;
- }
OpenCV 例程的更多相关文章
- 【双目备课】OpenCV例程_stereo_calib.cpp解析
stereo_calib是OpenCV官方代码中提供的最正统的双目demo,无论数据集还是代码都有很好实现. 一.代码效果: 相关的内容包括28张图片,1个xml和stereo_calib.cpp的代 ...
- OpenCV例程实现人脸检测
前段时间看的OpenCV,其实有很多的例子程序,参考代码值得我们学习,对图像特征提取三大法宝:HOG特征,LBP特征,Haar特征有一定了解后. 对本文中的例子程序刚开始没有调通,今晚上调通了,试了试 ...
- common.py OpenCv例程阅读
#!/usr/bin/env python ''' This module contais some common routines used by other samples. ''' import ...
- camshift.py OpenCv例程阅读
源码在这 #!/usr/bin/env python ''' Camshift tracker ================ This is a demo that shows mean-shif ...
- video.py OpenCv例程阅读
#!/usr/bin/env python ''' Video capture sample. Sample shows how VideoCapture class can be used to a ...
- OpenCV示例学习笔记(1)-contours2.cpp-通过findContours 函数实现轮廓提取
这个系列的目的是通过对OpenCV示例,进一步了解OpenCV函数的使用,不涉及具体原理. 示例代码地址:http://docs.opencv.org/3.0.0/examples.html(安装op ...
- OpenCV 之 图像分割 (一)
1 基于阈值 1.1 基本原理 灰度阈值化,是最简单也是速度最快的一种图像分割方法,广泛应用在硬件图像处理领域 (例如,基于 FPGA 的实时图像处理). 假设输入图像为 f,输出图像为 g,则经 ...
- OpenCV角点检测源代码分析(Harris和ShiTomasi角点)
OpenCV中常用的角点检测为Harris角点和ShiTomasi角点. 以OpenCV源代码文件 .\opencv\sources\samples\cpp\tutorial_code\Trackin ...
- 【opencv基础】detectmultiscale函数详解
前言 简单的人脸检测程序可以直接基于opencv的函数库进行实现,本文介绍一下detectMultiScale函数. 函数简介 opencv2人脸检测使用的是detectMultiScale函数,可以 ...
随机推荐
- postgresql backup
#!/bin/sh # Database backup script # Backup use postgres pg_dump command: # pg_dump -U <user> ...
- c++ string类基本使用
初始化用法 #include <iostream> #include "string" using namespace std; void main() { strin ...
- 15、Spring Boot 2.x 集成 Swagger UI
1.15.Spring Boot 2.x 集成 Swagger UI 完整源码: Spring-Boot-Demos 1.15.1 pom文件添加swagger包 <swagger2.versi ...
- Strategic game POJ - 1463 【最小点覆盖集】
Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solu ...
- deferred.pipe([doneFilter],[failFilter],[progressFilter])
deferred.pipe([doneFilter],[failFilter],[progressFilter]) 概述 筛选器和/或链Deferreds的实用程序方法. deferred.pipe( ...
- MySQL Data Directory -- Creating file-per-table tablespaces outside the data directory
Creating file-per-table tablespaces outside the data directory 一. Data Directory 1.应对情况 当数据库所在空间不足的时 ...
- Active Directory 常用属性
1.获取DirectoryEntry string str = string.Empty; string strPath = @LDAP://testDomain.com.mo; string ad ...
- PHP基础--traits的应用
Traits 在PHP中实现在方法的重复使用:Traits与Class相似,但是它能够在Class中使用自己的方法而不用继承: Traits在Class中优先于原Class中的方法,引用PHP Doc ...
- E.Substring Reverse Gym - 101755E
Substring Reverse Problem Two strings s and t of the same length are given. Determine whether it is ...
- ERROR 1010 (HY000): Error dropping database (can't rmdir './zabbix/', errno: 17)
在删除数据库的时候报标题所示错误 mysql> drop database zabbix; ERROR 1010 (HY000): Error dropping database (can't ...