㈠ 使用OpenCV获取摄像头图像,编码压缩并发送的问题
opencv用CvVideoWriter 来写视频文件,先用 cvCreateVideoWriter创建CvVideoWriter对象的,第二个参数写“-1”,就可以选择压缩编码方式
㈡ 请教怎么用opencv将一张模糊的图片变清晰
用opencv只能改善图片清晰度,但是不能将将一张模糊的图片变清晰的!因为图像清晰度是有拍摄相机像素高低决定的!
㈢ opencv如何将连续图像压缩成视频
这是我之前写的一段代码
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
/*******************************************************
图片转换为视频
*******************************************************/
//void ImagetoVideo()
main()
{
int i = 0;
//初始化视频编写器,参数根据实际视频文件修改
CvVideoWriter* writer = 0;
int isColor = 1;
//int fps = 25; // or 30
double fps = 6;
int frameW = 1920;
int frameH = 1080;
writer = cvCreateVideoWriter("decoderout.avi",CV_FOURCC('X','V','I','D'),fps, cvSize(frameW, frameH), isColor);
printf("\tvideo height:%d\n\tvidoe width:%d\n\t\fps:%d\n",frameH, frameW, fps);
int startframe = 1; //图片开始帧号
int endframe = 58;
char cur_fn[255];
char* prefix = "F:\\视频增强\\视频解码\\videoDecoder5-7-例程-先得到每一个nal\\img\\";//图片序列的路径
char* ext = ".bmp"; //序列图片的后缀名
//存储视频文件
IplImage* img = 0;
// int nFrames = 50;
// for (i = 0; i < nFrames; i++)
// {
// cvWriteFrame(writer,img); //写入一帧到一个视频文件中 cvGrabFrame(capture);
// }
while (startframe <= endframe)
{
strcpy(cur_fn,"");
sprintf(cur_fn,"%s%d%s",prefix,startframe,ext);
img = cvLoadImage(cur_fn,isColor);
if (!img)
{
printf("can not open file\n");
return ;
}
cvWriteFrame(writer,img);
cvWaitKey(20);
startframe++;
cvReleaseImage(&img);
}
//创建窗口
// cvNamedWindow("mainWin",CV_WINDOW_AUTOSIZE);
// cvShowImage("mainWin",img);
// cvWaitKey(20);
//释放视频存储器
cvReleaseVideoWriter(&writer);
}