[問題] BCB webcam
遇到的問題: (題意請描述清楚)
我的程式要從WebCam的影像擷取資料 然後作影像處理
如果我將顯示Webcam影像的視窗關掉 主程式就接不到影像資料了!!
我的程式有兩個form一個是主要的Form1和顯示目前視訊影像的Form2
但是關於擷取視訊影像的code都在Form1的cpp , Form2只是顯示而已
我的問題就是 Form2上顯示視訊影像的Panel必須要"有一點在螢幕上露出來"
才能讓主程式接到影像
可是如果Panel完全被Form1蓋住 主程式就接不到影像了...
希望得到的正確結果:
因為到時候是要讓Form1全螢幕執行 不能顯示Form2...
希望能在不顯示那個Panel的情況下 還能讓視訊讀到畫面~
開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux)
Borland C++ Builder
相關CODE:
以下的程式碼都在Form1的cpp
//我的程式是要讓視訊抓到紅外線燈
LRESULT CALLBACK VideoData( HWND hWnd,LPVIDEOHDR lpVHdr)
{
static int i = 0;
for (int y = 0; y <ResolutionHeight; ++y) {
for (int x = 0; x <ResolutionWidth; ++x) {
B1[x][y] =
(int)lpVHdr->lpData[3 * ( (ResolutionHeight-1-y)*ResolutionWidth + x )]; // Blue
G1[x][y] =
(int)lpVHdr->lpData[3 * ( (ResolutionHeight-1-y) * ResolutionWidth + x ) + 1]; // Green
R1[x][y] =
(int)lpVHdr->lpData[3 * ( (ResolutionHeight-1-y) * ResolutionWidth + x ) + 2]; // Red
if (R1[x][y] > threshold)
{
DrawBOX->StatusBar1->Panels->Items[1]->Text="攝影機座標:"+IntToStr(x)+","+IntToStr(y);
}
}
}
// DrawBOX->LabelRGB->Caption = i++;
return (LRESULT) TRUE;
}
//這是一個開啟視訊的按鈕
void __fastcall TDrawBOX::OpenButtonClick(TObject *Sender)
{
capDriverDisconnect(capw1);
capw1=capCreateCaptureWindow( "My cap1",
WS_CHILD | WS_VISIBLE,
0,0,ShowInformation->Panel1->Width,
ShowInformation->Panel1->Height, //ShowInformation就是Form2
ShowInformation->Panel1->Handle,
0);
bool connect_flag=false;
for( int i = 0; i < 10; i++ )
{
connect_flag = capDriverConnect( capw1, i );
if(connect_flag) break;
}
if(!connect_flag)
{
ShowMessage("攝影機A連接失敗..");
capDriverDisconnect(capw1);
return;
}
capGrabFrameNoStop(capw1);
capOverlay(capw1,true);
capPreview(capw1,true);
capPreviewScale(capw1,true);
capPreviewRate(capw1, 1000/30);
capSetCallbackOnFrame(capw1, &VideoData);
ShowInformation->Show();
}
謝謝!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.50.29
※ 編輯: rick7712 來自: 140.115.50.29 (03/24 13:45)
※ 編輯: rick7712 來自: 140.115.50.29 (03/24 13:48)
※ 編輯: rick7712 來自: 140.115.50.29 (03/24 13:48)
※ 編輯: rick7712 來自: 140.115.50.29 (03/24 13:49)
※ 編輯: rick7712 來自: 140.115.50.29 (03/24 14:01)
※ 編輯: rick7712 來自: 140.115.50.29 (03/24 14:01)
→
03/24 21:56, , 1F
03/24 21:56, 1F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章