OPENCV的2-10备注
来源:互联网 发布:可靠的韩国代购淘宝 编辑:程序博客网 时间:2024/06/05 21:02
#include "cv.h"#include "highgui.h"#include <stdio.h>// Convert a video to grayscale// argv[1]: input video file// argv[2]: name of new output file//IplImage* doresize(IplImage* in){IplImage* out1 = cvCreateImage( cvSize( in->width/2, in->height/2 ), in->depth, in->nChannels ); return( out1 );};IplImage* doPyrDown( IplImage* in, int filter = IPL_GAUSSIAN_5x5){ IplImage* out = cvCreateImage( cvSize( in->width/2, in->height/2 ), in->depth, in->nChannels ); cvPyrDown( in, out ); return( out );};int main( int argc, char* argv[] ) { cvNamedWindow( "Example2_10", CV_WINDOW_AUTOSIZE ); cvNamedWindow( "Log_Polar", CV_WINDOW_AUTOSIZE ); CvCapture* capture = cvCreateFileCapture( "D:\\1.wmv" ); if (!capture){ return -1; } IplImage* bgr_frame;IplImage* img_pyr; double fps = cvGetCaptureProperty ( capture, CV_CAP_PROP_FPS );printf("fps=%d\n",(int)fps); CvSize size = cvSize( (int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH), (int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT) ); printf("frame (w, h) = (%d, %d)\n",size.width,size.height); CvVideoWriter* writer = cvCreateVideoWriter( // On linux Will only work if you've installed ffmpeg development files correctly, "D:\\33.avi", // otherwise segmentation fault. Windows probably better. CV_FOURCC('D','X','5','0'), fps, size ); IplImage* logpolar_frame = cvCreateImage( size, IPL_DEPTH_8U, 3 ); IplImage* gray_frame = cvCreateImage( size, IPL_DEPTH_8U, 1 ); while( (bgr_frame=cvQueryFrame(capture)) != NULL ) { cvShowImage( "Example2_10", bgr_frame ); //cvLogPolar( bgr_frame, logpolar_frame, //This is just a fun conversion the mimic's the human visual system // cvPoint2D32f(bgr_frame->width/2, // bgr_frame->height/2), // 40, // CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS ); //此语句正确cvCvtColor(bgr_frame, gray_frame,CV_BGR2GRAY); //将色彩转换为灰度,必须与上面的IplImage* gray_frame搭配使用才行//用上语句转换灰度,则需要将gray_frame通道初始化为1,若为3则发生错误,下句可将gray_frame通道初始化为1为3,因为未指定转换格式CV_BGR2GRAY//cvConvertImage(bgr_frame, gray_frame,CV_CVTIMG_FLIP);//图像180度旋转/****以上两句程序都是讲图像转换为灰度****/img_pyr=doresize(gray_frame); cvResize(gray_frame,img_pyr); //使用cvResize需要先将目标图像初始化好为目标图像的一般即doresize所做的,然后才好将原图像转换为目标图像的一般//img_pyr =doPyrDown(gray_frame,IPL_GAUSSIAN_5x5); //gray_frame =doPyrDown(gray_frame,IPL_GAUSSIAN_5x5);这里必须重新定义指针,直接用这语句不对 /****以上两句程序都是讲图像缩放为原来的一般****/ cvShowImage( "Log_Polar", img_pyr ); //Sigh, on linux, depending on your ffmpeg, this often won't work ... cvWriteToAVI( writer, img_pyr ); char c = cvWaitKey(10); if( c == 27 ) break; } cvReleaseVideoWriter( &writer ); cvReleaseImage( &img_pyr ); cvReleaseCapture( &capture );}
0 0
- OPENCV的2-10备注
- opencv 学习备注2
- opencv学习备注
- 实例:对2个Makefile的备注
- 打印的备注字段
- Hibernate的小备注
- ppt备注的使用方法
- Linux的一些备注
- sed命令的备注
- 代理的备注
- 手机备注的设计
- iscroll4snap的使用备注
- GrEA的一个备注
- sift学习备注2
- c++备注2
- surf学习备注2
- Go语言备注2
- 备注
- Java8 ThreadLocal类源码 详解
- iOS开发之获取照片&&TZImagePickerController的使用
- spring InitializingBean接口
- 语音合成和识别接口
- MySql 时间比较:DATEDIFF函数与大于小于号
- OPENCV的2-10备注
- 安装selenium RC
- android studio编译运行各种踩坑解决方案
- 图片服务器架构
- 简单搜索题(D. Phillip and Trains)
- 一步集成侧滑(删除)菜单
- 《Refactoring》,Substitute Algorithm(替换算法)
- 主元素
- 清除WKWebView cookies