yuv数据解析

yuv数据解析

int main() {
	int frame = 1362;
	int img_data_len = (640 * 512 * 3 / 2) * frame;
	unsigned char* img_data = new unsigned char[img_data_len];
	fstream f("E:\\data\\1.yuv", ios::in | ios::binary);
	f.read(reinterpret_cast<char*>(img_data), img_data_len);
	Mat read_img(512 * 3 / 2, 640, CV_8UC1);
	for (int i = 0; i < frame; i++) {
		memcpy(read_img.data, img_data, 640 * 512 * 3 / 2);
		img_data += 640 * 512 * 3 / 2;
		Mat save_img;
		cvtColor(read_img, save_img, cv::COLOR_YUV2BGR_I420);
		string ss;
		int a = (i) / 10;
		if (a == 0)
			ss = "000";
		else if (a < 10)
			ss = "00";
		else if (a >= 10 && a < 100)
			ss = "0";
		else
			ss = "";
		imwrite("E:\\rgb\\" + ss + to_string(i) + ".jpg", save_img);
		//cv::imshow("test", save_img);
		waitKey(0);
	}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
UVTools are a set of software utilities to play, convert and analyze YUV or RGB video data in their raw formats. The main features of YUVTools are: It accepts (plays, converts, edits and analyzes) the combination of following formats: YUV in 4:4:4, 4:2:2 or 4:2:0 sample format, RGB in 4:4:4 sampling format; in different component order, like YUV, YVU, UYV, RGB, BGR, etc. in progressive (one single frame) or interlaced (two fields) format; in planar (YYY...UUU...VVV...) or packed (YUV, YUV....) pixel format; in predefined or arbitrary resolutions; Support FOURCC ( refer to: http://www.fourcc.org/). An image preview function to help guess the video format interactively. YUV Player can open multiple player dialogs and play different files in each dialog separately, or play multiple video files in one player dialog one by one sequentially. The detailed format of any opened or generated files will be logged, and the user can directly select any file to play back from the history list. YUV Converter can convert any combination of the format to another format, or convert to (or from) a sequence of BMP files. Other conversion functions include: scaling, join, crop, flip, padding, merge and separation of color components. YUV Analyzer can be used to calculate PSNR between two YUV files, or compare pixel by pixel to check the difference between the corresponding frames of two files, or overlay block type or motion vectors on top of each frame. Another useful feature is to help check the motion between two adjacent frames. YUV Editor can be used to edit the images pixel by pixel, or overlay one YUV image on top of another YUV image file. Convert YUV file to AVI format or vice versa; Setting options include grid display, different YUV to RGB conversion formula, etc. Many of above functions can also be performed in command line mode, which are useful for batch process or scripting.

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值