Varvrar / ios_logger

Application for camera and sensor data logging (iOS)
150 stars 28 forks source link

Switch camera #2

Open yaqding opened 4 years ago

yaqding commented 4 years ago

Hello Varvrar!

Thanks for you great work! I have used this nice app to recorder data for pose estimation. I was wondering how I could choose different back cameras since there are multiple back cameras from iphone 7. For example, I was trying to use the TelephotoCamera or UltraWideCamera, and based on the apple documentation I need to use AVCaptureDeviceDiscoverySession:

AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:AVCaptureDeviceTypeBuiltInUltraWideCamera mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];

However, it doesn't work. Could you please give some suggestions?

Thanks!

Varvrar commented 4 years ago

Hello yaqding!

I can't try to use second back camera now. But I think you should change AVCaptureDevice instead of using AVCaptureDeviceDiscoverySession. https://github.com/Varvrar/ios_logger/blob/a42f5331b977e73a747a102ad84b2cbfd13994f6/ios_logger/ViewController.mm#L93

Check apple documentation: https://developer.apple.com/documentation/avfoundation/avcapturedevice?language=objc

You can try to use different defaultDeviceWithDeviceType. Like AVCaptureDeviceTypeBuiltInTelephotoCamera or AVCaptureDeviceTypeBuiltInWideAngleCamera. Or try to get device types in advance using devicesWithMediaType.