mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
fix: reduce redundant code by optimizing device name retrieval
This commit is contained in:
parent
78630ddc67
commit
61d719d2aa
@ -1382,14 +1382,11 @@ int videoInput::listDevices(bool silent){
|
|||||||
// Find the description or friendly name.
|
// Find the description or friendly name.
|
||||||
VARIANT varName;
|
VARIANT varName;
|
||||||
VariantInit(&varName);
|
VariantInit(&varName);
|
||||||
hr = pPropBag->Read(L"Description", &varName, 0);
|
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
|
||||||
|
|
||||||
if (FAILED(hr)) hr = pPropBag->Read(L"FriendlyName", &varName, 0);
|
if (FAILED(hr)) hr = pPropBag->Read(L"Description", &varName, 0);
|
||||||
|
|
||||||
if (SUCCEEDED(hr)){
|
if (SUCCEEDED(hr)){
|
||||||
|
|
||||||
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
|
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int maxLen = sizeof(deviceNames[0])/sizeof(deviceNames[0][0]) - 2;
|
int maxLen = sizeof(deviceNames[0])/sizeof(deviceNames[0][0]) - 2;
|
||||||
while( varName.bstrVal[count] != 0x00 && count < maxLen) {
|
while( varName.bstrVal[count] != 0x00 && count < maxLen) {
|
||||||
|
Loading…
Reference in New Issue
Block a user