Webcam 照相存檔後再讀出發生問題 |
答題得分者是:aquarius
|
Patil
一般會員 發表:4 回覆:7 積分:2 註冊:2010-02-23 發送簡訊給我 |
我使用的是VFW的函式去使webcam連接然後拍照存成bmp檔案
再透過Image物件將bmp檔案秀出並對檔案作處理 連接webcam 拍照都沒有問題 但是最後要利用 Image1->Picture->LoadFromFile("TEST.bmp")卻發生問題 (List Index Out of Bounds(0) 因為不知道如何用CALLBACK將stream資料即時秀在Image物件上 所以只好透過存檔讀檔方式 程式碼如下~ 希望能有前輩可以指導一下~ //---------------------------------------------------------------------------
|
Patil
一般會員 發表:4 回覆:7 積分:2 註冊:2010-02-23 發送簡訊給我 |
|
aquarius
資深會員 發表:3 回覆:347 積分:330 註冊:2003-05-21 發送簡訊給我 |
不是很清楚你想問的問題是 statusbar 的錯誤, 還是想取得影像的方式?
取得影像, 用 VFW 應只有 capFileSaveDIB , 不過有在別的地方看到和你不同的用法, 你可參考看看 [code cpp] CFileDialog fileopen(FALSE,_T("DIB"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T("*.dib|*.dib|*.jpeg|*.jpeg|*.PNG|*.png|")); if ( IDOK == fileopen.DoModal() ) { CString path(""); CString ext(""); path = fileopen.GetPathName(); ext = fileopen.GetFileExt(); capGrabFrameNoStop(m_caphwnd); capFileSaveDIB(m_caphwnd,path.GetString()); if ( ext != CString("DIB") && ext != CString("dib") ) { CImage myImage; myImage.Load(path.GetString()); myImage.Save(path.GetString()); } } [/code]
------
水瓶男的blog: http://791909.blogspot.com |
Patil
一般會員 發表:4 回覆:7 積分:2 註冊:2010-02-23 發送簡訊給我 |
===================引 用 aquarius 文 章=================== 不是很清楚你想問的問題是 statusbar 的錯誤, 還是想取得影像的方式? 取得影像, 用 VFW 應只有 capFileSaveDIB , 不過有在別的地方看到和你不同的用法, 你可參考看看 [code cpp] ?CFileDialog fileopen(FALSE,_T("DIB"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T("*.dib|*.dib|*.jpeg|*.jpeg|*.PNG|*.png|")); ?if ( IDOK == fileopen.DoModal() ) { ? CString path(""); ? CString ext(""); ? path = fileopen.GetPathName(); ? ext = fileopen.GetFileExt(); ? capGrabFrameNoStop(m_caphwnd); ? capFileSaveDIB(m_caphwnd,path.GetString()); ? if ( ext != CString("DIB") && ext != CString("dib") ) {? ?? CImage myImage; ?? myImage.Load(path.GetString()); ?? myImage.Save(path.GetString()); ? } ?} [/code] 那請問有用法是用指標來接Webcam中的即時影像資訊,然後再透過指標將資料送到Image1物件的方式嗎? |
aquarius
資深會員 發表:3 回覆:347 積分:330 註冊:2003-05-21 發送簡訊給我 |
試試這個, 沒拿去 BCB下編譯, 不過應該沒寫錯... :)
可以把 Panel 上的影像存到 bmp 中. [code cpp] Graphics::TBitmap *bmp = new Graphics::TBitmap; bmp->Width = Panel1->Width; bmp->Height = Panel1->Height; HDC hDC=GetDC(Panel1->Handle); BitBlt(bmp->Canvas->Handle,0,0,bmp->Width,bmp->Height,hDC,0,0,0xCC0020); //SRCCOPY bmp->SaveToFile("panel.bmp"); ReleaseDC(Panel1->Handle , hDC); delete bmp; [/code]
------
水瓶男的blog: http://791909.blogspot.com |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |