CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

follow us on Twitter

Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















Home >> Visual C++ / C++ >> Miscellaneous >> Miscellaneous >> Video


Video For Windows Wrapper Class (CVFWImageProcessor)
Rating:

Ken Varn (view profile)
August 29, 2001

Performs DIB video capture to memory with or without preview mode.

.

Environment: VC6, NT, W2K, Win98, Win95.
(continued)



One of the main reasons why I wrote this class was to simplify the process of capturing images from a Video For Windows camera device. The Platform SDK Video for Windows (VFW) API did not seem to adequately document the VFW functions in the way that I wanted to implement them. My goal was to capture images from a capture device into a memory DIB. The VFW functions only seemed to be geared around saving captured images directly to disk. I wanted to be able to run image diagnostics on the captured contents without having to reload it from disk after the capture (very inneficient). I also did not want to deal with preview mode and trying to capture from that interface.

Microsoft did not appear to have built an MFC class around the VFW APIs. Instead, they chose to only utilize COM under the Windows Media Technologies to interface to VFW. So, I thought that I would try to develop a simplified class to the VFW APIs. The result is the CVFWImageProcessor class.

VFW APIs utilize a window handle as the point of reference for most of its functions which I encapsulated in the class. Most VFW API calls are dispatched under the windows message queue. In order to capture the DIB to memory instead of to disk, I decided to create a seperate thread that would be used to dispatch VFW message. This would allow me to syncronize the VFW callback functions without relying on the main message queue of my windows appliation.

Most of the work in the CVFWImageProcessor class focusses around the simplification of memory DIB capture. I added some additional member functions as wrappers around already existing VFW APIs. I did not incorporate all VFW APIs, just the ones that I thought were important for my application. I am sure that others may want to add or modify these members.

All of the testing that I performed was with Webcams that had no on-board compression. I am not sure how devices with built-in compression would function under this implementation.

Note that preview mode does not have to be active in order to capture a DIB to memory.

The download package includes a sample windows dialog application that shows how to use some of the features of the class.

I am well aware that there are probably ways that this class can be improved. My main goal was to illustrate a method for doing memory DIB captures with an easy to use class interface.

// Sample source on implemented CVFWImageProcessor class
// to capture a single DIB frame to memory.

CVFWImageProcessor VFWProc;
PBITMAPINFO pBitmap;
ULONG BitmapSize;

VFWProc.Initialize(); // Intialize first found VFW device.

pBitmap = NULL; // CaptureDIB will automatically
                // allocate this if it is set to NULL.

// Capture an image from the capture device.
if (VFWProc.CaptureDIB(&pBitmap, 0, &BitmapSize))
{
  // pBitmap captured successfully. Do whatever with it.

  delete pBitmap;    // Delete it when done.
}

VFWProc.Destroy();   // Done using VFW object.

UPDATES - August 29, 2001

The following changes were made:

  1. Removed DebugRelease configuration. This had a reference to GEAR32PD.LIB which is not used by the project.
  2. Removed all commented out sections concerning JPEG capture. JPEG capture is only available when I used the ImageGear package from AccuSoft which I could not redistribute. It was commented out, but was causing some confusion. So I removed it altogether.
  3. Corrected a lockup problem when using functions CVFWImageProcessor::DlgVideoDisplay(), CVFWImageProcessor::DlgVideoFormat(), and CVFWImageProcessor::DlgVideoSource().

Downloads

Download demo project - 19 Kb

About the Author
Currently developing Digital Video Recorder software for security surveilance under Windows using Visual C++ C#, and Microsoft .NET Framework.

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed







RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
Resolution - hundsmiachn (07/03/2008)
How can I change the bitmap file's format to 640x480 ? - Safiye (06/13/2007)
video conferencing - Legacy CodeGuru (02/19/2004)
Great. But how do i watch my plant grow ? - Legacy CodeGuru (02/13/2004)
very nice class, but troubles with AVI - Legacy CodeGuru (02/12/2004)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES