﻿<?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/best-sky2008/category/7211.html</link><description>KEYTOP</description><language>zh-cn</language><lastBuildDate>Thu, 29 May 2008 13:19:38 GMT</lastBuildDate><pubDate>Thu, 29 May 2008 13:19:38 GMT</pubDate><ttl>60</ttl><item><title>VC+DirectShow对视频进行图片处理之一</title><link>http://www.cppblog.com/best-sky2008/articles/51356.html</link><dc:creator>chs_mysky</dc:creator><author>chs_mysky</author><pubDate>Wed, 28 May 2008 01:07:00 GMT</pubDate><guid>http://www.cppblog.com/best-sky2008/articles/51356.html</guid><wfw:comment>http://www.cppblog.com/best-sky2008/comments/51356.html</wfw:comment><comments>http://www.cppblog.com/best-sky2008/articles/51356.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/best-sky2008/comments/commentRss/51356.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/best-sky2008/services/trackbacks/51356.html</trackback:ping><description><![CDATA[<h1 style="text-indent: 18.05pt;"><span style="font-size: 9pt;">现在的图像越来越花巧了，有浮雕、马赛克、相框等特效，看得人眼花缭乱。本来图像特效没什么稀奇的，在<span lang="EN-US">PhotoShop等图像处理软件中我们早已见得多 了，不过用在视频上就令人感觉有点神奇。我一直都想拥有这些效果，但我的摄像头是很早就买到的，没福气奢望驱动程序给它带来的全新精彩。刚好我学习
DirectShow有一段时间了，既为了挑战自己（我从未写过令自己感到满意的程序），也为了检验学习成果，我就下了决心用DirectShow实现这 些效果。几经努力，终于有了一些成绩，我完成了其中一些效果，并发现程序可以用在DirectShow支持的影音文件上，又自己把它应用到D3D中去，感
觉还不错。<br>
<br>
先看看效果吧，以激励斗志。我是对着摄像头广告中的效果图来做程序的，我怕编程的热情像以前那样很快冷却，只留下一堆乱糟糟的代码，我需要它来不断兴奋被代码搞得昏头转向的大脑。<o:p></o:p></span></span></h1>
<p class="MsoNormal" style="text-align: left;" align="left"><strong><span style="font-size: 9pt; font-family: 宋体;" lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></strong></p>
<div align="center">
<table style="width: 90%;" border="0" cellpadding="0" width="90%">
    <tbody>
        <tr>
            <td style="padding: 0.75pt;">
            <p class="MsoNormal" style="text-align: center;" align="center"><strong><span style="font-size: 9pt;" lang="EN-US"><!--[if gte vml 1]><v:shapetype
            id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"
            path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
            <v:stroke joinstyle="miter"/>
            <v:formulas>
            <v:f eqn="if lineDrawn pixelLineWidth 0"/>
            <v:f eqn="sum @0 1 0"/>
            <v:f eqn="sum 0 0 @1"/>
            <v:f eqn="prod @2 1 2"/>
            <v:f eqn="prod @3 21600 pixelWidth"/>
            <v:f eqn="prod @3 21600 pixelHeight"/>
            <v:f eqn="sum @0 0 1"/>
            <v:f eqn="prod @6 1 2"/>
            <v:f eqn="prod @7 21600 pixelWidth"/>
            <v:f eqn="sum @8 21600 0"/>
            <v:f eqn="prod @7 21600 pixelHeight"/>
            <v:f eqn="sum @10 21600 0"/>
            </v:formulas>
            <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
            <o:lock v:ext="edit" aspectratio="t"/>
            </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style="'width:158.25pt;
            "            height:115.5pt'>
            <v:imagedata src="file:///C:/DOCUME~1/河山/LOCALS~1/Temp/msoclip1/01/clip_image001.jpg"
            o:href="http://dev.yesky.com/imagelist/06/43/e7d63hew45r1.jpg"/>
            </v:shape><![endif]--><!--[if !vml]--><img src="file:///C:/DOCUME~1/%E6%B2%B3%E5%B1%B1/LOCALS~1/Temp/msoclip1/01/clip_image001.jpg" v:shapes="_x0000_i1025" height="154" width="211"><!--[endif]--><!--[if gte vml 1]><v:shape id="_x0000_i1026"
            type="#_x0000_t75" alt="" style="'width:128.25pt;height:116.25pt'">
            <v:imagedata src="file:///C:/DOCUME~1/河山/LOCALS~1/Temp/msoclip1/01/clip_image002.jpg"
            o:href="http://dev.yesky.com/imagelist/06/43/inkd0dgfm14w.jpg"/>
            </v:shape><![endif]--><!--[if !vml]--><img src="file:///C:/DOCUME~1/%E6%B2%B3%E5%B1%B1/LOCALS~1/Temp/msoclip1/01/clip_image002.jpg" v:shapes="_x0000_i1026" height="155" width="171"><!--[endif]--><br>
            </span></strong><strong><span style="font-size: 9pt; font-family: 宋体;">（图一：几种效果）</span></strong><strong><span style="font-size: 9pt;"> </span></strong><strong><span style="font-size: 9pt; font-family: 宋体;">（图二：</span></strong><strong><span style="font-size: 9pt;" lang="EN-US">D3D</span></strong><strong><span style="font-size: 9pt; font-family: 宋体;">中的摄像展示）</span></strong><strong><span style="font-size: 9pt; font-family: 宋体;" lang="EN-US"><o:p></o:p></span></strong></p>
            </td>
        </tr>
    </tbody>
</table>
</div>
<h1 style="text-indent: 18.05pt;"><span style="font-size: 9pt;">编程的思路是这样的：写一个<span lang="EN-US">DirectShow的VideoRenderer Filter用于实时获取图像，之后在用DirectShow连接并使用摄像头、播放视频时用上该Filter，这样就可以实时处理视频的图片并进行显示了。<o:p></o:p></span></span></h1>
<h1 style="text-indent: 18.05pt;"><span style="font-size: 9pt;">　由于要用到<span lang="EN-US">DirectShow，我想在这里说一些关于DirectShow的初级知识，初学或没学过DirectShow的朋友就请耐下性子来听我这个初学者罗嗦一阵子（要学DirectShow的朋友可以看天极的DirectShow相关文章，介绍很详细）。<br>
<br>
在新版的DX9 SDK中已看不到DirectShow的影子了（DirectShow发展到了尽头？），不过DirectShow还可用，而且相当有用。听说
VC.net自带有DX8 SDK开发文件，但我仍希望您能找到DX8 SDK和VC6。DX8 SDK帮助文件对DirectShow详细的说明和SDK丰富的DirectShow例子对DirectShow开发是大有裨益的。我在开发Filter
过程中发现VC.net不能编译通过，出现&#8220;InterLockedExchange 重定义&#8221;的编译错误，VC6则一切正常，我把这归咎为微软的问题，菜鸟的我无力解决。是了，我只用VC6编写Filter，其它编码使用的是
VC.net，VC.net可完成一般的DirectShow编程，我本人更喜欢VC.net的编码环境。<br>
<br>
&#8220;请问Filter是什 么？&#8221;这个问题在我脑中很久了，DirectShow的功能是由Filter搭建起来的，但我很久以来都被&#8220;Filter&#8221;这个词困惑着，直到现在才有些
眉目。当然，我学识浅，很可能会说错，请海涵。Filter在影音风暴等软件中称为&#8220;滤镜&#8221;，在微软中国上一些译文把它译为&#8220;筛选器&#8221;，五花八门的（看来 没有核心技术真的很被动）。而Filter在数字信号处理等专业课程中称为&#8220;滤波器&#8221;！这下您应该知道一点了吧，DirectShow对视频、音频的处理
过程就是数字信号处理的过程，可以把数字信号处理的理论应用于此，微软为此把这个DirectShow部件称为Filter。<br>
<br>
再说Sample，我把它译为&#8220;采样&#8221;，也就是一个数据包，可理解为摄像头摄像或声卡录音时每扫描一次得到的数据、音视频文件每一帧的数据。<o:p></o:p></span></span></h1><img src ="http://www.cppblog.com/best-sky2008/aggbug/51356.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/best-sky2008/" target="_blank">chs_mysky</a> 2008-05-28 09:07 <a href="http://www.cppblog.com/best-sky2008/articles/51356.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>