本文整理汇总了C++中DevicePtr::id方法的典型用法代码示例。如果您正苦于以下问题:C++ DevicePtr::id方法的具体用法?C++ DevicePtr::id怎么用?C++ DevicePtr::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DevicePtr
的用法示例。
在下文中一共展示了DevicePtr::id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
CSimpleOpt s(argc, argv, argumentSpecifications);
logger.setDefaultLogLevel(LOG_INFO);
uint16_t vid = 0;
Vector<uint16_t> pids;
String serialNumber;
String dumpFileName;
String type = "raw";
int32_t frameCount = 1;
char *endptr;
while (s.Next())
{
if (s.LastError() != SO_SUCCESS)
{
std::cout << s.GetLastErrorText(s.LastError()) << ": '" << s.OptionText() << "' (use -h to get command line help)" << std::endl;
help();
return -1;
}
//std::cout << s.OptionId() << ": " << s.OptionArg() << std::endl;
Vector<String> splits;
switch (s.OptionId())
{
case VENDOR_ID:
vid = (uint16_t)strtol(s.OptionArg(), &endptr, 16);
break;
case PRODUCT_ID:
split(s.OptionArg(), ',', splits);
for(auto &s1: splits)
pids.push_back((uint16_t)strtol(s1.c_str(), &endptr, 16));
break;
case SERIAL_NUMBER:
serialNumber = s.OptionArg();
break;
case DUMP_FILE:
dumpFileName = s.OptionArg();
break;
case NUM_OF_FRAMES:
frameCount = (int32_t)strtol(s.OptionArg(), &endptr, 10);
break;
case CAPTURE_TYPE:
type = s.OptionArg();
break;
default:
help();
break;
};
}
if(vid == 0 || pids.size() == 0 || pids[0] == 0 || dumpFileName.size() == 0)
{
std::cerr << "Required argument missing." << std::endl;
help();
return -1;
}
if (type != "raw" && type != "raw_processed" && type != "depth" && type != "pointcloud")
{
std::cerr << "Unknown type '" << type << "'" << std::endl;
help();
return -1;
}
std::ofstream f(dumpFileName, std::ios::binary | std::ios::out);
if(!f.good())
{
std::cerr << "Failed to open '" << dumpFileName << "'" << std::endl;
return -1;
}
CameraSystem sys;
// Get all valid detected devices
const Vector<DevicePtr> &devices = sys.scan();
DevicePtr toConnect;
std::cout << "Detected devices: " << std::endl;
for(auto &d: devices)
{
std::cout << d->id() << std::endl;
//.........这里部分代码省略.........
示例2: logger
UVCPrivate::UVCPrivate(DevicePtr usb)
{
if (usb->interfaceID() != Device::USB)
return;
USBSystem sys;
String devicePath = sys.getDeviceNode((USBDevice &)*usb);
if (!devicePath.size())
{
logger(LOG_ERROR) << "UVC: Could not get device path for device '" << usb->id() << "'" << std::endl;
return;
}
DWORD devInst;
if (!sys.getUSBSystemPrivate().getDevInst(devicePath, devInst))
{
logger(LOG_ERROR) << "UVC: Could not get devInst for device '" << usb->id() << "'" << std::endl;
return;
}
HRESULT hr = S_OK;
IMoniker *moniker;
Ptr<ICreateDevEnum> devEnum;
Ptr<IEnumMoniker> classEnum;
void *p;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
// Create the system device enumerator
if ((hr = (CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, IID_ICreateDevEnum, (void **)&p))) != S_OK)
{
logger(LOG_ERROR) << "UVC: Failed to get ICreateDevEnum enumerator" << std::endl;
return;
}
devEnum = Ptr<ICreateDevEnum>((ICreateDevEnum *)p, [](ICreateDevEnum *i) { i->Release(); });
// Create an enumerator for the video capture devices
if ((hr = devEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, (IEnumMoniker **)&p, 0)) != S_OK)
{
logger(LOG_ERROR) << "UVC: Failed to get VideoInputDeviceCategory class enumerator" << std::endl;
return;
}
// If there are no enumerators for the requested type, then
// CreateClassEnumerator will succeed, but pClassEnum will be NULL.
if (p == NULL)
{
logger(LOG_ERROR) << "UVC: Failed to get any video input devices in the enumerator" << std::endl;
return;
}
classEnum = Ptr<IEnumMoniker>((IEnumMoniker *)p, [](IEnumMoniker *i) { i->Release(); });
while ((hr = classEnum->Next(1, &moniker, NULL)) == S_OK)
{
IPropertyBag *propBag;
if ((hr = moniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&propBag)) != S_OK)
{
logger(LOG_WARNING) << "UVC: Could not get properties for current moniker" << std::endl;
continue;
}
VARIANT varName;
VariantInit(&varName);
if ((hr = propBag->Read(L"DevicePath", &varName, 0)) != S_OK)
{
logger(LOG_WARNING) << "UVC: Could not get DevicePath for current moniker" << std::endl;
continue;
}
_bstr_t b(varName.bstrVal);
String devPath = b;
VariantClear(&varName);
DWORD dInst;
DWORD parentDevInst;
if (!sys.getUSBSystemPrivate().getDevInst(devPath, dInst, (LPGUID)&AM_KSCATEGORY_CAPTURE)) //AM_KSCATEGORY_VIDEO
{
logger(LOG_WARNING) << "UVC: Could not get DevInst for DevicePath = " << devPath << std::endl;
continue;
}
if (CM_Get_Parent(&parentDevInst, dInst, 0) != CR_SUCCESS)
{
logger(LOG_WARNING) << "UVC: Could not get parent DevInst for DevicePath = " << devPath << std::endl;
continue;
}
if (parentDevInst == devInst) // Check whether our USBDevice's DevInst matches with IMoniker's parent's DevInst matches
{
if (usb->channelID() >= 0)
{
//.........这里部分代码省略.........