Davinci DM6446 视频格式相关

2024-03-03 16:18

本文主要是介绍Davinci DM6446 视频格式相关,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


标准的V4L2 API

http://v4l.videotechnology.com/dwg/v4l2.pdf

在例程/home/dvevm_1_20/demos/ImageGray中,涉及到图像采集及显示的一些概念

主要的几个文件

capture.c

display.c

video.c

在demo里面采集用到的格式是UYVY

V4L2_PIX_FMT_UYVY ('UYVY')

Name

V4L2_PIX_FMT_UYVY -- Variationof V4L2_PIX_FMT_YUYV with different order of samples in memory

Description

In this format each four bytes is twopixels. Each four bytes is two Y's, a Cb and a Cr. Each Y goes to one of thepixels, and the Cb and Cr belong to both pixels. As you can see, the Cr and Cbcomponents have half the horizontal resolution of the Y component.

Example 2-1. V4L2_PIX_FMT_UYVY4 × 4 pixel image

Byte Order. Each cell is one byte.

start + 0:

Cb00

Y'00

Cr00

Y'01

Cb01

Y'02

Cr01

Y'03

start + 8:

Cb10

Y'10

Cr10

Y'11

Cb11

Y'12

Cr11

Y'13

start + 16:

Cb20

Y'20

Cr20

Y'21

Cb21

Y'22

Cr21

Y'23

start + 24:

Cb30

Y'30

Cr30

Y'31

Cb31

Y'32

Cr31

Y'33

Color Sample Location.

 

0

 

1

 

2

 

3

0

Y

C

Y

 

Y

C

Y

1

Y

C

Y

 

Y

C

Y

2

Y

C

Y

 

Y

C

Y

3

Y

C

Y

 

Y

C

Y

 

在imagegray里面把图片变成灰度是在filecopy_dec.c这个函数里面有这样的代码

static void PictureGray(void *pInbuf,void*pOutbuf,unsigned int len)

{

   unsigned int i;

   unsigned int * pIn = (unsigned int*)pInbuf;

unsigned int *pOut= (unsigned int*)pOutbuf;

 len >>= 2;

   for(i=0;i<len;i++)

    {

         *pOut= *pIn & 0xff00ff00 | 0x00800080;

         pIn++;

         pOut++;

    }

}

从上面的UYVY的格式解释里面可以看到,变成灰度图像只是把图像四个字节跟0xff00ff00相与就可以了,一直没明白为什么还要在后面加上一个0x00800080相或,我原来一直以为是不是UYVY的格式解释不一样,找了半天各种格式之间区别的不少,讲到这个点子上的倒没看到,最后在TI的网站上有这样的回复

 

i want  to transfer the input image ofyuv422 format  to a gray image

 

if you want a grayscale output in the YCbCrcolorspace of your input  you can just set the Cb and Cr values to 0x80and leave the Y as is, as Y is the brightness/luminance and is essentially thegreyscale version of the image so if you set the color values to a constantmedian value of 0x80 you end up with a grayscale image.

 

For working with the encodedecode demo, ifall you want to do is make the output look grayscale than the small functionmentioned above (and here) should still work for you. In the encodedecode demoyou are actually compressing and decompressing the video so you could performthis operation between capture and compress or between decompress and display,either way should work as the frame buffer will be in the proper YCbCR 4:2:2format at both points. In YCbCr 4:2:2 you have a stream of bytes in the formCbYCrYCbYCrYCbYCrY... and so on, where the Y values for luminance arefor each pixel and each 2 pixels shares a Cb and Cr for chrominance. Since agreyscale image is an image with only brightness/luminance and nochrominance/color all you have to do is remove the chrominance values,

howeversince the display is expecting an image formatted in color we cannot take themout completely,

but rather we can make the chrominancevalues constant, and for greyscale/B&W you want them to all be mid pointvalues of 0x80 (out of 0xFF).

 The code below does just this, if yougive it a pointer to the YCbCr 4:2:2 frame buffer and the size of the buffer itwill step through and make all of the Cb and Cr values 0x80 so that the imageappears greyscale on the output.

Bernie Thompson:

//make the image greyscale by setting allchrominance to 0x80
void process_imagebw( void* currentFrame,  int yRows, int xPixels)
{
  
 int xx = 0;
 
     for( xx = 0; xx < (yRows * xPixels)*2; xx+=2)//just operating on the chroma
      {

           *( ( (unsigned char*)currentFrame ) + xx ) = 0x80; //set all chromato midpoint 0x80
         }

 
} // End process_imagebw()

对TVP5158采集到的YUV422分析,它是以UYVY格式存放的,因为U,V是正交化的由于本课题用到的图像处理基于黑白图像,所以只需对Y分量进行处理,那么第一步就是对YUV422提取出Y,如果要保留Y分量,那么需将UV置为0x80,如需置白/黑色,Y分量设为FF/00,提取出亮度信号后,即可作简单的二值化.

UV是色差分量,UV为0就会全是绿色,全为0x80的时候才能看到灰度图。



这篇关于Davinci DM6446 视频格式相关的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/770176

相关文章

Redis的Zset类型及相关命令详细讲解

《Redis的Zset类型及相关命令详细讲解》:本文主要介绍Redis的Zset类型及相关命令的相关资料,有序集合Zset是一种Redis数据结构,它类似于集合Set,但每个元素都有一个关联的分数... 目录Zset简介ZADDZCARDZCOUNTZRANGEZREVRANGEZRANGEBYSCOREZ

Linux使用fdisk进行磁盘的相关操作

《Linux使用fdisk进行磁盘的相关操作》fdisk命令是Linux中用于管理磁盘分区的强大文本实用程序,这篇文章主要为大家详细介绍了如何使用fdisk进行磁盘的相关操作,需要的可以了解下... 目录简介基本语法示例用法列出所有分区查看指定磁盘的区分管理指定的磁盘进入交互式模式创建一个新的分区删除一个存

关于Maven生命周期相关命令演示

《关于Maven生命周期相关命令演示》Maven的生命周期分为Clean、Default和Site三个主要阶段,每个阶段包含多个关键步骤,如清理、编译、测试、打包等,通过执行相应的Maven命令,可以... 目录1. Maven 生命周期概述1.1 Clean Lifecycle1.2 Default Li

numpy求解线性代数相关问题

《numpy求解线性代数相关问题》本文主要介绍了numpy求解线性代数相关问题,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 在numpy中有numpy.array类型和numpy.mat类型,前者是数组类型,后者是矩阵类型。数组

Redis的Hash类型及相关命令小结

《Redis的Hash类型及相关命令小结》edisHash是一种数据结构,用于存储字段和值的映射关系,本文就来介绍一下Redis的Hash类型及相关命令小结,具有一定的参考价值,感兴趣的可以了解一下... 目录HSETHGETHEXISTSHDELHKEYSHVALSHGETALLHMGETHLENHSET

python中的与时间相关的模块应用场景分析

《python中的与时间相关的模块应用场景分析》本文介绍了Python中与时间相关的几个重要模块:`time`、`datetime`、`calendar`、`timeit`、`pytz`和`dateu... 目录1. time 模块2. datetime 模块3. calendar 模块4. timeit

sqlite3 相关知识

WAL 模式 VS 回滚模式 特性WAL 模式回滚模式(Rollback Journal)定义使用写前日志来记录变更。使用回滚日志来记录事务的所有修改。特点更高的并发性和性能;支持多读者和单写者。支持安全的事务回滚,但并发性较低。性能写入性能更好,尤其是读多写少的场景。写操作会造成较大的性能开销,尤其是在事务开始时。写入流程数据首先写入 WAL 文件,然后才从 WAL 刷新到主数据库。数据在开始

两个月冲刺软考——访问位与修改位的题型(淘汰哪一页);内聚的类型;关于码制的知识点;地址映射的相关内容

1.访问位与修改位的题型(淘汰哪一页) 访问位:为1时表示在内存期间被访问过,为0时表示未被访问;修改位:为1时表示该页面自从被装入内存后被修改过,为0时表示未修改过。 置换页面时,最先置换访问位和修改位为00的,其次是01(没被访问但被修改过)的,之后是10(被访问了但没被修改过),最后是11。 2.内聚的类型 功能内聚:完成一个单一功能,各个部分协同工作,缺一不可。 顺序内聚:

log4j2相关配置说明以及${sys:catalina.home}应用

${sys:catalina.home} 等价于 System.getProperty("catalina.home") 就是Tomcat的根目录:  C:\apache-tomcat-7.0.77 <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" /> 2017-08-10

Node Linux相关安装

下载经编译好的文件cd /optwget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.gztar -xvf node-v10.15.3-linux-x64.tar.gzln -s /opt/node-v10.15.3-linux-x64/bin/npm /usr/local/bin/ln -s /opt/nod