<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>摄像头 &#8211; WilliamKyle&#039;s Home</title>
	<atom:link href="https://www.williamkyle.com.cn/archives/tag/%E6%91%84%E5%83%8F%E5%A4%B4/feed" rel="self" type="application/rss+xml" />
	<link>https://www.williamkyle.com.cn</link>
	<description>不积跬步，无以至千里；不积小流，无以成江海。</description>
	<lastBuildDate>Thu, 23 Jan 2020 07:39:18 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9.3</generator>
	<item>
		<title>VC6 下通过 DirectShow 调用摄像头</title>
		<link>https://www.williamkyle.com.cn/archives/117.html</link>
					<comments>https://www.williamkyle.com.cn/archives/117.html#comments</comments>
		
		<dc:creator><![CDATA[WilliamKyle]]></dc:creator>
		<pubDate>Thu, 23 Feb 2012 15:19:08 +0000</pubDate>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[DirectX]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[摄像头]]></category>
		<guid isPermaLink="false">http://www.williamkyle.com.cn/?p=117</guid>

					<description><![CDATA[首先，我们下载一下 DirectX 的 SDK 开发包，目前我们可以使用的是 DirectX 9.0 SDK（ &#8230; <a href="https://www.williamkyle.com.cn/archives/117.html" class="more-link">继续阅读<span class="screen-reader-text">VC6 下通过 DirectShow 调用摄像头</span></a>]]></description>
										<content:encoded><![CDATA[<p>首先，我们下载一下 DirectX 的 SDK 开发包，目前我们可以使用的是 <a href="http://download.microsoft.com/download/7/e/9/7e9f48c6-f28a-469b-9b8e-cc84032efbd4/dxsdk_sum2004.exe">DirectX 9.0 SDK（Summer 2004）</a>之后的版本 DirectShow 已经被分离出去了。下载之后安装，安装前最好把 IDE 都给关了，免得路径没有添加进去。</p>
<h2>    <strong>然后我们开始设计阶段：</strong></h2>
<p>我们先通过 MFC AppWizard(exe) 建立一个 MFC 的基本对话框，去除默认的两个按钮和文本，然后我们添加一个图像控件、一个组合框、一个按钮，然后设置属性，详情如下：</p>
<div style="text-align: center;"><img style="width: 506px; height: 375px; border-width: 0px; border-style: solid;" src="//www.williamkyle.com.cn/wp-content/uploads/ckfinder/images/clip_image001.png" />
</div>
<div style="text-align: center;"><img style="width: 528px; height: 192px; border-width: 0px; border-style: solid;" src="//www.williamkyle.com.cn/wp-content/uploads/ckfinder/images/clip_image002.png" /></div>
<p>&nbsp;</p>
<div style="text-align: center;"><img style="width: 528px; height: 192px; border-width: 0px; border-style: solid;" src="//www.williamkyle.com.cn/wp-content/uploads/ckfinder/images/clip_image003.png" />
</div>
<div style="text-align: center;"><img style="width: 528px; height: 192px; border-width: 0px; border-style: solid;" src="//www.williamkyle.com.cn/wp-content/uploads/ckfinder/images/clip_image004.png" />
</div>
<div style="text-align: left;">然后，我们通过类向导添加成员变量，详情如下：
</div>
<div style="text-align: center;"><img style="width: 576px; height: 378px; border-width: 0px; border-style: solid;" src="//www.williamkyle.com.cn/wp-content/uploads/ckfinder/images/clip_image006.jpg" />
</div>
<h3><strong>接下来，我们双击 Test</strong><strong>按钮，进入代码编写。</strong></h3>
<p>首先，我们把摄像头的两个文件加到项目路径下，然后再在文件视图里面添加这两个文件进项目。</p>
<div style="text-align: center;"><img style="width: 219px; height: 392px; border-width: 0px; border-style: solid;" src="//www.williamkyle.com.cn/wp-content/uploads/ckfinder/images/clip_image007.png" />
</div>
<p>然后，我们给窗口类的头文件里面添加引用</p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">#include "CaptureVideo.h"
</pre>
<p>接着，给窗口类添加一个私有的成员变量</p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">private:
         CCaptureVideo m_cap;
</pre>
<p>然后再在窗口初始化的时候，初始化设备列表</p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">m_cap.EnumDevices(m_Device.GetSafeHwnd());
m_Device.SetCurSel(0);
</pre>
<p>然后在按键的时候初始化摄像头就是的</p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">m_cap.Init(m_Device.GetCurSel(),m_Screen.GetSafeHwnd());
m_OK.EnableWindow(FALSE);
</pre>
<p>我的设计环境为 Windows 7 SP1 、 Visual C++ 6.0 SP6 ，借鉴的别人的程序，如果有其他问题，欢迎一起讨论。<br />
<a href="//www.williamkyle.com.cn/wp-content/uploads/ckfinder/files/Cap.rar">源代码点击下载</a></p>
<hr />
<p>关于出现以下错误的解决方案</p>
<pre class="brush:csharp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">C:\DXSDK\Include\strmif.h(1018) : error C2146: syntax error : missing ';' before identifier 'HSEMAPHORE'
C:\DXSDK\Include\strmif.h(1018) : fatal error C1004: unexpected end of file found
CapDlg.cpp
C:\DXSDK\Include\strmif.h(1018) : error C2146: syntax error : missing ';' before identifier 'HSEMAPHORE'
C:\DXSDK\Include\strmif.h(1018) : fatal error C1004: unexpected end of file found
CaptureVideo.cpp
C:\DXSDK\Include\strmif.h(1018) : error C2146: syntax error : missing ';' before identifier 'HSEMAPHORE'
C:\DXSDK\Include\strmif.h(1018) : fatal error C1004: unexpected end of file found
Generating Code...
执行 cl.exe 时出错.
</pre>
<p>在项目的 StdAfx.cpp 里面加上</p>
<pre class="brush:cpp;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;">#include "C:\DXSDK\Include\strmif.h"
</pre>
<p>编译一次就好了，之后注释掉就好了。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.williamkyle.com.cn/archives/117.html/feed</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
	</channel>
</rss>
