Advertisement
Advertisement
| 05.07.2008 at 11:18AM PDT, ID: 23383736 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: |
//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);
*/
}
|