<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" 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/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Tech Off - Programatically Using A Webcam In C#</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Tech Off - Programatically Using A Webcam In C#</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Sun, 19 May 2013 05:38:34 GMT</pubDate>
	<lastBuildDate>Sun, 19 May 2013 05:38:34 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>16</c9:totalResults>
	<c9:pageCount>-16</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>Does anyone know how to programatically take a picture using a webcam in C#? There are a few examples of webcam use in C# on the internet, but they don't do what I would like them to. The camera sadly doesn't come with an SDK, I have no idea what to do.<br>
<br>
<br>
Any ideas will be much appreciated.<br>
<br>
<br>
Thanks in advance<br>
<br>
Angus Higgins</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/93476#93476</link>
		<pubDate>Tue, 02 Aug 2005 13:09:08 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/93476#93476</guid>
		<dc:creator>Angus</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Angus/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>Periodically take snapshots or capture a stream?<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/432db67fcd224c938fc39dea01275fff#432db67fcd224c938fc39dea01275fff</link>
		<pubDate>Tue, 02 Aug 2005 13:55:39 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/432db67fcd224c938fc39dea01275fff#432db67fcd224c938fc39dea01275fff</guid>
		<dc:creator>W3bbo</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/W3bbo/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>Hi,<br>
<br>
I used some code found in Codeproject in some months ago that captured photos or a video stream from any video source, in my case, it was a webcam.<br>
<br>
The code, was a wrapper around the DirectX API. I remember that you needed to download the DirectX SDK to work with this.<br>
<br>
I think i have that code at home, if you can wait for 6 hours....... <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /><br>
<br>
<br>
Paulo Correia</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/ace2a841fb4d499d93199dea01276041#ace2a841fb4d499d93199dea01276041</link>
		<pubDate>Tue, 02 Aug 2005 13:59:06 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/ace2a841fb4d499d93199dea01276041#ace2a841fb4d499d93199dea01276041</guid>
		<dc:creator>paulo_iap</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/paulo_iap/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>I believe DirectShow should work for capturing a video stream.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/55c272c52a6a4bfcac929dea0127606a#55c272c52a6a4bfcac929dea0127606a</link>
		<pubDate>Tue, 02 Aug 2005 15:37:18 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/55c272c52a6a4bfcac929dea0127606a#55c272c52a6a4bfcac929dea0127606a</guid>
		<dc:creator>Andrei P</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Andrei P/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p><blockquote>
<div>W3bbo wrote:</div>
<div>Periodically take snapshots or capture a stream?<br>
</div>
</blockquote>
<br>
<br>
It needs to take a snapshot on command.<br>
<br>
Angus Higgins</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/5139339d80ca433d9e089dea01276093#5139339d80ca433d9e089dea01276093</link>
		<pubDate>Tue, 02 Aug 2005 15:42:41 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/5139339d80ca433d9e089dea01276093#5139339d80ca433d9e089dea01276093</guid>
		<dc:creator>Angus</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Angus/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>Hi. The fallowing is a C# file that will do it, iv reused this code a bunch of times over and I cant remember who the original author was.</p>
<p>[code language='C#']<br>
using System;<br>
using System.Collections;<br>
using System.ComponentModel;<br>
using System.Drawing;<br>
using System.Data;<br>
using System.Windows.Forms;<br>
using System.Runtime.InteropServices;</p>
<p>namespace WebCam_Capture<br>
{<br>
&nbsp;/// &lt;summary&gt;<br>
&nbsp;/// Summary description for UserControl1.<br>
&nbsp;/// &lt;/summary&gt;<br>
&nbsp;[System.Drawing.ToolboxBitmap(typeof(WebCamCapture), &quot;CAMERA.ICO&quot;)] // toolbox bitmap<br>
&nbsp;[Designer(&quot;Sytem.Windows.Forms.Design.ParentControlDesigner,System.Design&quot;, typeof(System.ComponentModel.Design.IDesigner))] // make composite<br>
&nbsp;public class WebCamCapture : System.Windows.Forms.UserControl<br>
&nbsp;{<br>
&nbsp;&nbsp;private System.ComponentModel.IContainer components;<br>
&nbsp;&nbsp;private System.Windows.Forms.Timer timer1;</p>
<p>&nbsp;&nbsp;// property variables<br>
&nbsp;&nbsp;private int m_TimeToCapture_milliseconds = 100;<br>
&nbsp;&nbsp;private int m_Width = 320;<br>
&nbsp;&nbsp;private int m_Height = 240;<br>
&nbsp;&nbsp;private int mCapHwnd;<br>
&nbsp;&nbsp;private ulong m_FrameNumber = 0;</p>
<p>&nbsp;&nbsp;// global variables to make the video capture go faster<br>
&nbsp;&nbsp;private WebCam_Capture.WebcamEventArgs x = new WebCam_Capture.WebcamEventArgs();<br>
&nbsp;&nbsp;private IDataObject tempObj;<br>
&nbsp;&nbsp;private System.Drawing.Image tempImg;<br>
&nbsp;&nbsp;private bool bStopped = true;</p>
<p>&nbsp;&nbsp;// event delegate<br>
&nbsp;&nbsp;public delegate void WebCamEventHandler (object source, WebCam_Capture.WebcamEventArgs e);<br>
&nbsp;&nbsp;// fired when a new image is captured<br>
&nbsp;&nbsp;public event WebCamEventHandler ImageCaptured; </p>
<p>&nbsp;&nbsp;#region API Declarations</p>
<p>&nbsp;&nbsp;[DllImport(&quot;user32&quot;, EntryPoint=&quot;SendMessage&quot;)]<br>
&nbsp;&nbsp;public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);</p>
<p>&nbsp;&nbsp;[DllImport(&quot;avicap32.dll&quot;, EntryPoint=&quot;capCreateCaptureWindowA&quot;)]<br>
&nbsp;&nbsp;public static extern int capCreateCaptureWindowA(string lpszWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hwndParent, int nID);</p>
<p>&nbsp;&nbsp;[DllImport(&quot;user32&quot;, EntryPoint=&quot;OpenClipboard&quot;)]<br>
&nbsp;&nbsp;public static extern int OpenClipboard(int hWnd);</p>
<p>&nbsp;&nbsp;[DllImport(&quot;user32&quot;, EntryPoint=&quot;EmptyClipboard&quot;)]<br>
&nbsp;&nbsp;public static extern int EmptyClipboard();</p>
<p>&nbsp;&nbsp;[DllImport(&quot;user32&quot;, EntryPoint=&quot;CloseClipboard&quot;)]<br>
&nbsp;&nbsp;public static extern int CloseClipboard();</p>
<p>&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;#region API Constants</p>
<p>&nbsp;&nbsp;public const int WM_USER = 1024;</p>
<p>&nbsp;&nbsp;public const int WM_CAP_CONNECT = 1034;<br>
&nbsp;&nbsp;public const int WM_CAP_DISCONNECT = 1035;<br>
&nbsp;&nbsp;public const int WM_CAP_GET_FRAME = 1084;<br>
&nbsp;&nbsp;public const int WM_CAP_COPY = 1054;</p>
<p>&nbsp;&nbsp;public const int WM_CAP_START = WM_USER;</p>
<p>&nbsp;&nbsp;public const int WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START &#43; 41;<br>
&nbsp;&nbsp;public const int WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START &#43; 42;<br>
&nbsp;&nbsp;public const int WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START &#43; 43;<br>
&nbsp;&nbsp;public const int WM_CAP_GET_VIDEOFORMAT = WM_CAP_START &#43; 44;<br>
&nbsp;&nbsp;public const int WM_CAP_SET_VIDEOFORMAT = WM_CAP_START &#43; 45;<br>
&nbsp;&nbsp;public const int WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START &#43; 46;<br>
&nbsp;&nbsp;public const int WM_CAP_SET_PREVIEW = WM_CAP_START &#43; 50;</p>
<p>&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;#region NOTES</p>
<p>&nbsp;&nbsp;/*<br>
&nbsp;&nbsp; * If you want to allow the user to change the display size and <br>
&nbsp;&nbsp; * color format of the video capture, call:<br>
&nbsp;&nbsp; * SendMessage (mCapHwnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0);<br>
&nbsp;&nbsp; * You will need to requery the capture device to get the new settings<br>
&nbsp;&nbsp;*/</p>
<p>&nbsp;&nbsp;#endregion</p>
<p><br>
&nbsp;&nbsp;public WebCamCapture()<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;// This call is required by the Windows.Forms Form Designer.<br>
&nbsp;&nbsp;&nbsp;InitializeComponent();<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Override the class's finalize method, so we can stop<br>
&nbsp;&nbsp;/// the video capture on exit<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;~WebCamCapture()<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;this.Stop();<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Clean up any resources being used.<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;protected override void Dispose( bool disposing )<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;if( disposing )<br>
&nbsp;&nbsp;&nbsp;{</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;if( components != null )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;components.Dispose();<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;base.Dispose( disposing );<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;#region Component Designer generated code<br>
&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Required method for Designer support - do not modify <br>
&nbsp;&nbsp;/// the contents of this method with the code editor.<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;private void InitializeComponent()<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;this.components = new System.ComponentModel.Container();<br>
&nbsp;&nbsp;&nbsp;this.timer1 = new System.Windows.Forms.Timer(this.components);<br>
&nbsp;&nbsp;&nbsp;// <br>
&nbsp;&nbsp;&nbsp;// timer1<br>
&nbsp;&nbsp;&nbsp;// <br>
&nbsp;&nbsp;&nbsp;this.timer1.Tick &#43;= new System.EventHandler(this.timer1_Tick);<br>
&nbsp;&nbsp;&nbsp;// <br>
&nbsp;&nbsp;&nbsp;// WebCamCapture<br>
&nbsp;&nbsp;&nbsp;// <br>
&nbsp;&nbsp;&nbsp;this.Name = &quot;WebCamCapture&quot;;<br>
&nbsp;&nbsp;&nbsp;this.Size = new System.Drawing.Size(342, 252);<br>
&nbsp;&nbsp;&nbsp;this.Load &#43;= new System.EventHandler(this.WebCamCapture_Load);</p>
<p>&nbsp;&nbsp;}<br>
&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;#region Control Properties</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// The time intervale between frame captures<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;public int TimeToCapture_milliseconds<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;get<br>
&nbsp;&nbsp;&nbsp;{ return m_TimeToCapture_milliseconds; }</p>
<p>&nbsp;&nbsp;&nbsp;set<br>
&nbsp;&nbsp;&nbsp;{ m_TimeToCapture_milliseconds = value; }<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// The height of the video capture image<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;public int CaptureHeight<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;get<br>
&nbsp;&nbsp;&nbsp;{ return m_Height; }<br>
&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;set<br>
&nbsp;&nbsp;&nbsp;{ m_Height = value; }<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// The width of the video capture image<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;public int CaptureWidth<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;get<br>
&nbsp;&nbsp;&nbsp;{ return m_Width; }</p>
<p>&nbsp;&nbsp;&nbsp;set<br>
&nbsp;&nbsp;&nbsp;{ m_Width = value; }<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// The sequence number to start at for the frame number. OPTIONAL<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;public ulong FrameNumber<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;get<br>
&nbsp;&nbsp;&nbsp;{ return m_FrameNumber; }</p>
<p>&nbsp;&nbsp;&nbsp;set<br>
&nbsp;&nbsp;&nbsp;{ m_FrameNumber = value; }<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;#region Start and Stop Capture Functions</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Starts the video capture<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;/// &lt;param name=&quot;FrameNumber&quot;&gt;the frame number to start at. <br>
&nbsp;&nbsp;/// Set to 0 to let the control allocate the frame number&lt;/param&gt;<br>
&nbsp;&nbsp;public void Start(ulong FrameNum)<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;try<br>
&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;// for safety, call stop, just in case we are already running<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.Stop();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// setup a capture window<br>
&nbsp;&nbsp;&nbsp;&nbsp;mCapHwnd = capCreateCaptureWindowA(&quot;WebCap&quot;, 0, 0, 0, m_Width, m_Height, this.Handle.ToInt32(), 0);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// connect to the capture device<br>
&nbsp;&nbsp;&nbsp;&nbsp;Application.DoEvents();<br>
&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(mCapHwnd, WM_CAP_CONNECT, 0, 0);<br>
&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(mCapHwnd, WM_CAP_SET_PREVIEW, 0, 0);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// set the frame number<br>
&nbsp;&nbsp;&nbsp;&nbsp;m_FrameNumber = FrameNum;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// set the timer information<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.timer1.Interval = m_TimeToCapture_milliseconds;<br>
&nbsp;&nbsp;&nbsp;&nbsp;bStopped = false;<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.timer1.Start();<br>
&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;catch (Exception excep)<br>
&nbsp;&nbsp;&nbsp;{ <br>
&nbsp;&nbsp;&nbsp;&nbsp;MessageBox.Show(&quot;An error ocurred while starting the video capture. Check that your webcamera is connected properly and turned on.\r\n\n&quot; &#43; excep.Message);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.Stop();<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Stops the video capture<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;public void Stop()<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;try<br>
&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;// stop the timer<br>
&nbsp;&nbsp;&nbsp;&nbsp;bStopped = true;<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.timer1.Stop();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// disconnect from the video source<br>
&nbsp;&nbsp;&nbsp;&nbsp;Application.DoEvents();<br>
&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(mCapHwnd, WM_CAP_DISCONNECT, 0, 0);<br>
&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;catch (Exception excep)<br>
&nbsp;&nbsp;&nbsp;{ // don't raise an error here.<br>
&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;#region Video Capture Code</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Capture the next frame from the video feed<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;private void timer1_Tick(object sender, System.EventArgs e)<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;try<br>
&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;// pause the timer<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.timer1.Stop();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// get the next frame;<br>
&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(mCapHwnd, WM_CAP_GET_FRAME, 0, 0);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// copy the frame to the clipboard<br>
&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(mCapHwnd, WM_CAP_COPY, 0, 0);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// paste the frame into the event args image<br>
&nbsp;&nbsp;&nbsp;&nbsp;if (ImageCaptured != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// get from the clipboard<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tempObj = Clipboard.GetDataObject();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tempImg = (System.Drawing.Bitmap) tempObj.GetData(System.Windows.Forms.DataFormats.Bitmap);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* For some reason, the API is not resizing the video<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* feed to the width and height provided when the video<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* feed was started, so we must resize the image here<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x.WebCamImage = tempImg.GetThumbnailImage(m_Width, m_Height, null, System.IntPtr.Zero);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// raise the event<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.ImageCaptured(this, x);<br>
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// restart the timer<br>
&nbsp;&nbsp;&nbsp;&nbsp;Application.DoEvents();<br>
&nbsp;&nbsp;&nbsp;&nbsp;if (! bStopped)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.timer1.Start();<br>
&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;catch (Exception excep)<br>
&nbsp;&nbsp;&nbsp;{ <br>
&nbsp;&nbsp;&nbsp;&nbsp;MessageBox.Show(&quot;An error ocurred while capturing the video image. The video capture will now be terminated.\r\n\n&quot; &#43; excep.Message);<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.Stop(); // stop the process<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;private void WebCamCapture_Load(object sender, System.EventArgs e)<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;}<br>
&nbsp;}<br>
}<br>
<br>
<br>
<br>
<br>
[/code]</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/665a01791a2e438ea47f9dea012760e6#665a01791a2e438ea47f9dea012760e6</link>
		<pubDate>Wed, 03 Aug 2005 22:28:25 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/665a01791a2e438ea47f9dea012760e6#665a01791a2e438ea47f9dea012760e6</guid>
		<dc:creator>Programous</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Programous/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>That code works great, but, isn't there a way to copy the data into an image object more directly, to avoid using the clipboard (to gain some speed)</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/41357414e4224c8591d79dea0127610f#41357414e4224c8591d79dea0127610f</link>
		<pubDate>Thu, 02 Mar 2006 23:31:16 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/41357414e4224c8591d79dea0127610f#41357414e4224c8591d79dea0127610f</guid>
		<dc:creator>GurliGebis</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/GurliGebis/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>I want to know also..<br>
<br>
But there is a smaple in Coding4Fun... Check it out</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/a5c79e3db20f437792b79dea01276139#a5c79e3db20f437792b79dea01276139</link>
		<pubDate>Fri, 03 Mar 2006 00:42:08 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/a5c79e3db20f437792b79dea01276139#a5c79e3db20f437792b79dea01276139</guid>
		<dc:creator>Shark_M</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Shark_M/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>Interesting you'd refresh this thread.&nbsp; I was just thinking about writing a service that would use a webcam to detect motion in the room, then close the active screensaver.&nbsp; I got the inspiration when I walked into the room, bumped the table (thus the
 mouse) and the screensaver closed.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/7e0d35413a88420e91cd9dea01276162#7e0d35413a88420e91cd9dea01276162</link>
		<pubDate>Fri, 03 Mar 2006 02:22:19 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/7e0d35413a88420e91cd9dea01276162#7e0d35413a88420e91cd9dea01276162</guid>
		<dc:creator>tsilb</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/SlackmasterK/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>Any ideas on how to avoid the clipboard?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/f577ec0b2ac14dff8e359dea0127618a#f577ec0b2ac14dff8e359dea0127618a</link>
		<pubDate>Fri, 03 Mar 2006 17:10:40 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/f577ec0b2ac14dff8e359dea0127618a#f577ec0b2ac14dff8e359dea0127618a</guid>
		<dc:creator>GurliGebis</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/GurliGebis/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>Hi,<br>
<br>
Do you have a copy of the program using directx sdk in vb2005.net format??</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/9ca6bfbcc2a348d1910e9dea012761cb#9ca6bfbcc2a348d1910e9dea012761cb</link>
		<pubDate>Thu, 29 May 2008 09:33:02 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/9ca6bfbcc2a348d1910e9dea012761cb#9ca6bfbcc2a348d1910e9dea012761cb</guid>
		<dc:creator>airness132002</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/airness132002/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Programous said:</div><div class="quoteText">
<p>Hi. The fallowing is a C# file that will do it, iv reused this code a bunch of times over and I cant remember who the original author was.</p>
<p>[code language='C#']<br>
using System;<br>
using System.Collections;<br>
using System.ComponentModel;<br>
using System.Drawing;<br>
using System.Data;<br>
using System.Windows.Forms;<br>
using System.Runtime.InteropServices;</p>
<p>namespace WebCam_Capture<br>
{<br>
&nbsp;/// &lt;summary&gt;<br>
&nbsp;/// Summary description for UserControl1.<br>
&nbsp;/// &lt;/summary&gt;<br>
&nbsp;[System.Drawing.ToolboxBitmap(typeof(WebCamCapture), &quot;CAMERA.ICO&quot;)] // toolbox bitmap<br>
&nbsp;[Designer(&quot;Sytem.Windows.Forms.Design.ParentControlDesigner,System.Design&quot;, typeof(System.ComponentModel.Design.IDesigner))] // make composite<br>
&nbsp;public class WebCamCapture : System.Windows.Forms.UserControl<br>
&nbsp;{<br>
&nbsp;&nbsp;private System.ComponentModel.IContainer components;<br>
&nbsp;&nbsp;private System.Windows.Forms.Timer timer1;</p>
<p>&nbsp;&nbsp;// property variables<br>
&nbsp;&nbsp;private int m_TimeToCapture_milliseconds = 100;<br>
&nbsp;&nbsp;private int m_Width = 320;<br>
&nbsp;&nbsp;private int m_Height = 240;<br>
&nbsp;&nbsp;private int mCapHwnd;<br>
&nbsp;&nbsp;private ulong m_FrameNumber = 0;</p>
<p>&nbsp;&nbsp;// global variables to make the video capture go faster<br>
&nbsp;&nbsp;private WebCam_Capture.WebcamEventArgs x = new WebCam_Capture.WebcamEventArgs();<br>
&nbsp;&nbsp;private IDataObject tempObj;<br>
&nbsp;&nbsp;private System.Drawing.Image tempImg;<br>
&nbsp;&nbsp;private bool bStopped = true;</p>
<p>&nbsp;&nbsp;// event delegate<br>
&nbsp;&nbsp;public delegate void WebCamEventHandler (object source, WebCam_Capture.WebcamEventArgs e);<br>
&nbsp;&nbsp;// fired when a new image is captured<br>
&nbsp;&nbsp;public event WebCamEventHandler ImageCaptured; </p>
<p>&nbsp;&nbsp;#region API Declarations</p>
<p>&nbsp;&nbsp;[DllImport(&quot;user32&quot;, EntryPoint=&quot;SendMessage&quot;)]<br>
&nbsp;&nbsp;public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);</p>
<p>&nbsp;&nbsp;[DllImport(&quot;avicap32.dll&quot;, EntryPoint=&quot;capCreateCaptureWindowA&quot;)]<br>
&nbsp;&nbsp;public static extern int capCreateCaptureWindowA(string lpszWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hwndParent, int nID);</p>
<p>&nbsp;&nbsp;[DllImport(&quot;user32&quot;, EntryPoint=&quot;OpenClipboard&quot;)]<br>
&nbsp;&nbsp;public static extern int OpenClipboard(int hWnd);</p>
<p>&nbsp;&nbsp;[DllImport(&quot;user32&quot;, EntryPoint=&quot;EmptyClipboard&quot;)]<br>
&nbsp;&nbsp;public static extern int EmptyClipboard();</p>
<p>&nbsp;&nbsp;[DllImport(&quot;user32&quot;, EntryPoint=&quot;CloseClipboard&quot;)]<br>
&nbsp;&nbsp;public static extern int CloseClipboard();</p>
<p>&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;#region API Constants</p>
<p>&nbsp;&nbsp;public const int WM_USER = 1024;</p>
<p>&nbsp;&nbsp;public const int WM_CAP_CONNECT = 1034;<br>
&nbsp;&nbsp;public const int WM_CAP_DISCONNECT = 1035;<br>
&nbsp;&nbsp;public const int WM_CAP_GET_FRAME = 1084;<br>
&nbsp;&nbsp;public const int WM_CAP_COPY = 1054;</p>
<p>&nbsp;&nbsp;public const int WM_CAP_START = WM_USER;</p>
<p>&nbsp;&nbsp;public const int WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START &#43; 41;<br>
&nbsp;&nbsp;public const int WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START &#43; 42;<br>
&nbsp;&nbsp;public const int WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START &#43; 43;<br>
&nbsp;&nbsp;public const int WM_CAP_GET_VIDEOFORMAT = WM_CAP_START &#43; 44;<br>
&nbsp;&nbsp;public const int WM_CAP_SET_VIDEOFORMAT = WM_CAP_START &#43; 45;<br>
&nbsp;&nbsp;public const int WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START &#43; 46;<br>
&nbsp;&nbsp;public const int WM_CAP_SET_PREVIEW = WM_CAP_START &#43; 50;</p>
<p>&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;#region NOTES</p>
<p>&nbsp;&nbsp;/*<br>
&nbsp;&nbsp; * If you want to allow the user to change the display size and <br>
&nbsp;&nbsp; * color format of the video capture, call:<br>
&nbsp;&nbsp; * SendMessage (mCapHwnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0);<br>
&nbsp;&nbsp; * You will need to requery the capture device to get the new settings<br>
&nbsp;&nbsp;*/</p>
<p>&nbsp;&nbsp;#endregion</p>
<p><br>
&nbsp;&nbsp;public WebCamCapture()<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;// This call is required by the Windows.Forms Form Designer.<br>
&nbsp;&nbsp;&nbsp;InitializeComponent();<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Override the class's finalize method, so we can stop<br>
&nbsp;&nbsp;/// the video capture on exit<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;~WebCamCapture()<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;this.Stop();<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Clean up any resources being used.<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;protected override void Dispose( bool disposing )<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;if( disposing )<br>
&nbsp;&nbsp;&nbsp;{</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;if( components != null )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;components.Dispose();<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;base.Dispose( disposing );<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;#region Component Designer generated code<br>
&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Required method for Designer support - do not modify <br>
&nbsp;&nbsp;/// the contents of this method with the code editor.<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;private void InitializeComponent()<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;this.components = new System.ComponentModel.Container();<br>
&nbsp;&nbsp;&nbsp;this.timer1 = new System.Windows.Forms.Timer(this.components);<br>
&nbsp;&nbsp;&nbsp;// <br>
&nbsp;&nbsp;&nbsp;// timer1<br>
&nbsp;&nbsp;&nbsp;// <br>
&nbsp;&nbsp;&nbsp;this.timer1.Tick &#43;= new System.EventHandler(this.timer1_Tick);<br>
&nbsp;&nbsp;&nbsp;// <br>
&nbsp;&nbsp;&nbsp;// WebCamCapture<br>
&nbsp;&nbsp;&nbsp;// <br>
&nbsp;&nbsp;&nbsp;this.Name = &quot;WebCamCapture&quot;;<br>
&nbsp;&nbsp;&nbsp;this.Size = new System.Drawing.Size(342, 252);<br>
&nbsp;&nbsp;&nbsp;this.Load &#43;= new System.EventHandler(this.WebCamCapture_Load);</p>
<p>&nbsp;&nbsp;}<br>
&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;#region Control Properties</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// The time intervale between frame captures<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;public int TimeToCapture_milliseconds<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;get<br>
&nbsp;&nbsp;&nbsp;{ return m_TimeToCapture_milliseconds; }</p>
<p>&nbsp;&nbsp;&nbsp;set<br>
&nbsp;&nbsp;&nbsp;{ m_TimeToCapture_milliseconds = value; }<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// The height of the video capture image<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;public int CaptureHeight<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;get<br>
&nbsp;&nbsp;&nbsp;{ return m_Height; }<br>
&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;set<br>
&nbsp;&nbsp;&nbsp;{ m_Height = value; }<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// The width of the video capture image<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;public int CaptureWidth<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;get<br>
&nbsp;&nbsp;&nbsp;{ return m_Width; }</p>
<p>&nbsp;&nbsp;&nbsp;set<br>
&nbsp;&nbsp;&nbsp;{ m_Width = value; }<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// The sequence number to start at for the frame number. OPTIONAL<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;public ulong FrameNumber<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;get<br>
&nbsp;&nbsp;&nbsp;{ return m_FrameNumber; }</p>
<p>&nbsp;&nbsp;&nbsp;set<br>
&nbsp;&nbsp;&nbsp;{ m_FrameNumber = value; }<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;#region Start and Stop Capture Functions</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Starts the video capture<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;/// &lt;param name=&quot;FrameNumber&quot;&gt;the frame number to start at. <br>
&nbsp;&nbsp;/// Set to 0 to let the control allocate the frame number&lt;/param&gt;<br>
&nbsp;&nbsp;public void Start(ulong FrameNum)<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;try<br>
&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;// for safety, call stop, just in case we are already running<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.Stop();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// setup a capture window<br>
&nbsp;&nbsp;&nbsp;&nbsp;mCapHwnd = capCreateCaptureWindowA(&quot;WebCap&quot;, 0, 0, 0, m_Width, m_Height, this.Handle.ToInt32(), 0);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// connect to the capture device<br>
&nbsp;&nbsp;&nbsp;&nbsp;Application.DoEvents();<br>
&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(mCapHwnd, WM_CAP_CONNECT, 0, 0);<br>
&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(mCapHwnd, WM_CAP_SET_PREVIEW, 0, 0);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// set the frame number<br>
&nbsp;&nbsp;&nbsp;&nbsp;m_FrameNumber = FrameNum;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// set the timer information<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.timer1.Interval = m_TimeToCapture_milliseconds;<br>
&nbsp;&nbsp;&nbsp;&nbsp;bStopped = false;<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.timer1.Start();<br>
&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;catch (Exception excep)<br>
&nbsp;&nbsp;&nbsp;{ <br>
&nbsp;&nbsp;&nbsp;&nbsp;MessageBox.Show(&quot;An error ocurred while starting the video capture. Check that your webcamera is connected properly and turned on.\r\n\n&quot; &#43; excep.Message);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.Stop();<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Stops the video capture<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;public void Stop()<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;try<br>
&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;// stop the timer<br>
&nbsp;&nbsp;&nbsp;&nbsp;bStopped = true;<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.timer1.Stop();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// disconnect from the video source<br>
&nbsp;&nbsp;&nbsp;&nbsp;Application.DoEvents();<br>
&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(mCapHwnd, WM_CAP_DISCONNECT, 0, 0);<br>
&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;catch (Exception excep)<br>
&nbsp;&nbsp;&nbsp;{ // don't raise an error here.<br>
&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;#region Video Capture Code</p>
<p>&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// Capture the next frame from the video feed<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;private void timer1_Tick(object sender, System.EventArgs e)<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;try<br>
&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;// pause the timer<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.timer1.Stop();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// get the next frame;<br>
&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(mCapHwnd, WM_CAP_GET_FRAME, 0, 0);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// copy the frame to the clipboard<br>
&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(mCapHwnd, WM_CAP_COPY, 0, 0);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// paste the frame into the event args image<br>
&nbsp;&nbsp;&nbsp;&nbsp;if (ImageCaptured != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// get from the clipboard<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tempObj = Clipboard.GetDataObject();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tempImg = (System.Drawing.Bitmap) tempObj.GetData(System.Windows.Forms.DataFormats.Bitmap);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* For some reason, the API is not resizing the video<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* feed to the width and height provided when the video<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* feed was started, so we must resize the image here<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x.WebCamImage = tempImg.GetThumbnailImage(m_Width, m_Height, null, System.IntPtr.Zero);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// raise the event<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.ImageCaptured(this, x);<br>
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// restart the timer<br>
&nbsp;&nbsp;&nbsp;&nbsp;Application.DoEvents();<br>
&nbsp;&nbsp;&nbsp;&nbsp;if (! bStopped)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.timer1.Start();<br>
&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;catch (Exception excep)<br>
&nbsp;&nbsp;&nbsp;{ <br>
&nbsp;&nbsp;&nbsp;&nbsp;MessageBox.Show(&quot;An error ocurred while capturing the video image. The video capture will now be terminated.\r\n\n&quot; &#43; excep.Message);<br>
&nbsp;&nbsp;&nbsp;&nbsp;this.Stop(); // stop the process<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;#endregion</p>
<p>&nbsp;&nbsp;private void WebCamCapture_Load(object sender, System.EventArgs e)<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;}<br>
&nbsp;}<br>
}<br>
<br>
<br>
<br>
<br>
[/code]</p>
</div></blockquote>
<p>Hi I was tring to run the program form <a id="ctl00_MainPlaceHolder_EntryList_ctl06_EntryTemplate_UsernameLink" href="/Niners/Programous/">
<span id="ctl00_MainPlaceHolder_EntryList_ctl06_EntryTemplate_UsernameLabel"><span>Programous</span></span></a> but I get two errors when I try to run it</p>
<p>Error&nbsp;1&nbsp;The type or namespace name 'WebcamEventArgs' does not exist in the namespace 'WebCam_Capture' (are you missing an assembly reference?)&nbsp;C:\Users\Alin\Documents\Visual Studio 2005\Projects\WebCam_Capture\WebCam_Capture\Form1.cs&nbsp;37&nbsp;79&nbsp;WebCam_Capture</p>
<p>Anyone has an ideea how I can rezolve this?<br>
Thanks</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/6eb747ed9ec94373a5679dea0127623c#6eb747ed9ec94373a5679dea0127623c</link>
		<pubDate>Wed, 13 May 2009 11:49:17 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/6eb747ed9ec94373a5679dea0127623c#6eb747ed9ec94373a5679dea0127623c</guid>
		<dc:creator>Alin1x</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Alin1x/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">Alin1x said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">Programous said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>Hi I was tring to run the program form <a id="ctl00_MainPlaceHolder_EntryList_ctl06_EntryTemplate_UsernameLink" href="/Niners/Programous/">
<span id="ctl00_MainPlaceHolder_EntryList_ctl06_EntryTemplate_UsernameLabel"><span>Programous</span></span></a> but I get two errors when I try to run it</p>
<p>Error&nbsp;1&nbsp;The type or namespace name 'WebcamEventArgs' does not exist in the namespace 'WebCam_Capture' (are you missing an assembly reference?)&nbsp;C:\Users\Alin\Documents\Visual Studio 2005\Projects\WebCam_Capture\WebCam_Capture\Form1.cs&nbsp;37&nbsp;79&nbsp;WebCam_Capture</p>
<p>Anyone has an ideea how I can rezolve this?<br>
Thanks</p>
</div></blockquote>
<p>Any progress on that?</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/220c1b6cf75a4c81808d9dea01276280#220c1b6cf75a4c81808d9dea01276280</link>
		<pubDate>Sat, 01 Aug 2009 23:10:09 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/220c1b6cf75a4c81808d9dea01276280#220c1b6cf75a4c81808d9dea01276280</guid>
		<dc:creator>andreasbalzer</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/andreasbalzer/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">andreasbalzer said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">Alin1x said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>Any progress on that?</p>
</div></blockquote>
<p>test</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/06685218634f41bf85e39dea012762c2#06685218634f41bf85e39dea012762c2</link>
		<pubDate>Sun, 02 Aug 2009 05:11:31 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/06685218634f41bf85e39dea012762c2#06685218634f41bf85e39dea012762c2</guid>
		<dc:creator>damage-inc</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/damage-inc/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p><blockquote><div class="quoteUser">andreasbalzer said:</div><div class="quoteText">
<blockquote>
<div class="quoteUser">Alin1x said:</div>
<div class="quoteText">*snip*</div>
</blockquote>
<p>Any progress on that?</p>
</div></blockquote>
<p>you might want to check out touchless ( <a href="http://www.codeplex.com/touchless">
http://www.codeplex.com/touchless</a>&nbsp;) <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /> in an sdk för doing 2d blob tracking but it also includes code for getting frames from webcams</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/ce39fd77f0b04459b0359dea01276304#ce39fd77f0b04459b0359dea01276304</link>
		<pubDate>Tue, 04 Aug 2009 11:13:34 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/ce39fd77f0b04459b0359dea01276304#ce39fd77f0b04459b0359dea01276304</guid>
		<dc:creator>Allan Lindqvist</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/aL_/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Programatically Using A Webcam In C#</title>
		<description><![CDATA[<p>Try here : this site have C# and VB in WPF and WinForm ,it great !!.</p>
<p><a href="<a href="http://sites.google.com/site/webcamlibrarydotnet/">http&#58;&#47;&#47;sites.google.com&#47;site&#47;webcamlibrarydotnet&#47;</a>system/app/pages/sitemap/hierarchy"><a href="http://sites.google.com/site/webcamlibrarydotnet/">http&#58;&#47;&#47;sites.google.com&#47;site&#47;webcamlibrarydotnet&#47;</a></a></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/c3652c7f2a4246c2ae1c9dea01276345#c3652c7f2a4246c2ae1c9dea01276345</link>
		<pubDate>Fri, 11 Dec 2009 18:11:32 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/c3652c7f2a4246c2ae1c9dea01276345#c3652c7f2a4246c2ae1c9dea01276345</guid>
		<dc:creator>pongsakorn</dc:creator>
		<slash:comments>16</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pongsakorn/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>