Submit Search
AVFoundationを使った無音カメラアプリの作り方
17 likes
22,060 views
Takashi Ohtsuka
AVFoundationを使った無音カメラアプリのチュートリアルとAVFoundationで簡単にカメラ撮影できるクラスライブラリの説明
Read more
1 of 32
1
2
Most read
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
More Related Content
PPT
Fundamentals of Financial Ratio Analysis
B.V. Raghavendra
PPTX
Property, Plant & Equipment IAS 16
Md. Moazzem Hossain
PPTX
Activity based costing
sachdevkkapil
PPT
Valuation
Anjana Vivek
PDF
Financal feasibility study
Mohamed Amin
PPTX
ACTIVITY BASED COSTING
AKSHIT JAIN
PPT
Financial Planning and Forecasting
Ankesh Gorkhali
DOC
Tcs synonyms and antonyms
Siva Chaitanya Kumar
Fundamentals of Financial Ratio Analysis
B.V. Raghavendra
Property, Plant & Equipment IAS 16
Md. Moazzem Hossain
Activity based costing
sachdevkkapil
Valuation
Anjana Vivek
Financal feasibility study
Mohamed Amin
ACTIVITY BASED COSTING
AKSHIT JAIN
Financial Planning and Forecasting
Ankesh Gorkhali
Tcs synonyms and antonyms
Siva Chaitanya Kumar
What's hot
(6)
PPT
Risk And Return
Al Razaq Muhammad
PPT
Target Costing.ppt
VibhavSrivastava15
PPT
Risk and Return: Portfolio Theory and Assets Pricing Models
PANKAJ PANDEY
PPSX
Ind AS 116 Leases
Paras Jain
PPTX
Ratio analysis
N A M COLLEGE KALLIKKANDY
PPT
Traditional & Abc
Dr. Rana Singh
Risk And Return
Al Razaq Muhammad
Target Costing.ppt
VibhavSrivastava15
Risk and Return: Portfolio Theory and Assets Pricing Models
PANKAJ PANDEY
Ind AS 116 Leases
Paras Jain
Ratio analysis
N A M COLLEGE KALLIKKANDY
Traditional & Abc
Dr. Rana Singh
Ad
AVFoundationを使った無音カメラアプリの作り方
1.
カメラアプリ開発入門 (第2回) AVFoundationを使った無音カメラアプリの作り方 2013/6/29 名古屋iPhone開発者勉強会 13年6月29日土曜日
2.
大塚 崇(おおつか たかし) DJ / フリーランスのエンジニア・プログラマ ハンドル名:
takatronix Facebook/Twitter/Skype/LINE/Weibo -> takatronix http://takatronix.com 趣味興味:旅行、語学、筋トレ、LEGO、FX、心理学、 脳科学、宇宙 自己紹介 13年6月29日土曜日
3.
リリースしたアプリ セクシーミラー、SEXY SCAN、 放射能汚染 地図、和牛スキャン
... (代表作) セクシーミラー-編集不要の神自撮りアプリ 13年6月29日土曜日
4.
http://sexymirror-app.com 2013/1リリース イギリスのiPhone総合で 10位に、現在42万ダウンロード セクシーミラー-編集不要の神自撮りアプリ 13年6月29日土曜日
5.
iOSカメラAPI UIImagePickerController AVFoundation.framework iOS4から、標準のカメラUIを使わない アプリが作れる よくあるカメラのUI 非常に簡単だが自由がない リアルタイムエフェクトはできない 実装は結構大変だがなんでもできる 13年6月29日土曜日
6.
AVFoundationを扱うのはけっこう大変 初期化だけでもかなりめんどくさい ので.... AVFoundationを超絶簡単に使 えるクラスをつくりました 13年6月29日土曜日
7.
サンプルのプロジェクトを用意しました。 http://takatronix.com/tutorial/20130629.zip 13年6月29日土曜日
8.
#import <UIKit/UIKit.h> #import "CameraManager.h" @interface
ViewController : UIViewController @property CameraManager* cameraManager; // カメラマネージャクラス @property IBOutlet UIImageView* previewView; // プレビューを配置するビュー @property IBOutlet UIImageView* captureview; // キャプチャ後のイメージ @end CameraManagerクラスの使い方 13年6月29日土曜日
9.
初期化 - (void)viewDidLoad { [super viewDidLoad]; //
カメラクラスを初期化 _cameraManager = CameraManager.new; // プレビューレイヤを設定 [_cameraManager setPreview:_previewView]; } 13年6月29日土曜日
10.
撮影 // 静止画撮影(シャッター音あり) -(IBAction)photo:(id)sender{ [_cameraManager takePhoto:^(UIImage
*image, NSError *error) { _captureview.image = image; }]; } // ビデオイメージ取得(シャッター音なし) -(IBAction)video:(id)sender{ _captureview.image = _cameraManager.rotatedVideoImage; } 13年6月29日土曜日
11.
カメラ制御 // バックカメラを使う -(IBAction)back:(id)sender{ [_cameraManager useFrontCamera:NO]; } //
フロントカメラを使う -(IBAction)front:(id)sender{ [_cameraManager useFrontCamera:YES]; } // カメラ切り替え -(IBAction)flip:(id)sender{ [_cameraManager flipCamera]; } 13年6月29日土曜日
12.
ライト制御 // ライト切り替え -(IBAction)light:(id)sender{ [_cameraManager lightToggle]; } //
ライトON -(IBAction)lightOn:(id)sender{ [_cameraManager light:YES]; } // ライトOFF -(IBAction)lightOff:(id)sender{ [_cameraManager light:NO]; } 13年6月29日土曜日
13.
こんな感じに簡単につかえます。 詳しい使い方はCameraManager.hを読んで ください 13年6月29日土曜日
14.
さっそく コードを読みながら 理解しよう 13年6月29日土曜日
15.
基本的なクラスを ざっと解説 13年6月29日土曜日
16.
AVCaptureSession セッション管理をするクラス 入力と出力をつなぎ映像や音声の流 れを定義し、実行する 13年6月29日土曜日
17.
AVCaptureInput カメラ、マイクなどの入力デバイスの データを受け取る AVCaptureSessionにつなぐ 13年6月29日土曜日
18.
AVCaptureDevice カメラやマイクなどのデバイス ライトをつけたり、フォーカスの制 御したりするときに使う AVCaptureInputを作成するときに使う 13年6月29日土曜日
19.
AVCaptureOutput ファイルやバッファなどの出力 AVCaptureSessionにつなぐ AVCaptureStillImageOutput 静止画 AVCaptureAudioDataOutput AVCaptureVideoDataOutput オーディオ ビデオ いろんなのありますw 13年6月29日土曜日
20.
AVCaptureVideoPreviewLayer プレビューを表示するCALayer カメラの生のデータを表示できる リアルタイムエフェクトしたい場合には 使えないが、表示は速い。 AVCaptureSessionにつなぐ 13年6月29日土曜日
21.
AVCaptureConnection 入力と出力の接続状態の設定とか も、もうやめて・・・ って感じですよねw 13年6月29日土曜日
22.
AVCaptureSession AVCaptureOutput AVCaptureInput AVCaptureInput AVCaptureOutput startRunningで開始 カメラの入力 画像化 13年6月29日土曜日
23.
// デフォルトはバックカメラ videoInput =
[AVCaptureDeviceInput deviceInputWithDevice:self.backCameraDevice error:nil]; ///////////////////////////////////////////////// // キャプチャセッションの作成 ///////////////////////////////////////////////// ! captureSession = AVCaptureSession.new; [captureSession setSessionPreset:preset]; [captureSession addInput:videoInput]; !self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:captureSession]; ! [self.previewLayer setBackgroundColor:[[UIColor blackColor] CGColor]]; [self.previewLayer setVideoGravity:AVLayerVideoGravityResizeAspect]; [self setupImageCapture]; [self setupVideoCapture]; [captureSession startRunning]; セッションの作成、初期化 13年6月29日土曜日
24.
カメラを変更するときなど接続を組み直すとき CaptureSessionの変更 // カメラを有効化する -(void)enableCamera:(AVCaptureDevicePosition)desiredPosition{ [captureSession stopRunning]; for
(AVCaptureDevice *d in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) { if ([d position] == desiredPosition) { [captureSession beginConfiguration]; videoInput= [AVCaptureDeviceInput deviceInputWithDevice:d error:nil]; for (AVCaptureInput *oldInput in [[_previewLayer session] inputs]) { [captureSession removeInput:oldInput]; } [captureSession addInput:videoInput]; [captureSession commitConfiguration]; break; } } [captureSession startRunning]; } [captureSession beginConfigration] [captureSession commitConfiration] 入出力の切り替え 反映 13年6月29日土曜日
25.
静止画の取得 AVCaptureStillImageOutput CaptureSessionに接続した AVCaptureStillImageOutputから CMSampleBufferを取得 デバイスの向きに合わせたUImageに変換 -(void)takePhoto:(takePhotoBlock) block 表示 13年6月29日土曜日
26.
動画の取得 AVCaptureVideoDataOutput CaptureSessionに AVCaptureVideoDataOutputを接続 CaptureSettion startRunning後 - (void)captureOutput:(AVCaptureOutput
*)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection が、ビデオのフレームの更新毎に呼ばれる 13年6月29日土曜日
27.
画像データの表示までの流れ CMSampleBuffer CVImageBuffer CGImage UIImage Core Media CoreVideo Core Graphics UIKit 13年6月29日土曜日
28.
取得画像の向き デバイスの向きが縦でも横でも取得す るビデオイメージは横向き固定 撮影時のデバイスの向きを記録し、画 像化するときに回転させること CameraManager rotatedVideoImageを参照 13年6月29日土曜日
29.
例題 プレビューレイヤを使わずに取得し た画像をリアルタイムでモノクロ化 してみよう *モノクロ化のコードは前回のチュートリアル を参考に http://takatronix.com/tutorial/20130525.zip 13年6月29日土曜日
30.
プロジェクトとこのスライドはここから 落とせますよ。 http://takatronix.com/tutorial/20130629.zip 13年6月29日土曜日
31.
takatronix検索 http://takatronix.com 13年6月29日土曜日
32.
ありがとうございました takatronix検索 http://takatronix.com 13年6月29日土曜日