掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
フレームレートを取得するには? (ID:52548)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
早速のお返事ありがとうございます。 >レンダリングフィルターからIQualProp インターフェイス >を取得してget_AvgFrameRate()をCALLする。 最近DirectShowをはじめたばかりでわからないことが多ので、申し訳ありませんがもう少し詳しく教えていただけないでしょうか(フレームレートをメインダイアログ上のエディットボックスに表示させる方法などもできればお願いいたします)。 プログラムはDirectShow8.1bSDKのサンプルのStillCapを使用して作成しています。よろしくお願いします。 HRESULT CStillCap::InitStillGraph() { //******************************ここから追加******************************// HRESULT hr; // create a filter graph // hr = m_pGraph.CoCreateInstance( CLSID_FilterGraph ); if( !m_pGraph ) { Error( TEXT("Could not create filter graph") ); return E_FAIL; } // get whatever capture device exists // CComPtr< IBaseFilter > pCap; GetDefaultCaptureDevice( &pCap ); if( !pCap ) { Error( TEXT("No video capture device was detected on your system.\r\n\r\n") TEXT("This sample requires a functional video capture device, such\r\n") TEXT("as a USB web camera.") ); return E_FAIL; } // add the capture filter to the graph // hr = m_pGraph->AddFilter( pCap, L"Cap" ); if( FAILED( hr ) ) { Error( TEXT("Could not put capture device in graph")); return E_FAIL; } // create a sample grabber // hr = m_pGrabber.CoCreateInstance( CLSID_SampleGrabber ); if( !m_pGrabber ) { Error( TEXT("Could not create SampleGrabber (is qedit.dll registered?)")); return hr; } CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase( m_pGrabber ); // force it to connect to video, 24 bit // CMediaType VideoType; VideoType.SetType( &MEDIATYPE_Video ); VideoType.SetSubtype( &MEDIASUBTYPE_RGB24 ); hr = m_pGrabber->SetMediaType( &VideoType ); // shouldn't fail if( FAILED( hr ) ) { Error( TEXT("Could not set media type")); return hr; } // add the grabber to the graph // hr = m_pGraph->AddFilter( pGrabBase, L"Grabber" ); if( FAILED( hr ) ) { Error( TEXT("Could not put sample grabber in graph")); return hr; } // find the two pins and connect them // IPin * pCapOut = GetOutPin( pCap, 0 ); IPin * pGrabIn = GetInPin( pGrabBase, 0 ); hr = m_pGraph->Connect( pCapOut, pGrabIn ); if( FAILED( hr ) ) { Error( TEXT("Could not connect capture pin #0 to grabber.\r\n") TEXT("Is the capture device being used by another application?")); return hr; } // render the sample grabber output pin, so we get a preview window // IPin * pGrabOut = GetOutPin( pGrabBase, 0 ); hr = m_pGraph->Render( pGrabOut ); if( FAILED( hr ) ) { Error( TEXT("Could not render sample grabber output pin")); return hr; } // ask for the connection media type so we know how big // it is, so we can write out bitmaps // AM_MEDIA_TYPE mt; hr = m_pGrabber->GetConnectedMediaType( &mt ); if ( FAILED( hr) ) { Error( TEXT("Could not read the connected media type")); return hr; } VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat; mCB.m_pCleaningRobotDlg = this; mCB.m_lWidth = vih->bmiHeader.biWidth; mCB.m_lHeight = vih->bmiHeader.biHeight; FreeMediaType( mt ); // don't buffer the samples as they pass through // m_pGrabber->SetBufferSamples( FALSE ); // only grab one at a time, stop stream after // grabbing one sample // m_pGrabber->SetOneShot( FALSE ); // set the callback, so we can grab the one sample // m_pGrabber->SetCallback( &mCB, 1 ); // find the video window and stuff it in our window // CComQIPtr< IVideoWindow, &IID_IVideoWindow > pWindow = m_pGraph; if( !pWindow ) { Error( TEXT("Could not get video window interface")); return E_FAIL; } // set up the preview window to be in our dialog // instead of floating popup // HWND hwndPreview = NULL; GetDlgItem( IDC_LIVE_VIDEO_PREVIEW_PICT, &hwndPreview ); RECT rc; ::GetWindowRect( hwndPreview, &rc ); pWindow->put_Owner( (OAHWND) hwndPreview ); pWindow->put_Left( 0 ); pWindow->put_Top( 0 ); pWindow->put_Width( rc.right - rc.left ); pWindow->put_Height( rc.bottom - rc.top ); pWindow->put_Visible( OATRUE ); pWindow->put_WindowStyle( WS_CHILD | WS_CLIPSIBLINGS ); // Add our graph to the running object table, which will allow // the GraphEdit application to "spy" on our graph #ifdef REGISTER_FILTERGRAPH hr = AddGraphToRot(m_pGraph, &g_dwGraphRegister); if (FAILED(hr)) { Error(TEXT("Failed to register filter graph with ROT!")); g_dwGraphRegister = 0; } #endif // run the graph // CComQIPtr< IMediaControl, &IID_IMediaControl > pControl = m_pGraph; hr = pControl->Run( ); if( FAILED( hr ) ) { Error( TEXT("Could not run graph")); return hr; } UpdateStatus(_T("ライブビデオのプレビュー")); return 0; //******************************ここまで追加******************************// }
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.