找出Webcam的範圍解析度 |
缺席
|
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
|
ikk
尊榮會員 發表:4 回覆:413 積分:768 註冊:2003-06-30 發送簡訊給我 |
有幾個重點...
IAMStreamConfig * m_pVSC; 1. pBuild->FindInterface( &PIN_CATEGORY_CAPTURE, // Preview pin. &MEDIATYPE_Video, // Any media type. pVCap, // Pointer to the capture filter. IID_IAMStreamConfig, (void**)&m_pVSC); 2. // // Get now using format // m_pVSC->GetFormat( &pmtUsingConfig ); 3. // // Get how many support format // m_pVSC->GetNumberOfCapabilities(&iCount, &iSize);
------
FPGA驗證, FPGA開發平台, http://smims.com |
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
ikk,你好!
我目前是參考別人寫的,如下: 但是這各方法是寫死的,無法找出webcam的解析度範圍 還是有點不太懂你說的方法????? [code cpp] BOOL SetFormat(ICaptureGraphBuilder2* pBuilder, IBaseFilter* pCap, longlWidth, long lHeight, unsigned short iColorBit, __int64 iRate ) { VIDEOINFOHEADER* phead; IAMStreamConfig* iconfig = NULL; HRESULT hr; hr = pBuilder -> FindInterface( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, pCap, IID_IAMStreamConfig, (void **)&iconfig ); if ( hr != NOERROR ) { hr = pBuilder -> FindInterface( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pCap, IID_IAMStreamConfig, (void **)&iconfig); } if ( FAILED( hr ) ) return FALSE; AM_MEDIA_TYPE* pmt; if ( iconfig -> GetFormat( &pmt ) != S_OK ) return FALSE; if ( pmt -> formattype == FORMAT_VideoInfo) { phead = ( VIDEOINFOHEADER* )pmt -> pbFormat; phead -> bmiHeader.biBitCount = iColorBit; phead -> bmiHeader.biWidth = lWidth; phead -> bmiHeader.biHeight = lHeight; phead -> bmiHeader.biSizeImage = _DIBSIZE(phead->bmiHeader); // phead -> bmiHeader.biSizeImage = lWidth * lHeight * iColorBit / 8; phead -> AvgTimePerFrame = (REFERENCE_TIME)(10000000/iRate); // fps if ( ( hr = iconfig -> SetFormat( pmt ) ) != S_OK ) return FALSE; } iconfig -> Release(); iconfig = NULL; MyFreeMediaType( *pmt ); return TRUE; } [/code] |
ikk
尊榮會員 發表:4 回覆:413 積分:768 註冊:2003-06-30 發送簡訊給我 |
接續我上面的code
[code cpp] // Check the size to make sure we pass in the correct structure. if ((unsigned)iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) { // Use the video capabilities structure. for (int iFormat = 0; iFormat < iCount; iFormat ) { VIDEO_STREAM_CONFIG_CAPS scc; AM_MEDIA_TYPE *pmtConfig; hr = m_pVSC->GetStreamCaps(iFormat, &pmtConfig, (BYTE*)&scc); if (SUCCEEDED(hr)) { pHead = ( VIDEOINFOHEADER* )pmtConfig->pbFormat; if ( pmtConfig->subtype == MEDIASUBTYPE_RGB24 ) { sprintf(ShowTypeMsg,"RGB24"); sprintf(ShowSizeMsg,"%d X %d (RGB24)", pHead->bmiHeader.biWidth, pHead->bmiHeader.biHeight); } else if ( pmtConfig->subtype == MEDIASUBTYPE_I420 ) { sprintf(ShowTypeMsg,"I420"); sprintf(ShowSizeMsg,"%d X %d (I420)", pHead->bmiHeader.biWidth, pHead->bmiHeader.biHeight); } else { UtilDeleteMediaType(pmtConfig); continue; //sprintf(ShowSizeMsg,"0X%X = %d X %d", pmtConfig->subtype, HEADER(pmtConfig->pbFormat)->biWidth, HEADER(pmtConfig->pbFormat)->biHeight); } /* Examine the format, and possibly use it. */ // Delete the media type when you are done. UtilDeleteMediaType(pmtConfig); } } } [/code]
------
FPGA驗證, FPGA開發平台, http://smims.com |
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
ikk,你好~~
請問我這先宣告對嗎?? 因為執行後有很多變數沒宣告 但我不知道要將那些變數如何宣告,可以請你教我嗎?? [code cpp] BOOL SetFormat(ICaptureGraphBuilder2* pBuilder, IBaseFilter* pCap, long lWidth, long lHeight, unsigned short iColorBit, __int64 iRate ) { HRESULT hr; IAMStreamConfig* pSC; hr = pBuild->FindInterface( &PIN_CATEGORY_CAPTURE, // Preview pin. &MEDIATYPE_Video, // Any media type. pCap, // Pointer to the capture filter. IID_IAMStreamConfig,(void**)&pSC); // Get now using format hr = pSC->GetFormat( &pmtUsingConfig ); // Get how many support format hr = pSC->GetNumberOfCapabilities(&iCount, &iSize); // Check the size to make sure we pass in the correct structure. if ((unsigned)iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) { // Use the video capabilities structure. for (int iFormat = 0; iFormat < iCount; iFormat ) { VIDEO_STREAM_CONFIG_CAPS scc; AM_MEDIA_TYPE *pmtConfig; hr = m_pVSC->GetStreamCaps(iFormat, &pmtConfig, (BYTE*)&scc); if (SUCCEEDED(hr)) { pHead = ( VIDEOINFOHEADER* )pmtConfig->pbFormat; if ( pmtConfig->subtype == MEDIASUBTYPE_RGB24 ) { sprintf(ShowTypeMsg,"RGB24"); sprintf(ShowSizeMsg,"%d X %d (RGB24)", pHead->bmiHeader.biWidth, pHead->bmiHeader.biHeight); } else if ( pmtConfig->subtype == MEDIASUBTYPE_I420 ) { sprintf(ShowTypeMsg,"I420"); sprintf(ShowSizeMsg,"%d X %d (I420)", pHead->bmiHeader.biWidth, pHead->bmiHeader.biHeight); } else { UtilDeleteMediaType(pmtConfig); continue; //sprintf(ShowSizeMsg,"0X%X = %d X %d", pmtConfig->subtype, HEADER(pmtConfig->pbFormat)->biWidth, HEADER(pmtConfig->pbFormat)->biHeight); } /* Examine the format, and possibly use it. */ // Delete the media type when you are done. UtilDeleteMediaType(pmtConfig); } } } } [/code]
編輯記錄
gso033 重新編輯於 2009-03-13 09:23:57, 註解 無‧
|
ikk
尊榮會員 發表:4 回覆:413 積分:768 註冊:2003-06-30 發送簡訊給我 |
|
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
|
ikk
尊榮會員 發表:4 回覆:413 積分:768 註冊:2003-06-30 發送簡訊給我 |
|
monkeystop
一般會員 發表:1 回覆:7 積分:11 註冊:2008-02-13 發送簡訊給我 |
在你開啟webcam的程式碼中加入
[code cpp] Filter1->BaseFilter->Moniker = SysDev->GetMoniker(((TComboBox *)Sender)->ItemIndex); FilterGraph1->Active = true; ICaptureGraphBuilder2 *Graph = NULL; IBaseFilter *SourceFilter = NULL; IBaseFilter *VideoFilter = NULL; IBaseFilter *CaptureFilter=NULL; CheckDSError(FilterGraph1->QueryInterface(IID_ICaptureGraphBuilder2, &Graph)); CheckDSError(VideoWindow1->QueryInterface(IID_IBaseFilter, &VideoFilter)); CheckDSError(SampleGrabber1->QueryInterface(IID_IBaseFilter, &CaptureFilter)); CheckDSError(Filter1->QueryInterface(IID_IBaseFilter, &SourceFilter)); TPinList * PinList = new TPinList( SourceFilter ); ShowPinPropertyPage((unsigned int)Form1->Handle,PinList->Items[0]); Graph->RenderStream(&PIN_CATEGORY_PREVIEW, NULL, SourceFilter, NULL, VideoFilter); Graph->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, SourceFilter, NULL, CaptureFilter); FilterGraph1->Play(); Graph->Release(); VideoFilter->Release(); SourceFilter->Release(); delete PinList; [/code] 你要的功能在這兩行 TPinList * PinList = new TPinList( SourceFilter ); ShowPinPropertyPage((unsigned int)Form1->Handle,PinList->Items[0]); |
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
|
ikk
尊榮會員 發表:4 回覆:413 積分:768 註冊:2003-06-30 發送簡訊給我 |
|
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
你好,
我是用webcam_dx寫一個副程式去呼叫 所以你敎我的這各用法我要用在哪??? ===================引 用 monkeystop 文 章=================== 在你開啟webcam的程式碼中加入 [code cpp] Filter1->BaseFilter->Moniker = SysDev->GetMoniker(((TComboBox *)Sender)->ItemIndex); FilterGraph1->Active = true; ICaptureGraphBuilder2 *Graph = NULL; IBaseFilter *SourceFilter = NULL; IBaseFilter *VideoFilter = NULL; IBaseFilter *CaptureFilter=NULL; CheckDSError(FilterGraph1->QueryInterface(IID_ICaptureGraphBuilder2, &Graph)); CheckDSError(VideoWindow1->QueryInterface(IID_IBaseFilter, &VideoFilter)); CheckDSError(SampleGrabber1->QueryInterface(IID_IBaseFilter, &CaptureFilter)); CheckDSError(Filter1->QueryInterface(IID_IBaseFilter, &SourceFilter)); TPinList * PinList = new TPinList( SourceFilter ); ShowPinPropertyPage((unsigned int)Form1->Handle,PinList->Items[0]); Graph->RenderStream(&PIN_CATEGORY_PREVIEW, NULL, SourceFilter, NULL, VideoFilter); Graph->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, SourceFilter, NULL, CaptureFilter); FilterGraph1->Play(); Graph->Release(); VideoFilter->Release(); SourceFilter->Release(); delete PinList; [/code] 你要的功能在這兩行 TPinList * PinList = new TPinList( SourceFilter ); ShowPinPropertyPage((unsigned int)Form1->Handle,PinList->Items[0]); |
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
|
ikk
尊榮會員 發表:4 回覆:413 積分:768 註冊:2003-06-30 發送簡訊給我 |
|
monkeystop
一般會員 發表:1 回覆:7 積分:11 註冊:2008-02-13 發送簡訊給我 |
|
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
對,我是用BCB5
我可以試看看 因為是初學者,所以請多多指教 DSPACK元件是指EZCAM...嗎?? ===================引 用 monkeystop 文 章=================== 你是BCB吧?! 我是用DSPACK元件來做的..看你要不要試試看
編輯記錄
gso033 重新編輯於 2009-03-13 11:15:01, 註解 無‧
|
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
|
ikk
尊榮會員 發表:4 回覆:413 積分:768 註冊:2003-06-30 發送簡訊給我 |
|
monkeystop
一般會員 發表:1 回覆:7 積分:11 註冊:2008-02-13 發送簡訊給我 |
|
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
了解
可是我發生了一件事 就是安裝完又單獨執行VideoCapture是沒問題 可是我執行demo卻出現如下的錯誤,這樣我到底是有安裝成功嗎??? 目前發現DSPACK在BCB5好像無法使用 [C Error] austream.h(114): E2293 ) expected [C Error] austream.h(117): E2293 ) expected [C Error] austream.h(245): E2108 Improper use of typedef 'IAudioMediaStream' [C Error] austream.h(245): E2451 Undefined symbol 'This' [C Error] austream.h(245): E2293 ) expected [C Error] austream.h(258): E2293 ) expected [C Error] austream.h(581): E2293 ) expected [C Error] austream.h(584): E2293 ) expected [C Error] austream.h(676): E2108 Improper use of typedef 'IAudioData' [C Error] austream.h(676): E2293 ) expected [C Error] austream.h(689): E2293 ) expected [C Error] MainForm.cpp(33): E2085 Invalid pointer addition ===================引 用 monkeystop 文 章=================== 用站內收尋DSPACK吧 裡面會有很多你需要的資訊 P.S DSPACK != EZCAM (ezcam是用vfw寫的) ===================引 用 gso033 文 章=================== 對,我是用BCB5 我可以試看看 因為是初學者,所以請多多指教 DSPACK元件是指EZCAM...嗎??
編輯記錄
gso033 重新編輯於 2009-03-13 13:09:01, 註解 無‧
|
gso033
一般會員 發表:6 回覆:17 積分:4 註冊:2008-11-26 發送簡訊給我 |
我是用DX90SDK
也看了他的Sample,但是他的語法是用C 所以看不太懂????????? 在DX90SDK的sample下有這個function, serach沒有找到"UtilDeleteMediaType" ===================引 用 ikk 文 章=================== 我拿出這些code是希望你能舉一反三... if裡面要做什麼, 是看你code要怎麼寫. UtilDeleteMediaType() 在DXSDK的sample下有這個function, serach一下吧... |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |