﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-日日勤作息-随笔分类-视频处理</title><link>http://www.cppblog.com/zealsoft/category/15478.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 16 Nov 2010 21:59:09 GMT</lastBuildDate><pubDate>Tue, 16 Nov 2010 21:59:09 GMT</pubDate><ttl>60</ttl><item><title>视频捕捉的格式问题</title><link>http://www.cppblog.com/zealsoft/archive/2010/11/16/133827.html</link><dc:creator>zealsoft</dc:creator><author>zealsoft</author><pubDate>Tue, 16 Nov 2010 14:30:00 GMT</pubDate><guid>http://www.cppblog.com/zealsoft/archive/2010/11/16/133827.html</guid><wfw:comment>http://www.cppblog.com/zealsoft/comments/133827.html</wfw:comment><comments>http://www.cppblog.com/zealsoft/archive/2010/11/16/133827.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/zealsoft/comments/commentRss/133827.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/zealsoft/services/trackbacks/133827.html</trackback:ping><description><![CDATA[
<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><span style="font-family: Simsun; line-height: normal; font-size: medium; ">&nbsp;&nbsp; &nbsp;这几天一个学生在调试视频捕捉程序的时候遇到了一个问题。他使用capGetVideoFormat函数获得视频的格式时，发现m_bmpinfo.bmiHeader.biBitCount为16，他认为这是表示16位的RGB格式。可是不管他是使用RGB565，还是RGB555格式进行转换时，发现转换后的YUV文件都是不对的。在我的Sony笔记本上运行他的程序，其中的m_bmpinfo.bmiHeader.biCompression的值为1498831189，这说明笔记本的摄像头所采集的数据的格式并不是普通的16位RGB数据，而是UYVY格式的。UYVY格式是YUV格式的一个变种，在网上可以找到详细的说明，在此就不赘述了。</span></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><span style="font-family: Simsun; line-height: normal; font-size: medium; ">&nbsp;&nbsp; &nbsp;要想知道biCompression到底有多少种取值，可以参考一下：<a href="http://files.codes-sources.com/fichier.aspx?id=45735&amp;f=src/org/hypik/webcamlib/codecs/Codecs.java">http://files.codes-sources.com/fichier.aspx?id=45735&amp;f=src/org/hypik/webcamlib/codecs/Codecs.java</a>。在这里详细的列出了各种视频压缩的编码。</span></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><span style="font-family: Simsun; line-height: normal; font-size: medium; ">&nbsp;&nbsp; &nbsp;怎样才能知道自己的摄像头到底支持哪种格式的输出呢？可以使用capDlgVideoFormat函数：</span>&nbsp;</p><div class="cnblogs_code" style="background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; line-height: 21px; "><div><span style="font-family: 'Courier New'; color: rgb(0, 0, 0); ">capDlgVideoFormat(m_wndVideo);</span></div></div><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><span style="font-family: Simsun; line-height: normal; font-size: medium; ">&nbsp;&nbsp; &nbsp; 这个函数会激活摄像头驱动的视频格式设置对话框，如下图所示。</span></p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; text-align: center; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; "><img src="http://www.cnblogs.com/images/cnblogs_com/zealsoft/videoformat.JPG" width="464" height="267" alt="">&nbsp;</p><p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px; font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px; ">&nbsp;&nbsp; &nbsp;我的这个摄像头支持2种输出格式，一种是UYVY，另一种是YUV2。 如果将m_bmpinfo.bmiHeader.biCompression设置为这两种之外的值，再使用capSetVideoFormat改变输出格式，由于驱动程序不支持而不会获得成功。</p><img src ="http://www.cppblog.com/zealsoft/aggbug/133827.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zealsoft/" target="_blank">zealsoft</a> 2010-11-16 22:30 <a href="http://www.cppblog.com/zealsoft/archive/2010/11/16/133827.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>