//------------------------------------------------------------------ // Vision-based Game Class Sample Program 10 // An example of adding some objects into the capture window // // Date: 2010/04/19 // by Yeuan-Kuen Lee, CSIE, MCU // http://vgc-yklee.blogspot.com //------------------------------------------------------------------ // 全域變數宣告 unsigned char ucTimeMark[25][30][3]; LRESULT CALLBACK FrameCallBackObjectAdding( HWND hwndCapture, PVIDEOHDR lpvhdr ); /------------------------------------------------------------------------------------------------------------------------- // Callback Function 的主體程式 (我們要程式自動執行的程式) LRESULT CALLBACK FrameCallBackObjectAdding( HWND hwndCapture, PVIDEOHDR lpvhdr ) { iFrameCount++; CaptureData = LPVIDEOHDR(lpvhdr); ptrCapture = CaptureData->lpData; k = 0; for (i=iCapWindowHeight-1;i>=0;i--) { for (j=0;j=20)&&(i<35)&&(j>=20)&&(j<145)) { ptrCapture[k] = 0; ptrCapture[k+1] = 255; ptrCapture[k+2] = 255; } if ((i>=20)&&(i<35)&&(j>=175)&&(j<300)) { ptrCapture[k] = 0; ptrCapture[k+1] = 255; ptrCapture[k+2] = 0; } if ((i>=15)&&(i<40)&&(j>=145)&&(j<175)) { ptrCapture[k] = ucTimeMark[i-15][j-145][0]; ptrCapture[k+1] = ucTimeMark[i-15][j-145][1]; ptrCapture[k+2] = ucTimeMark[i-15][j-145][2]; } k = k+3; } } return 0; } //------------------------------------------------------------------------------------------------------------------------- void __fastcall TForm1::PreviewCallbackFunction1Click(TObject *Sender) { if ( bCallbackOnFrame ) { capSetCallbackOnFrame(hwndVideo, NULL); PreviewCallbackFunction1->Caption = "Turn On Preview Callback Function"; bCallbackOnFrame = false; } else { capSetCallbackOnFrame(hwndVideo, &FrameCallBackObjectAdding); PreviewCallbackFunction1->Caption = "Turn Off Preview Callback Function"; bCallbackOnFrame = true; } } //------------------------------------------------------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { imTimeMark->Picture->LoadFromFile("Time60S.bmp"); for (i=0;i<25;i++) for (j=0;j<30;j++) { ucTimeMark[i][j][0] = GetBValue(imTimeMark->Canvas->Pixels[j][i]); ucTimeMark[i][j][1] = GetGValue(imTimeMark->Canvas->Pixels[j][i]); ucTimeMark[i][j][2] = GetRValue(imTimeMark->Canvas->Pixels[j][i]); } } //-------------------------------------------------------------------------------------------------------------------------