<?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>NGCoders - Next Generation Coders &#187; videoinput</title>
	<atom:link href="http://www.ngcoders.com/tag/videoinput/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ngcoders.com</link>
	<description>Personal Blog of Vikas Patial.</description>
	<lastBuildDate>Sun, 01 Jan 2012 20:13:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Capturing Video on windows using C++</title>
		<link>http://www.ngcoders.com/uncategorized/capture-video-using-videoinput-librar</link>
		<comments>http://www.ngcoders.com/uncategorized/capture-video-using-videoinput-librar#comments</comments>
		<pubDate>Sun, 13 Jun 2010 05:05:42 +0000</pubDate>
		<dc:creator>Vikas Patial</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[capture]]></category>
		<category><![CDATA[videoinput]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">http://www.ngcoders.com/?p=234</guid>
		<description><![CDATA[Using Webcam on windows should be easy, that is what i thought when i started out and wasted three days trying to get thing to work reliably. Most people used Video for Windows (VFW) in tutorials , but i found it very unreliable and crashing often, also when debugging it threw wired errors. Then I [...]]]></description>
			<content:encoded><![CDATA[<p>Using Webcam on windows should be easy, that is what i thought when i started out and wasted three days trying to get thing to work reliably. Most people used Video for Windows (VFW) in tutorials , but i found it very unreliable and crashing often, also when debugging it threw wired errors. Then I made up my mind to use the DirectX based DirectShow methods, Its needs DirectX SDK to build it and on downloading it and finally looking for the files i found that functionality have been moved to platform SDK. Anyhow i was not downloading another 4.5 GB of SDK to test if it worked. So after some Googling i found about the VideoInput library (uses DirectShow methods) which people sometimes use for OpenCV. I wished i had found it earlier , here is a small tutorial on hot to get started using it , since the original files which came with it did not work for me.There are a whole host of features supported so you can explore the documentation for more . </p>
<p><a href="http://muonics.net/school/spring05/videoInput/" target="_blank">VideoInput Library homepage</a></p>
<p>How to use webcam/tv tuner/capture cards in VC++ to capture video and take pictures &#8211; </p>
<p>1. Create simple Dialog based MFC project.</p>
<p>2. In the dialog make a Picture control and a Button , Picture control will Display the Video stream and the button will be used to capture a snapshot.Change Picture control to type Bitmap and attach a CStatic variable to it.</p>
<p>3. Now we will use a simple timer ( WM_TIMER ) to update the image being captured there are better way but this should do for a tutorial. In OnInitDialog() set the timer to refresh at say 10 times a second,</p>
<p><code>SetTimer(NULL,100,NULL)</code></p>
<p>4. Include the video videoInput.h header file. Also add the videoinput.lib in the linker input and for ignore library atlthunk.lib ( if it causes errors ).</p>
<p>5. Initialize the device using VideoInput API . </p>
<p><code>	// in header<br />
	int device,width,height,size;<br />
	videoInput VI;<br />
	unsigned char * captureBuffer;</p>
<p>	// in InitDoalog<br />
	device = 0; // first webcam<br />
	VI.setupDevice(device,320,240); // 320 x 240 resolution </p>
<p>	width  = VI.getWidth(device);<br />
	height = VI.getHeight(device);<br />
	size   = VI.getSize(device); // size to initialize buffer</p>
<p>	captureBuffer = new unsigned char[size];  // our capturebuffer </code></p>
<p>6. Now lets capture video and display frame in the OnTimer</p>
<p><code>	if(VI.isFrameNew(device))<br />
	{<br />
		VI.getPixels(device,captureBuffer, false, true);<br />
		DisplayImage(&amp;m_webcam,height,width,captureBuffer);<br />
	}</code></p>
<p>7. There is also example of how to capture image using libjpeg, please download the source and check it out. </p>
Note: There is a file embedded within this post, please visit this post to download the file.
]]></content:encoded>
			<wfw:commentRss>http://www.ngcoders.com/uncategorized/capture-video-using-videoinput-librar/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

