Click here to Skip to main content
15,896,606 members
Articles / Programming Languages / C++

Capturing Video from Web-camera on Windows 7 and 8 by using Media Foundation

Rate me:
Please Sign up or sign in to vote.
4.96/5 (25 votes)
10 Apr 2013CPOL5 min read 281.5K   33.1K   71  
Simple lib for capturing video from web-camera by using Media Foundation
��<!DOCTYPE html>

<!-- saved from url=(0014)about:internet -->

 <html xmlns:msxsl="urn:schemas-microsoft-com:xslt"><head><meta content="en-us" http-equiv="Content-Language" /><meta content="text/html; charset=utf-16" http-equiv="Content-Type" /><link type="text/css" rel="stylesheet" href="_UpgradeReport_Files\UpgradeReport.css" /><title _locID="ConversionReport0">

          BG5B > ?5@5=>A5

        </title><script type="text/javascript" language="javascript"> 

          

            // Startup 

            // Hook up the the loaded event for the document/window, to linkify the document content

            var startupFunction = function() { linkifyElement("messages"); };

            

            if(window.attachEvent)

            {

              window.attachEvent('onload', startupFunction);

            }

            else if (window.addEventListener) 

            {

              window.addEventListener('load', startupFunction, false);

            }

            else 

            {

              document.addEventListener('load', startupFunction, false);

            } 

            

            // Toggles the visibility of table rows with the specified name 

            function toggleTableRowsByName(name)

            {

               var allRows = document.getElementsByTagName('tr');

               for (i=0; i < allRows.length; i++)

               {

                  var currentName = allRows[i].getAttribute('name');

                  if(!!currentName && currentName.indexOf(name) == 0)

                  {

                      var isVisible = allRows[i].style.display == ''; 

                      isVisible ? allRows[i].style.display = 'none' : allRows[i].style.display = '';

                  }

               }

            }

            

            function scrollToFirstVisibleRow(name) 

            {

               var allRows = document.getElementsByTagName('tr');

               for (i=0; i < allRows.length; i++)

               {

                  var currentName = allRows[i].getAttribute('name');

                  var isVisible = allRows[i].style.display == ''; 

                  if(!!currentName && currentName.indexOf(name) == 0 && isVisible)

                  {

                     allRows[i].scrollIntoView(true); 

                     return true; 

                  }

               }

               

               return false;

            }

            

            // Linkifies the specified text content, replaces candidate links with html links 

            function linkify(text)

            {

                 if(!text || 0 === text.length)

                 {

                     return text; 

                 }



                 // Find http, https and ftp links and replace them with hyper links 

                 var urlLink = /(http|https|ftp)\:\/\/[a-zA-Z0-9\-\.]+(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\/\\\+&%\$#\=~;\{\}])*/gi;

                 

                 return text.replace(urlLink, '<a href="$&">$&</a>') ;

            }

            

            // Linkifies the specified element by ID

            function linkifyElement(id)

            {

                var element = document.getElementById(id);

                if(!!element)

                {

                  element.innerHTML = linkify(element.innerHTML); 

                }

            }

            

            function ToggleMessageVisibility(projectName)

            {

              if(!projectName || 0 === projectName.length)

              {

                return; 

              }

              

              toggleTableRowsByName("MessageRowClass" + projectName);

              toggleTableRowsByName('MessageRowHeaderShow' + projectName);

              toggleTableRowsByName('MessageRowHeaderHide' + projectName); 

            }

            

            function ScrollToFirstVisibleMessage(projectName)

            {

              if(!projectName || 0 === projectName.length)

              {

                return; 

              }

              

              // First try the 'Show messages' row

              if(!scrollToFirstVisibleRow('MessageRowHeaderShow' + projectName))

              {

                // Failed to find a visible row for 'Show messages', try an actual message row 

                scrollToFirstVisibleRow('MessageRowClass' + projectName); 

              }

            }

           </script></head><body><h1 _locID="ConversionReport">

          BG5B > <83@0F88 - SimpleCapture</h1><div id="content"><h2 _locID="OverviewTitle">17>@</h2><div id="overview"><table><tr><th></th><th _locID="ProjectTableHeader">@>5:B</th><th _locID="PathTableHeader">CBL</th><th _locID="ErrorsTableHeader">H81:8</th><th _locID="WarningsTableHeader">@54C?@5645=8O</th><th _locID="MessagesTableHeader">!>>1I5=8O</th></tr><tr><td><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Warning.png" alt="Warning" /></td><td><strong><a href="#SimpleCapture">SimpleCapture</a></strong></td><td>SimpleCapture.vcproj</td><td class="textCentered"><a>0</a></td><td class="textCentered"><a href="#SimpleCaptureWarning">5</a></td><td class="textCentered"><a href="#" onclick="ScrollToFirstVisibleMessage('SimpleCapture'); return false;">2</a></td></tr><tr><td><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Warning.png" alt="Warning" /></td><td><strong><a href="#Solution"><span _locID="OverviewSolutionSpan"> 5H5=85</span></a></strong></td><td>SimpleCapture.sln</td><td class="textCentered"><a>0</a></td><td class="textCentered"><a href="#SolutionWarning">1</a></td><td class="textCentered"><a href="#" onclick="ScrollToFirstVisibleMessage('Solution'); return false;">2</a></td></tr></table></div><h2 _locID="SolutionAndProjectsTitle"> 5H5=85 8 ?@>5:BK</h2><div id="messages"><a name="SimpleCapture" /><h3>SimpleCapture</h3><table><tr id="SimpleCaptureHeaderRow"><th></th><th class="messageCell" _locID="MessageTableHeader">!>>1I5=85</th></tr><tr name="WarningRowClassSimpleCapture"><td><a name="SimpleCaptureWarning" /><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Warning.png" alt="Warning" /></td><td class="messageCell"><strong>SimpleCapture.vcproj:

        </strong><span>VCWebServiceProxyGeneratorTool 1>;LH5 =5 ?>445@68205BAO. -B>B 8=AB@C<5=B 1K; C40;5= 87 ?0@0<5B@>2 ?@>5:B0.</span></td></tr><tr name="WarningRowClassSimpleCapture"><td><a name="SimpleCaptureWarning" /><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Warning.png" alt="Warning" /></td><td class="messageCell"><strong>SimpleCapture.vcproj:

        </strong><span>B@81CB "Detect64BitPortabilityProblems" B8?0 "VCCLCompilerTool" 2 MB>9 25@A88 =5 ?>445@68205BAO 8 1K; C40;5= 2 ?@>F5AA5 ?@5>1@07>20=8O.</span></td></tr><tr name="WarningRowClassSimpleCapture"><td><a name="SimpleCaptureWarning" /><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Warning.png" alt="Warning" /></td><td class="messageCell"><strong>SimpleCapture.vcproj:

        </strong><span>B@81CB "Detect64BitPortabilityProblems" B8?0 "VCCLCompilerTool" 2 MB>9 25@A88 =5 ?>445@68205BAO 8 1K; C40;5= 2 ?@>F5AA5 ?@5>1@07>20=8O.</span></td></tr><tr name="WarningRowClassSimpleCapture"><td><a name="SimpleCaptureWarning" /><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Warning.png" alt="Warning" /></td><td class="messageCell"><strong>SimpleCapture.vcproj:

        </strong><span>B@81CB "Detect64BitPortabilityProblems" B8?0 "VCCLCompilerTool" 2 MB>9 25@A88 =5 ?>445@68205BAO 8 1K; C40;5= 2 ?@>F5AA5 ?@5>1@07>20=8O.</span></td></tr><tr name="WarningRowClassSimpleCapture"><td><a name="SimpleCaptureWarning" /><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Warning.png" alt="Warning" /></td><td class="messageCell"><strong>SimpleCapture.vcproj:

        </strong><span>B@81CB "Detect64BitPortabilityProblems" B8?0 "VCCLCompilerTool" 2 MB>9 25@A88 =5 ?>445@68205BAO 8 1K; C40;5= 2 ?@>F5AA5 ?@5>1@07>20=8O.</span></td></tr><tr name="MessageRowHeaderShowSimpleCapture"><td><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" /></td><td class="messageCell"><a _locID="ShowAdditionalMessages" href="#" name="SimpleCaptureMessage" onclick="ToggleMessageVisibility('SimpleCapture'); return false;">

          >:070BL 2 4>?>;=8B5;L=K5 A>>1I5=8O

        </a></td></tr><tr name="MessageRowClassSimpleCapture" style="display: none"><td><a name="SimpleCaptureMessage" /><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" alt="Message" /></td><td class="messageCell"><strong>SimpleCapture.vcproj:

        </strong><span>@5>1@07>20=85 D09;0 ?@>5:B0 "C:\Users\Logan\Documents\Visual Studio 2012\Projects\SimpleCapture\SimpleCapture.vcproj".</span></td></tr><tr name="MessageRowClassSimpleCapture" style="display: none"><td><a name="SimpleCaptureMessage" /><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" alt="Message" /></td><td class="messageCell"><strong>SimpleCapture.vcproj:

        </strong><span>@5>1@07>20=85 2 =>2K9 D09; ?@>5:B0 "C:\Users\Logan\Documents\Visual Studio 2012\Projects\SimpleCapture\SimpleCapture.vcxproj" 7025@H5=>.</span></td></tr><tr style="display: none" name="MessageRowHeaderHideSimpleCapture"><td><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" /></td><td class="messageCell"><a _locID="HideAdditionalMessages" href="#" name="SimpleCaptureMessage" onclick="ToggleMessageVisibility('SimpleCapture'); return false;">

          !:@KBL 2 4>?>;=8B5;L=K5 A>>1I5=8O

        </a></td></tr></table><a name="Solution" /><h3 _locID="ProjectDisplayNameHeader"> 5H5=85</h3><table><tr id="SolutionHeaderRow"><th></th><th class="messageCell" _locID="MessageTableHeader">!>>1I5=85</th></tr><tr name="WarningRowClassSolution"><td><a name="SolutionWarning" /><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Warning.png" alt="Warning" /></td><td class="messageCell"><strong>SimpleCapture.sln:

        </strong><span>!@540 Visual Studio 4>;6=0 2=5AB8 2 MB>B ?@>5:B =5DC=:F8>=0;L=K5 87<5=5=8O, GB>1K 53> <>6=> 1K;> >B:@K20BL 2 MB>9 25@A88 8 2 Visual Studio 2010 A ?0:5B>< >1=>2;5=8O 1 (SP1) 157 CI5@10 4;O ?>2545=8O ?@>5:B0.</span></td></tr><tr name="MessageRowHeaderShowSolution"><td><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" /></td><td class="messageCell"><a _locID="ShowAdditionalMessages" href="#" name="SolutionMessage" onclick="ToggleMessageVisibility('Solution'); return false;">

          >:070BL 2 4>?>;=8B5;L=K5 A>>1I5=8O

        </a></td></tr><tr name="MessageRowClassSolution" style="display: none"><td><a name="SolutionMessage" /><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" alt="Message" /></td><td class="messageCell"><strong>SimpleCapture.sln:

        </strong><span>#A?5H=> A>740=0 @575@2=0O :>?8O D09;0 C:\Users\Logan\Documents\Visual Studio 2012\Projects\SimpleCapture\Backup\SimpleCapture.sln</span></td></tr><tr name="MessageRowClassSolution" style="display: none"><td><a name="SolutionMessage" /><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" alt="Message" /></td><td class="messageCell"><strong>SimpleCapture.sln:

        </strong><span>5@5=>A @5H5=8O CA?5H=> 7025@H5=</span></td></tr><tr style="display: none" name="MessageRowHeaderHideSolution"><td><img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" /></td><td class="messageCell"><a _locID="HideAdditionalMessages" href="#" name="SolutionMessage" onclick="ToggleMessageVisibility('Solution'); return false;">

          !:@KBL 2 4>?>;=8B5;L=K5 A>>1I5=8O

        </a></td></tr></table></div></div></body></html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions