Merge pull request #22946 from VadimLevin:dev/vlevin/avfoundation-stable-multicamera-index

fix: AVFoundation inconsistent camera indices
This commit is contained in:
Alexander Smorkalov 2022-12-13 10:34:42 +03:00 committed by GitHub
commit c2ecbc76ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 ) {