全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:3979
推到 Plurk!
推到 Facebook!

找出Webcam的範圍解析度

缺席
gso033
一般會員


發表:6
回覆:17
積分:4
註冊:2008-11-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-03-11 15:15:52 IP:140.117.xxx.xxx 訂閱
目前在學習DirectShow,已經可以開啟webcam
但是要增新如AMcap中的功能如video Capture Pin可以找出webcam的範圍解析度
這部份不太會...................
不之是否可以提示ㄧ下,要從哪下手?????
ikk
尊榮會員


發表:4
回覆:413
積分:768
註冊:2003-06-30

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-03-12 09:02:21 IP:163.28.xxx.xxx 訂閱
有幾個重點...
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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-03-12 15:39:06 IP:140.117.xxx.xxx 訂閱
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]
編輯記錄
gso033 重新編輯於 2009-03-12 15:39:35, 註解 無‧
gso033 重新編輯於 2009-03-12 15:42:09, 註解 無‧
gso033 重新編輯於 2009-03-12 15:43:07, 註解 無‧
gso033 重新編輯於 2009-03-12 15:44:23, 註解 無‧
gso033 重新編輯於 2009-03-12 15:46:26, 註解 無‧
gso033 重新編輯於 2009-03-12 15:48:06, 註解 無‧
ikk
尊榮會員


發表:4
回覆:413
積分:768
註冊:2003-06-30

發送簡訊給我
#4 引用回覆 回覆 發表時間:2009-03-12 16:13:28 IP:163.28.xxx.xxx 訂閱
接續我上面的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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2009-03-13 02:17:00 IP:140.117.xxx.xxx 訂閱
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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2009-03-13 08:35:59 IP:163.28.xxx.xxx 訂閱
你執行看看, 有缺哪些宣告, 再自行補足即可.....
也可更加了解這些function的作用..
------
FPGA驗證, FPGA開發平台, http://smims.com
gso033
一般會員


發表:6
回覆:17
積分:4
註冊:2008-11-26

發送簡訊給我
#7 引用回覆 回覆 發表時間:2009-03-13 09:28:28 IP:140.117.xxx.xxx 訂閱
ikk,你好~
請問程式中的 "&pmtUsingConfig"
我要宣告他??

[code cpp]
// Get now using format
hr = pSC->GetFormat( &pmtUsingConfig );

[/code]
編輯記錄
gso033 重新編輯於 2009-03-13 09:58:06, 註解 無‧
ikk
尊榮會員


發表:4
回覆:413
積分:768
註冊:2003-06-30

發送簡訊給我
#8 引用回覆 回覆 發表時間:2009-03-13 09:31:38 IP:163.28.xxx.xxx 訂閱
要呀 是要傳入 pmtUsingConfig
------
FPGA驗證, FPGA開發平台, http://smims.com
monkeystop
一般會員


發表:1
回覆:7
積分:11
註冊:2008-02-13

發送簡訊給我
#9 引用回覆 回覆 發表時間:2009-03-13 10:02:37 IP:118.167.xxx.xxx 訂閱
在你開啟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

發送簡訊給我
#10 引用回覆 回覆 發表時間:2009-03-13 10:03:47 IP:140.117.xxx.xxx 訂閱
ikk,你好==
1.是這種方式宣告嗎
2.可以請問你是用哪一版BCB嗎
因為此程式中的ShowTypeMsg,ShowSizeMsg不是指令嗎????
[code cpp]
AM_MEDIA_TYPE *pmtUsingConfig ;
hr = pSC->GetFormat( &pmtUsingConfig );
[/code]
ikk
尊榮會員


發表:4
回覆:413
積分:768
註冊:2003-06-30

發送簡訊給我
#11 引用回覆 回覆 發表時間:2009-03-13 10:09:18 IP:163.28.xxx.xxx 訂閱
1.是的是這樣宣告沒錯...
2.那只是字串而已...用來輸出的...不要的話, 就註解掉.
------
FPGA驗證, FPGA開發平台, http://smims.com
gso033
一般會員


發表:6
回覆:17
積分:4
註冊:2008-11-26

發送簡訊給我
#12 引用回覆 回覆 發表時間:2009-03-13 10:37:06 IP:140.117.xxx.xxx 訂閱
你好,
我是用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

發送簡訊給我
#13 引用回覆 回覆 發表時間:2009-03-13 10:42:31 IP:140.117.xxx.xxx 訂閱
請問你是指已下哪種方法??
1.
[code cpp]
sprintf("RGB24");
[/code]
2.
[code cpp]
//sprintf(ShowTypeMsg,"RGB24");
[/code]


===================引 用 ikk 文 章===================
1.是的是這樣宣告沒錯...
2.那只是字串而已...用來輸出的...不要的話, 就註解掉.
ikk
尊榮會員


發表:4
回覆:413
積分:768
註冊:2003-06-30

發送簡訊給我
#14 引用回覆 回覆 發表時間:2009-03-13 10:46:31 IP:163.28.xxx.xxx 訂閱
1.這種方法 是語法錯誤吧...
2.是註解的意思沒錯...
------
FPGA驗證, FPGA開發平台, http://smims.com
monkeystop
一般會員


發表:1
回覆:7
積分:11
註冊:2008-02-13

發送簡訊給我
#15 引用回覆 回覆 發表時間:2009-03-13 10:59:57 IP:118.167.xxx.xxx 訂閱
你是BCB吧?!
我是用DSPACK元件來做的..看你要不要試試看
gso033
一般會員


發表:6
回覆:17
積分:4
註冊:2008-11-26

發送簡訊給我
#16 引用回覆 回覆 發表時間:2009-03-13 11:04:46 IP:140.117.xxx.xxx 訂閱
對,我是用BCB5
我可以試看看
因為是初學者,所以請多多指教
DSPACK元件是指EZCAM...嗎??

===================引 用 monkeystop 文 章===================
你是BCB吧?!
我是用DSPACK元件來做的..看你要不要試試看
編輯記錄
gso033 重新編輯於 2009-03-13 11:15:01, 註解 無‧
gso033
一般會員


發表:6
回覆:17
積分:4
註冊:2008-11-26

發送簡訊給我
#17 引用回覆 回覆 發表時間:2009-03-13 11:21:33 IP:140.117.xxx.xxx 訂閱
你好,
如果我都將他註解那if跟else就沒有東西了阿???
UtilDeleteMediaType(pmtConfig)ˇ的"UtilDeleteMediaType"也怪的???
===================引 用 ikk 文 章===================
1.這種方法 是語法錯誤吧...
2.是註解的意思沒錯...
ikk
尊榮會員


發表:4
回覆:413
積分:768
註冊:2003-06-30

發送簡訊給我
#18 引用回覆 回覆 發表時間:2009-03-13 11:25:47 IP:163.28.xxx.xxx 訂閱
我拿出這些code是希望你能舉一反三...
if裡面要做什麼, 是看你code要怎麼寫.
UtilDeleteMediaType()
在DXSDK的sample下有這個function, serach一下吧...
------
FPGA驗證, FPGA開發平台, http://smims.com
monkeystop
一般會員


發表:1
回覆:7
積分:11
註冊:2008-02-13

發送簡訊給我
#19 引用回覆 回覆 發表時間:2009-03-13 11:36:25 IP:118.167.xxx.xxx 訂閱
用站內收尋DSPACK吧
裡面會有很多你需要的資訊

P.S DSPACK != EZCAM (ezcam是用vfw寫的)

===================引 用 gso033 文 章===================
對,我是用BCB5
我可以試看看
因為是初學者,所以請多多指教
DSPACK元件是指EZCAM...嗎??

gso033
一般會員


發表:6
回覆:17
積分:4
註冊:2008-11-26

發送簡訊給我
#20 引用回覆 回覆 發表時間:2009-03-13 11:46:18 IP:140.117.xxx.xxx 訂閱
了解
可是我發生了一件事
就是安裝完又單獨執行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

發送簡訊給我
#21 引用回覆 回覆 發表時間:2009-03-13 13:07:46 IP:140.117.xxx.xxx 訂閱
我是用DX90SDK
也看了他的Sample,但是他的語法是用C
所以看不太懂?????????
在DX90SDK的sample下有這個function, serach沒有找到"UtilDeleteMediaType"
===================引 用 ikk 文 章===================
我拿出這些code是希望你能舉一反三...
if裡面要做什麼, 是看你code要怎麼寫.
UtilDeleteMediaType()
在DXSDK的sample下有這個function, serach一下吧...
系統時間:2024-04-20 13:43:08
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!