direct show 应用 用direct show 做视频采集程序,知道 怎么预览,怎么存成avi文件了,可 没看明白 怎么 单帧采集,难道也是用回调或是消息处理,那 单帧采集应该触发什么消息啊 有知道的吗 谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 要设置一个回调函数,例如:CComPtr<ISampleGrabber> m_pGrabber;////////////////////////////////////////////////////////////////////////////////////// create a sample grabberhr = m_pGrabber.CoCreateInstance(CLSID_SampleGrabber);if(!m_pGrabber){ AfxMessageBox("Fail to create SampleGrabber, maybe qedit.dll is not registered?"); return;}CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase(m_pGrabber);//设置视频格式AM_MEDIA_TYPE mt;ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));mt.majortype = MEDIATYPE_Video;mt.subtype = MEDIASUBTYPE_RGB24;hr = m_pGrabber->SetMediaType(&mt);if(FAILED(hr)){ AfxMessageBox("Fail to set media type!"); return;}hr = g_pGraph->AddFilter(pGrabBase, L"Grabber");if(FAILED(hr)){ AfxMessageBox("Fail to put sample grabber in graph"); return;}// try to render preview/capture pin// 通常情况下,当每个filter只有一个输出pin和一个输入pin时,RenderStream方法就才适用。hr = g_pCapture->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pSrcFilter, pGrabBase, NULL);if(FAILED(hr)) hr = g_pCapture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pSrcFilter, pGrabBase, NULL);if(FAILED(hr)){ AfxMessageBox("Can’t build the graph"); return;}hr = m_pGrabber->GetConnectedMediaType( &mt );if ( FAILED( hr) ){ AfxMessageBox("Failt to read the connected media type"); return;}VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;mCB.SetVideoBase(this);FreeMediaType(mt);hr = m_pGrabber->SetBufferSamples( FALSE );hr = m_pGrabber->SetOneShot( FALSE );//设置快照hr = m_pGrabber->SetCallback( &mCB, 1 );//设置回调 /*//输出到文件IBaseFilter *pMux;hr = g_pCapture->SetOutputFileName( &MEDIASUBTYPE_Avi, // Specifies AVI for the target file. L"C:\\Example.avi", // File name. &pMux, // Receives a pointer to the mux. NULL); // (Optional) Receives a pointer to the file sink. hr = g_pCapture->RenderStream( &PIN_CATEGORY_CAPTURE, // Pin category. &MEDIATYPE_Video, // Media type. pSrcFilter, // Capture filter. NULL, // Intermediate filter (optional). pMux); // Mux or file sink filter. // Release the mux filter. pMux->Release();*/ mCB 在回调里面 怎么取图像呢 ISampleGrabber 用它的 方法吗 我第一次 用 多谢你们拉 关于字符串之间的转换问题,有点搞不懂,想请教各位! 在服务程序中,不能写注册表? 毕业5年再考研? 关于类的问题。。请大家帮忙。。20分只是心意 ★★[紧急求教!]在VC中怎么把“类”写成DLL然后在VB中调用?★★ 江湖救急!宽带太他妈不好了. SQL7.0中,存贮图像(.bmp或.jpg)时其字段应定义为image还是varBinary?其长度又应该是多少呀? windows核心编程(第四版)关于消息队列问题 哪里有控件源程序? 列表控件锁定最下面一行,不能响应使用鼠标中键下翻的问题 很怪的问题,不能否可以实现????关于缓冲区。。。 关于收费邮箱
CComPtr<ISampleGrabber> m_pGrabber;////////////////////////////////////////////////////////////////////////////////////
// create a sample grabber
hr = m_pGrabber.CoCreateInstance(CLSID_SampleGrabber);
if(!m_pGrabber)
{
AfxMessageBox("Fail to create SampleGrabber, maybe qedit.dll is not registered?");
return;
}CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase(m_pGrabber);//设置视频格式
AM_MEDIA_TYPE mt;
ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
mt.majortype = MEDIATYPE_Video;
mt.subtype = MEDIASUBTYPE_RGB24;hr = m_pGrabber->SetMediaType(&mt);
if(FAILED(hr))
{
AfxMessageBox("Fail to set media type!");
return;
}hr = g_pGraph->AddFilter(pGrabBase, L"Grabber");
if(FAILED(hr))
{
AfxMessageBox("Fail to put sample grabber in graph");
return;
}// try to render preview/capture pin
// 通常情况下,当每个filter只有一个输出pin和一个输入pin时,RenderStream方法就才适用。
hr = g_pCapture->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pSrcFilter, pGrabBase, NULL);
if(FAILED(hr))
hr = g_pCapture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pSrcFilter, pGrabBase, NULL);if(FAILED(hr))
{
AfxMessageBox("Can’t build the graph");
return;
}hr = m_pGrabber->GetConnectedMediaType( &mt );
if ( FAILED( hr) )
{
AfxMessageBox("Failt to read the connected media type");
return;
}VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;
mCB.SetVideoBase(this);
FreeMediaType(mt);hr = m_pGrabber->SetBufferSamples( FALSE );
hr = m_pGrabber->SetOneShot( FALSE );//设置快照
hr = m_pGrabber->SetCallback( &mCB, 1 );//设置回调 /*
//输出到文件
IBaseFilter *pMux;
hr = g_pCapture->SetOutputFileName(
&MEDIASUBTYPE_Avi, // Specifies AVI for the target file.
L"C:\\Example.avi", // File name.
&pMux, // Receives a pointer to the mux.
NULL); // (Optional) Receives a pointer to the file sink. hr = g_pCapture->RenderStream(
&PIN_CATEGORY_CAPTURE, // Pin category.
&MEDIATYPE_Video, // Media type.
pSrcFilter, // Capture filter.
NULL, // Intermediate filter (optional).
pMux); // Mux or file sink filter. // Release the mux filter.
pMux->Release();*/
我第一次 用 多谢你们拉