|
@@ -39,16 +39,20 @@
|
|
|
|
|
|
for (AVCaptureDeviceFormat *format in supportedFormats) {
|
|
for (AVCaptureDeviceFormat *format in supportedFormats) {
|
|
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
|
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
|
- CMVideoDimensions bestVideoDimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[bestFormat formatDescription]);
|
|
|
|
-
|
|
|
|
- if (((CGFloat)dimensions.width/(CGFloat)dimensions.height) == radio && dimensions.height <= desiredHeight) {
|
|
|
|
-
|
|
|
|
- if(dimensions.width == 1080 && (model == SDK_CAPTURE_MODE_PANORAMA || model == SDK_CAPTURE_MODE_INTELLEGENCE_PANORAMA)) {
|
|
|
|
- aspect = (CGFloat)dimensions.width / dimensions.height;
|
|
|
|
- bestFormat = format;
|
|
|
|
- break;
|
|
|
|
- } else {
|
|
|
|
- aspect = (CGFloat)dimensions.width / dimensions.height;
|
|
|
|
|
|
+ if (((CGFloat)dimensions.width/(CGFloat)dimensions.height) == radio && dimensions.height == desiredHeight) {
|
|
|
|
+ bestFormat = format;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [device lockForConfiguration:nil];
|
|
|
|
+ if (!bestFormat) {
|
|
|
|
+ //未找到 匹配格式 查找固定匹配格式 (720 1080 2160)
|
|
|
|
+ for (AVCaptureDeviceFormat *format in supportedFormats) {
|
|
|
|
+ CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
|
|
|
+ CMVideoDimensions bestVideoDimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[bestFormat formatDescription]);
|
|
|
|
+ if (((CGFloat)dimensions.width/(CGFloat)dimensions.height) == radio &&
|
|
|
|
+ (dimensions.height == 720 || dimensions.height == 1080 || dimensions.height == 2160)) {
|
|
if (bestVideoDimensions.height <= dimensions.height) {
|
|
if (bestVideoDimensions.height <= dimensions.height) {
|
|
bestFormat = format;
|
|
bestFormat = format;
|
|
}
|
|
}
|
|
@@ -56,20 +60,20 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- [device lockForConfiguration:nil];
|
|
|
|
- if(bestFormat) {
|
|
|
|
- [device setActiveFormat:bestFormat];
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (!bestFormat) {
|
|
|
|
+ //未找到 固定格式 (720 1080 2160) 查找最佳格式(目标格式最近的分辨率)
|
|
for (AVCaptureDeviceFormat *format in supportedFormats) {
|
|
for (AVCaptureDeviceFormat *format in supportedFormats) {
|
|
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
|
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
|
CMVideoDimensions bestVideoDimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[bestFormat formatDescription]);
|
|
CMVideoDimensions bestVideoDimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[bestFormat formatDescription]);
|
|
- if (((CGFloat)dimensions.width/(CGFloat)dimensions.height) == radio) {
|
|
|
|
|
|
+ if (((CGFloat)dimensions.width/(CGFloat)dimensions.height) == radio && dimensions.height <= desiredHeight ) {
|
|
if (bestVideoDimensions.height <= dimensions.height) {
|
|
if (bestVideoDimensions.height <= dimensions.height) {
|
|
bestFormat = format;
|
|
bestFormat = format;
|
|
- break;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(bestFormat) {
|
|
[device setActiveFormat:bestFormat];
|
|
[device setActiveFormat:bestFormat];
|
|
}
|
|
}
|
|
|
|
|