读取yuv并转化为RGB数据在Opencv中打开显示

/**

* Opencv中一般是读取 demo.avi 格式视频,下面程序是直接读取 demo.yuv  然后使用 Mat 保存

* 再使用 cv::cvtColor() 将每帧的 yuv 数据转化为 rgb 然后显示

*/



#include <opencv/cv.h>
#include <fstream>
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>



using namespace std;
using namespace cv;

const int width = 1280;
const int height = 720;
const int framesize = width * height * 3 / 2;   //一副图所含的像素个数

typedef struct planet
{
	char name[framesize];
	double population;
	double g;
} PLANET;

int main()
{

/
// 计算视频的帧数,怎样替换成c语言形式的?
	PLANET pl;
	ifstream fin;
	fin.open("demo.yuv", ios_base::in|ios_base::binary);
	if(fin.fail())
	{
		cout << "the file is error" << endl;
		return -1;
	}

	fin.seekg(0, ios::end);   //设置文件指针到文件流的尾部
	streampos ps = fin.tellg();  //指出当前的文件指针
	unsigned lon
  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值