

Webcam DirectShow 
High Level Code generation in C, C++, Visual C++ 
1 Webcam DirectShow
WebcamDirectShow01 download source WebcamDirectShow01 download exe 2 take a picture into a second window WebcamDirectShow02 download source WebcamDirectShow02 download exe 3 filter usage WebcamDirectShow03 download exe 4 edge detection WebcamDirectShow04 download exe if you are successful send an email, if one program can be useful for you write, any problem or suggestion? orgler@tin.it 
MFC Project with a subset from the AMCAP example 1)EnumerateAllDevices(): The programm first lists all video devices. 2)StartThisDevice(gx.rgpmVideoMenu[0]): If there is only one source start it otherwise chose the source and click on the "select source" button 3) InitCapFilters(): 4) BuildPreviewGraph(): 5) StartPreview(): The webcam is now connected with the actual dialog window The source was compiled with "Visual Studio 2010" plus SDK. With the button "take a picture" it is possible to copy the windows content in an array. In the function "CopyImageFromWindow()" we create first a Bitmap With "BitBlt" we transfer the actual window content in the Bitmap "capture_map" The function "GetDIBits" than copies the content of cature_map into "arrImage1" Now we can elaborate this "arrImage1" transfer elaborated data to another memory like "arrImage2" and view this data in the other dialog window. To view the data we must transfer the array data into device context from this window. We use the function "SetDIBitsToDevice" in "void CWin2Dlg::OnPaint()" A bitmap is organized in multiple of two. RGB colors needs 3 Bytes, so we have for each pixel 4 bytes. For every color one byte and one void byte. If you want to convert to grayscale a simple method is to sum all three pixels and than divide by 3. Better is to take the right percentages of the 3 colors. iGrayBlue = cBlue * 29; iGrayGreen = cGreen * 151; iGrayRed = cRed * 77; iGraySum = iGrayBlue + iGrayGreen + iGrayRed; iGraySum /= 256; 100 percent is equal 256. A value multiplied with 29 and than divided about 256 is equal to 11% A value multiplied with 152 and than divided about 256 is equal to 59% A value multiplied with 77 and than divided about 256 is equal to 30% The gray value is the sum of 11% blue, 59% green and 30% red. This calculation is an example of a fast integer arithmetic calculate image about 3x3 matrix High pass filter sharpening 0 1 0 1 4 1 iDiv=4 0 1 0 Low pass filter gauss 1 2 1 2 4 2 iDiv=16 1 2 1 Low pass filter median extract the median pixelvalue from 3x3 pixelmatrix replace the centered pixel with this value Take a picture with checkbox enabled "grayed" To find the edge you can use the Prewitt or the Sobel operator 1 0 +1 Gx = 1 0 +1 1 0 +1 