#include #include #include #include #ifdef LINUX #include #endif #ifdef WITH_LIBDC_SUPPORT #include #endif #ifdef WITH_UNICAP_SUPPORT #include #endif namespace icl{ GenericGrabber::GenericGrabber(const std::string &desiredAPIOrder, const std::string ¶ms, bool notifyErrors){ m_poGrabber = 0; std::vector lP = tok(params,","); std::string pPWC,pDC,pUnicap,pFile; for(unsigned int i=0;i 4 && lP[i].substr(0,3) == "pwc"){ pPWC = lP[i].substr(4); }else if(lP[i].length() > 3 && lP[i].substr(0,2) == "dc"){ pDC = lP[i].substr(3); }else if(lP[i].length() > 7 && lP[i].substr(0,6) == "unicap"){ pUnicap = lP[i].substr(7); }else if(lP[i].length() > 5 && lP[i].substr(0,4) == "file"){ pFile = lP[i].substr(5); } } std::vector l = tok(desiredAPIOrder,","); for(unsigned int i=0;iinit(Size(640,480),24,to32s(pPWC))){ m_poGrabber = pwc; m_sType = "pwc"; break; }else{ delete pwc; continue; } } #endif #ifdef WITH_LIBDC_SUPPORT if(l[i] == "dc"){ std::vector devs = DCGrabber::getDeviceList(); int idx = to32s(pDC); printf("index is %d devs size is %d \n",idx,devs.size()); if(idx < 0) idx = 0; if(idx >= (int)devs.size()){ continue; }else{ m_poGrabber = new DCGrabber(devs[idx]); m_sType = "dc"; break; } } #endif #ifdef WITH_UNICAP_SUPPORT if(l[i] == "unicap"){ static std::vector devs = UnicapGrabber::getDeviceList(pUnicap); if(!devs.size()){ continue; }else{ m_poGrabber = new UnicapGrabber(devs[0]); m_sType = "unicap"; break; } } #endif if(l[i] == "file"){ if(FileList(pFile).size()){ m_poGrabber = new FileGrabber(pFile); ((FileGrabber*)m_poGrabber)->setIgnoreDesiredParams(false); m_sType = "file"; break; }else{ continue; } } } if(!m_poGrabber && notifyErrors){ ERROR_LOG("Generic Grabber was not able to find any suitable device!"); } } }