资源简介
libyuv库,包含RGB和yuv之间的转换接口,图像缩放接口等。包含头文件libyuv.h即可,接口在yuv_convert.cpp中,代码量很少,一看就懂。
代码片段和文件信息
#include “yuv_convert.h“
#include
#include
#include
#include
#include
#include
#include
//#include “util/time_util.hpp“
//#include “base/log_system.hpp“
#ifdef __cplusplus
extern “C“ {
#endif
#include “libyuv.h“
#ifdef __cplusplus
}
#endif
using namespace libyuv;
//static LogSystem log_(“yuv_convert“);
//#define debug_info(fmt args...) log_.Dbg(“%s@%d: “ fmt __FUNCTION__ __LINE__ ##args)
//#define print_info(fmt args...) log_.Info(“%s@%d: “ fmt __FUNCTION__ __LINE__ ##args)
//#define error_info(fmt args...) log_.Err(“%s@%d: “ fmt __FUNCTION__ __LINE__ ##args)
int fb_index = -1;
unsigned char *rgb_buffer;
unsigned char *yuv_buffer;
unsigned char *fb_mem;
unsigned int w;
unsigned int h;
void ConvToI420(unsigned char *dataIn unsigned char *dataOut int width int height enum ConvertType type)
{
unsigned int FourCC = 0;
switch (type) {
case CONV_UYVY_TO_I420:
FourCC = FOURCC_2VUY;
break;
case CONV_ABGR_TO_I420:
FourCC = FOURCC_ABGR;
break;
default:
FourCC = FOURCC_2VUY;
break;
}
//unsigned long long int time1 = GetTimeOfSysUs();
ConvertToI420(dataIn width * height * 3 / 2
dataOut width dataOut + (width * height) width / 2 dataOut + (width * height * 5 / 4) width / 2
0 0 width height width height kRotate0 FourCC);
//unsigned long long int time2 = GetTimeOfSysUs();
//debug_info(“ConvertToI420 delay: %lldms\n“ (time2 - time1) / 1000);
}
void ConvToARGB(unsigned char *dataIn unsigned char *dataOut int width int height enum ConvertType type)
{
unsigned int FourCC = 0;
switch (type) {
case CONV_I420_TO_ARGB:
FourCC = FOURCC_IYUV;
break;
case CONV_UYVY_TO_ARGB:
FourCC = FOURCC_2VUY;
break;
default:
FourCC = FOURCC_IYUV;
break;
}
//unsigned long long int time1 = GetTimeOfSysUs();
ConvertToARGB(dataIn width * height * 3 / 2 dataOut width * 4 0 0 width height width height kRotate0 FourCC);
//unsigned long long int time2 = GetTimeOfSysUs();
//debug_info(“ConvertToARGB delay: %lldms\n“ (time2 - time1) / 1000);
}
void YuvInit(unsigned int width unsigned int height)
{
w = width;
h = height;
printf(“YuvInit w:%d h:%d\n“ w h);
rgb_buffer = (unsigned char *)malloc(w * h * 4);
yuv_buffer = (unsigned char *)malloc(w * h * 2);
system(“sudo service lightdm stop“);
fb_index = open(“/dev/fb0“ O_RDWR);
fb_mem = (unsigned char *)mmap(NULL w * h * 4 PROT_READ | PROT_WRITE MAP_SHARED fb_index 0);
}
void YuvWriteframe(unsigned char *data)
{
ConvToARGB(data rgb_buffer w h CONV_I420_TO_ARGB);
memcpy(fb_
- 上一篇:测距雷达距离模糊的两种快速算法
- 下一篇:Jetson_Nano开发板原理图.pdf
相关资源
- sRGBColorCheckerBoundary.jpg
- YUV视频剪切工具
- YUV 和 RGB 颜色互转的小工具
- bmp格式图片转为rgb565格式图片
- Bayer图像格式转化为标准RGB格式
-
yuv pla
yer(亲测好用) - linux下操做OV5640摄像头
- yuv序列间隔丢失宏块,再按照JM8.6误码
- 四通道LVDS转RGB芯片
- rgba8888转yuvsp420
-
YUVpla
yer1.3 - 树莓派控制RGB LED源代码softPwm
- LT8619C_DataSheet_R1.2.pdf
- ili9488液晶初始化RGB接口
- 用FCM算法实现图像分割(图像源可以
- YUV422转换为YUV420数据格式
- JPEG数据格式转YUV数据格式
- ubuntu平台的pyuv播放器
- yuv视频文件剪切
- yuv420p转yuv422
- RGB驱动LED电路图
- HSVRGB屏幕取色
- Linux下QT tcp接收Zedboard发送的RGB888视频
- rgb565_to_bmp
- YUY420(YV12)转YUY2(YUV420),读取yu
- 字符叠加及YUV420转RGB
- 利用PWM技术控制RGB灯变色和呼吸
- YUV图像OSD字幕信息叠加功能
- RGB888与RGB565互转工具
- 78种RGB配色方案
评论
共有 条评论