wince 下摄像头分辩率的调节

勇敢爱 2010-03-26 05:43:10
我的代码和下面的这个差不多,因为公司不让所以不能发,不好意思。
1.初始化
HRESULT hr = S_OK;
hr = CoInitializeEx(NULL,COINIT_MULTITHREADED );
if(FAILED(hr))
{
OutputDebugString(L"CoInitializeEx Failed!\r\n");
CoUninitialize();
return FALSE;
}

// 创建ICaptureGraphBuilder2接口
hr = CoCreateInstance(CLSID_CaptureGraphBuilder, NULL, CLSCTX_INPROC, IID_ICaptureGraphBuilder2,(void**)&pCaptureGraphBuild);
if(FAILED(hr))
{
OutputDebugString(L"CoCreateInstance CaptureGraphBuilder Failed!\r\n");
return FALSE;
}

// 创建IGraphBuilder接口
hr = CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC,IID_IGraphBuilder,(void**)&pGraphBuilder);
if(FAILED(hr))
{
OutputDebugString(L"CoCreateInstance GraphBuilder Failed!\r\n");
return FALSE;
}

hr = pCaptureGraphBuild->SetFiltergraph(pGraphBuilder);
if(FAILED(hr))
{
OutputDebugString(L"pCaptureGraphBuild SetFiltergraph GraphBuilder Failed!\r\n");
return FALSE;
}
2.查找Camera
GUID guidCamera = { 0xCB998A05, 0x122C, 0x4166, 0x84, 0x6A, 0x93, 0x3E, 0x4D, 0x7E, 0x3C, 0x86 };
// Note about the above: The driver material doesn't ship as part of the SDK. This GUID is hardcoded
// here to be able to enumerate the camera drivers and pass the name of the driver to the video capture filter

di.dwSize = sizeof(di);

handle = FindFirstDevice( DeviceSearchByGuid, &guidCamera, &di );
if(( handle == NULL ) || ( di.hDevice == NULL ))
{
OutputDebugString(L"FindCameraDevice Failed!\r\n");
return FALSE;
}

FindClose( handle );
varCamName = di.szLegacyName;
PropBag.Write( _T("VCapName"), &varCamName );

hr = CoCreateInstance(CLSID_VideoCapture, NULL, CLSCTX_INPROC,IID_IBaseFilter, (void**)&pBaseFilter);
if(FAILED(hr))
{
OutputDebugString(L"CoCreateInstance pBaseFilter Failed!\r\n");
return FALSE;
}

hr = pBaseFilter->QueryInterface(IID_IPersistPropertyBag,(void**)&pPropertyBag );
if(FAILED(hr))
{
OutputDebugString(L"pBaseFilter QueryInterface pPropertyBag Failed!\r\n");
return FALSE;
}
pPropertyBag->Load( &PropBag, NULL );

hr = pGraphBuilder->AddFilter(pBaseFilter,_T("Video Capture Filter"));
if(FAILED(hr))
{
OutputDebugString(L"pGraphBuilder AddFilter pBaseFilter Failed!\r\n");
return FALSE;
}

hr = pCaptureGraphBuild->RenderStream (&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,pBaseFilter, NULL, NULL);
if (FAILED(hr))
{
OutputDebugString(TEXT("Couldn't render the video capture stream.\r\n"));
pBaseFilter->Release();
return hr;
}

pBaseFilter->Release();
3.连接
HRESULT hr = S_OK;
IMediaControl* pMediaControl = NULL;
IVideoWindow* pVideoWindow = NULL;

//查询IMediaControl接口
hr = pGraphBuilder->QueryInterface(IID_IMediaControl,(void**)&pMediaControl);
if(FAILED(hr))
{
OutputDebugString(L"pGraphBuilder QueryInterface pMediaControl Failed!\r\n");
return FALSE;
}

//查询IVideoWindow
hr = pGraphBuilder->QueryInterface(IID_IVideoWindow,(void**)&pVideoWindow);
if(FAILED(hr))
{
OutputDebugString(L"pGraphBuilder QueryInterface pVideoWindow Failed!\r\n");
pMediaControl->Release();
return FALSE;
}

hr = pGraphBuilder->QueryInterface(IID_IMediaEventEx, (void **)&pMediaEvent);
if(FAILED(hr))
{
OutputDebugString(L"pGraphBuilder QueryInterface pMediaEvent Failed!\r\n");
return FALSE;
}

hr = pMediaEvent->SetNotifyWindow((OAHWND)g_hWnd,WM_GRAPHNOTIFY,0);//自定义消息WM_GRAPHNOTIFY,到第三步里Wndproc里得到该消息
hr = pVideoWindow->put_Owner(OAHWND(g_hWnd));
if(FAILED(hr))
{
OutputDebugString(L"pVideoWindow put_Owner Failed!\r\n");
return FALSE;
}

hr = pVideoWindow->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN);
if(FAILED(hr))
{
OutputDebugString(L"pVideoWindow put_WindowStyle Failed!\r\n");
return FALSE;
}

hr = pVideoWindow->put_Visible(OATRUE);
if(FAILED(hr))
{
OutputDebugString(L"pVideoWindow put_Visible Failed!\r\n");
return FALSE;
}

hr = pVideoWindow->SetWindowPosition(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
if(FAILED(hr))
{
OutputDebugString(L"pVideoWindow SetWindowPosition Failed!\r\n");
return FALSE;
}

hr = pVideoWindow->put_FullScreenMode(OATRUE);
hr = pMediaControl->Run();//开始视频捕捉
if(FAILED(hr))
{
OutputDebugString(L"pMediaControl Run Failed!\r\n");

return FALSE;
}
4.播放
case WM_GRAPHNOTIFY:
HandleGraphEvent();
HRESULT HandleGraphEvent(void)
{
LONG evCode, evParam1, evParam2;
HRESULT hr=S_OK;

// Make sure that we don't access the media event interface
// after it has already been released.
if (!pMediaEvent)
return S_OK;

// Process all queued events
while(SUCCEEDED(pMediaEvent->GetEvent(&evCode, (LONG_PTR *) &evParam1,
(LONG_PTR *) &evParam2, 0)))
{
// Free memory associated with callback, since we're not using it
hr = pMediaEvent->FreeEventParams(evCode, evParam1, evParam2);

// If this is the end of the clip, reset to beginning
if(EC_COMPLETE == evCode)
{
LONGLONG pos=0;

// Reset to first frame of movie
hr = pMediaSeeking->SetPositions(&pos, AM_SEEKING_AbsolutePositioning ,NULL, AM_SEEKING_NoPositioning);
if (FAILED(hr))
{
// Some custom filters (like the Windows CE MIDI filter)
// may not implement seeking interfaces (IMediaSeeking)
// to allow seeking to the start. In that case, just stop
// and restart for the same effect. This should not be
// necessary in most cases.
if (FAILED(hr = pMediaControl->Stop()))
{
//Msg(TEXT("Failed(0x%08lx) to stop media clip!\r\n"), hr);
break;
}

if (FAILED(hr = pMediaControl->Run()))
{
//Msg(TEXT("Failed(0x%08lx) to reset media clip!\r\n"), hr);
break;
}
}
}
}

return hr;
}


我现在在UT6410上,我不管如何把窗口调大,我抓到的图片,都 是320*240的,我把代码都看了,不知道如何调节,希望有人,能帮我下。谢谢。
...全文
189 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wz19761022 2010-05-22
  • 打赏
  • 举报
回复
你们公司也太那个。。。
如果你的摄像头支持你要的分辨率,而你们移植的DShow又支持IAMStreamConfig的话,我想是可以的。
papapa123123 2010-05-21
  • 打赏
  • 举报
回复
一般驱动支持的。 不过分辨率不是Dshow设置的。。 一般操作是通过注册表楼主 找找你注册表操作的地方就会有头绪。
wengshh 2010-05-21
  • 打赏
  • 举报
回复
不是你把窗口调大,图片分辨率率就会跟着变大,那样太恐怖了,随便一个Camera都有照出自己想要的分辨率了,首先是驱动支持,然后再程序设置。
cotulla 2010-03-27
  • 打赏
  • 举报
回复
还是自己秘密研究吧
LaiQingXiong 2010-03-27
  • 打赏
  • 举报
回复
这个是DirectShow吧。不错,呵呵。
勇敢爱 2010-03-27
  • 打赏
  • 举报
回复
我没有做过这方面的,第一个次接触,会的帮个忙吧,我只想把分辩率改到800*480就行了。
sunrain_hjb 2010-03-26
  • 打赏
  • 举报
回复
没用过6410,建议找开发板厂家的技术支持问问原因。

19,500

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧