opencv 摄像头录取视频保存图像
来源:互联网 发布:华晨宇 知乎 编辑:程序博客网 时间:2024/04/28 09:00
1,API
CvVideoWriter* cvCreateVideoWriter(const char* filename, int fourcc, double fps, CvSize frame_size, int is_color=1 )isColor – If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only)
fourcc – 4-character code of codec used to compress the frames. For example, CV_FOURCC('P','I','M','1') is a MPEG-1 codec, CV_FOURCC('M','J','P','G') is a motion-jpeg codec etc. 参数为-1时,运行时会弹出一个框叫你选择。
IplImage* cvQueryFrame(CvCapture* capture)The methods/functions combine VideoCapture::grab() and VideoCapture::retrieve() in one call.
If no frames has been grabbed (camera has been disconnected, or there are no more frames in video file), the methods return false and the functions return NULL pointer.
int cvSaveImage(const char* filename, const CvArr* image, const int* params=0 )params:Format-specific save parameters encoded as pairs paramId_1, paramValue_1, paramId_2, paramValue_2,
2,测试代码:
#include "cv.h"#include "highgui.h"#include "conio.h"#include <stdio.h>using namespace cv;int main(int argc, char** argv){IplImage *pSaveimage= NULL;char filename[20];int i=0;//start cameraCvCapture *capture = cvCreateCameraCapture(0);if(!capture){printf("cannot open camera\n");system("pause");return -1;}IplImage *frame;frame = cvQueryFrame(capture);CvSize size =cvGetSize(frame);double fps =10;CvVideoWriter *video = cvCreateVideoWriter("video_camera.avi",CV_FOURCC('M','J','P','G'),fps,size,1);cvNamedWindow("haha",1);while((frame=cvQueryFrame(capture))!=NULL){cvShowImage("haha",frame);cvWriteFrame(video,frame);printf("one more picture\n");//save imagepSaveimage = cvCreateImage(size,frame->depth,frame->nChannels);sprintf(filename ,"%d.jpg",i);i++;cvResize(frame,pSaveimage,CV_INTER_LINEAR);cvSaveImage(filename,pSaveimage);char key =cvWaitKey(30);if(key==27) //ESCbreak;}cvReleaseVideoWriter(&video);cvReleaseCapture(&capture);cvDestroyAllWindows();return 0;}
0 0
- opencv 摄像头录取视频保存图像
- OpenCV摄像头保存视频和图像
- OpenCv打开摄像头,显示图像,保存视频
- opencv读取视频,摄像头,保存视频代码
- Qt5.3里使用OpenCV库采集摄像头图像保存为图片和视频
- 【图像识别】 Python+Opencv调用摄像头实现人脸识别并保存视频
- opencv 摄像头捕获的图像保存为avi视频 代码解析
- opencv采集视频/摄像头数据并保存
- opencv摄像头视频+帧保存为图片
- opencv 2.4.6 摄像头实时保存视频
- opencv摄像头视频+帧保存为图片
- opencv摄像头拍摄视频并保存方法
- OpenCV打开摄像头 保存视频…
- Qt+OpenCV摄像头读取保存回放视频
- Opencv把视频保存为图像
- opencv读取视频保存成图像
- VS2008+MFC+opencv 显示视频图像/捕捉摄像头视频界面
- OpenCV显示摄像头图像保存成bmp文件
- 从交换两个变量值看c语言学习历程
- installDecor()的流程 | windowSytle| Theme|Feature设置(笔记)
- 函数返回结构体的内幕
- 个人--对编译内核源码的理解
- flash破解相关
- opencv 摄像头录取视频保存图像
- mac下配置php+apache2+mysql
- 不解的一段小程序
- 外企哪些事 笔记
- 将根文件系统 烧录到 nand
- 第五章:树和二叉树
- 第13周项目5字符串操作-统计字符串中字母出现的个数
- NSDate+Helper
- 内核的配置和编译——分析