べるべる研究日誌

なんでもやる系エンジニアの日々

iPhone 4のLEDフラッシュの制御

とりあえず簡単にできそうだったのでやってみたら制御できた。

 captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
 captureDevice.torchMode = AVCaptureTorchModeOn;
 captureInput =[AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:nil];	
 AVCaptureVideoDataOutput *captureOutput = [[AVCaptureVideoDataOutput alloc] init];
 captureSession = [[AVCaptureSession alloc] init];	
 [captureSession addInput:captureInput];
 [captureSession addOutput:captureOutput];
 [captureSession startRunning];

iOS4のマルチタスクに落ちたり復活したときのAVCaptureSessionのあたりの挙動がよくわからんかったのでした。

無料でいろいろアプリが出てきたけど、綺麗なインターフェースとかストロボとかいろいろ考えるなぁと関心。