mirror of
https://github.com/opencv/opencv.git
synced 2024-12-12 07:09:12 +08:00
fix: AVFoundation inconsistent camera indices
This commit is contained in:
parent
ebaee3ea21
commit
727feda935
@ -376,6 +376,15 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Preserve devices ordering on the system
|
||||||
|
// see AVCaptureDevice::uniqueID property documentation for more info
|
||||||
|
devices = [devices
|
||||||
|
sortedArrayUsingComparator:^NSComparisonResult(AVCaptureDevice *d1,
|
||||||
|
AVCaptureDevice *d2) {
|
||||||
|
return [d1.uniqueID compare:d2.uniqueID];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
mCaptureDevice = devices[cameraNum];
|
mCaptureDevice = devices[cameraNum];
|
||||||
|
|
||||||
if ( ! mCaptureDevice ) {
|
if ( ! mCaptureDevice ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user