//in the initialization function:
//-------------------------------------
hWndC = capCreateCaptureWindow ( "Capture Window", WS_CHILD |WS_DLGFRAME , 50, 50,320,240,GetSafeHwnd(), 11011);
if(hWndC)
capDriverConnect (hWndC, 0); // 0 ->means default driver.
else
{
AfxMessageBox("Error Cammera is not connected!");
exit(1);
}
//--------------------------------------
void CVidtestDlg::OnOK()
{
HDC hdc;
int X = 1;
int Y = 1;
unsigned long RGB;
//grab a framefrom webcam, save it as a bmp file for confirmation of successful grab
capGrabFrame(hWndC);
capFileSaveDIB(hWndC,"MyFrameGrab_HelloWorld.bmp");
//get device context
hdc = ::GetDC(hWndC);
//get a pixel from the fram grab...?
RGB = GetPixel(hdc, X, Y);
//send RGB to a file so I can see what it is
ofstream fout;
fout.open("PixelData.dat", ios::app);
fout << RGB << endl;
fout.close( );
/*
//try to break up RGB assuming it's a 32-bit double word
red = ((0x00FF0000 & RGB) >> 16) << 0;
green = ((0x0000FF00 & RGB) >> 8) << 0;
blue = ((0x000000FF & RGB) >> 0) << 0;
//show the pixel value in my GUI dialog
m_RGB = red;
m_RGB2 = green;
m_RGB3 = blue;
UpdateData(FALSE);
*/
}
|