我正在使用AVCaptureDevice的实例方法" isFlashModeSupported"如下:
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filtering_stream.hpp>
template <typename T>
void read_and_verify(std::string name, T& into) {
std::ifstream compressed("/tmp/so/computer_vision/openpose/train_data/" + name + ".bz2");
boost::iostreams::filtering_istream fs;
fs.push(boost::iostreams::bzip2_decompressor{});
fs.push(compressed);
boost::archive::text_iarchive ia(fs);
ia >> into;
debug_print(name, into);
}
但在iOS 10中,{@ 1}}和NSArray *captureDeviceType = @[AVCaptureDeviceTypeBuiltInWideAngleCamera,AVCaptureDeviceTypeBuiltInMicrophone];
AVCaptureDeviceDiscoverySession *captureDevice = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:captureDeviceType mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
NSArray *deviceList = [captureDevice devices];
AVCaptureDevice *selectedCamera = [deviceList objectAtIndex:(NSUInteger)currentCameraDeviceIndex];
if ( [selectedCamera isFlashModeSupported:AVCaptureFlashModeAuto] ){
[selectedCamera setFlashMode:AVCaptureFlashModeAuto]; // AVCaptureFlashModeAuto
}
方法已被弃用。
Xcode建议使用AVCapturePhotoOutput&#39; s -supportedFlashModes。
有任何想法如何使用上述方法吗?
提前致谢
答案 0 :(得分:1)
使用此代码。这非常有效。
AVCaptureSession *session = [[AVCaptureSession alloc] init];
[session setSessionPreset:AVCaptureSessionPresetPhoto];
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
if ([device hasFlash]) {
[device lockForConfiguration:nil];
device.flashMode = AVCaptureFlashModeAuto;
[device unlockForConfiguration];
}
答案 1 :(得分:0)
这是怎么回事?
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device hasFlash]) {
if ([self.stillImageOutput.supportedFlashModes containsObject:[NSNumber numberWithInt:AVCaptureFlashModeOn]]) {
}