Unable to display two cameras in DirectShow

走远了吗. 提交于 2019-12-12 10:11:50

问题


I'm using two DirectShow graphs, running on separate threads, to display streaming video (using VMR 9 on a seperate) and capture frames (using Sample Grabber) from two webcams. One of them is a built-in webcam (HP TrueVision HD) and the other is a Creative VF0520 connected to a USB port. None of the other USB ports are in use.

The problem is that the Creative camera turns on (LED lights up), but no stream comes through. The problem persists even if I disabled the built-in webcam. However, the Creative cam works if running on a desktop where the Creative cam is the only camera connected.

The program works when each camera is the only one connected (the Creative VF0520 works when it is the only camera connected to a desktop), but when two cameras are connected, video display and frame-grabbing only work for the built-in webcam.

I suspect the problem may arise from moniker-binding with capture filters. I am using modified code from MSDN. Is this the correct way to bind monikers to capture filters for multiple cameras?

ULONG VideoPlayer::GetMonikers(IEnumMoniker *pEnum, std::vector<IMoniker *> *pListMonikers)
{
ULONG numRetrieved =  0;
IMoniker* pMoniker = NULL;

while (pEnum->Next(1, &pMoniker, &numRetrieved) == S_OK)
{
// Bind to vector
pListMonikers->push_back(pMoniker);

    IPropertyBag *pPropBag;
    HRESULT hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
    if (FAILED(hr))
    {
        (*ppMoniker)->Release();
        continue;  
    }
    // Get information to display

    pPropBag->Release();
}

return numRetrieved;
}

The vector containing the monikers is then accessed to bind to the capture filter:

hr = listMonikers[CAMERA_ID]->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&pCap);

回答1:


Your first and best guess troubleshooting 2+ USB webcams is hitting USB bandwidth limit. With USB video you have so high chances to hit it, esp. with all the symptoms you mentioned. Make sure to read previous Qs on this:

  • Run multiple webcams at a time using DirectShow
  • 2 usb cameras not working with opencv
  • Implications of using many USB web cameras



回答2:


This is most likely related to USB hardware. download vlc and check if you can get video from both cameras on 2 different vlc instances.

vlc.exe -> media -> opencapturecapture

If you can't then start drilling into usb. It could be that your your 2nd usb cameras is being picked up by a usb 1.0 controller. I dont think it is directshow because I can get multiple cameras to work with directshow.

I had the same problem and it was related to usb bandwidth, and usb controller. Try plugging the cameras into different usb ports aswell.. that might work.



来源:https://stackoverflow.com/questions/15581396/unable-to-display-two-cameras-in-directshow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!