iPhone 3.1 beta 3에서 camera 변경된 점

iPhone에도 3.1 부터 AR(증강현실)을 사용가능? 의 포스트에서 밝힌 바와 같이
슬슬 Camera와 관련한 사용자의 니즈를 반영하고 있는 것 같은데요.
09년 7월 27일 부로 베타 3가 나왔습니다.
cameraOverlayView와 관련해서는 아래의 문서를 참고바랍니다.
http://developer.apple.com/iphone/prere ··· rlayview
3.0 OS 까지 Camera Preview를 볼 수 있는 방법은 UIImagePickerController 이용하는 것이었습니다.
그러나 이 클래스의 역할은 modal 창으로 떠서 단 한장의 사진을 얻어서 사라지는 것이었습니다.
심지어 2.x 버전에서는 아래아 같이 시커먼 검은띠가 달린 거슬리는 화면 구성을 가지고 있었구요.

그러나 3.1 부터는
- (void)takePicture
라는 메소드를 추가하였습니다.
즉, 프리뷰를 보면서 사진을 여러장 찍을 수 있게 지원을 하고 있습니다.
그러나 현재 preview 프레임에 접근하는 것 까지는 공개하지 않았네요.
takePicture 함수를 호출하면 기존과 같이
UIImagePickerControllerDelegate 의
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
가 호출되는데 사실 1600*1200 해상도로 사진을 찍기 때문에 1초 정도가 걸립니다.- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
Computer Vision 기술을 사용하는 AR은 프레임을 얻어야 가능한데
1초가 걸리는 takePicture 함수로 하기는 아무래도 아직 무리가 있겠습니다.
단지, CoreLocation 정보를 이용해서 Compass값, 위도, 경도를 적절하게 Visual 하게 표현하여
AR 어플리케이션이 나올 가능성은 많습니다.
아래는 이번 추가된 API를 사용하여 카메라 프리뷰 줌을 만들어 봤습니다.
Custom Camera OverayView를 하나 만들고 Muti-touch가 가능하게 옵션을 주고
touch가 일어났을 때 아래와 같이 UIImagePickerController 의 cameraViewTransform 만 변경시킨 것입니다.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
if([touches count] == 2){
NSArray * twoTouches = [touches allObjects];
UITouch * first = [twoTouches objectAtIndex:0];
UITouch * second = [twoTouches objectAtIndex:1];
initialDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
if([touches count] == 2){
NSArray * twoTouches = [touches allObjects];
UITouch * first = [twoTouches objectAtIndex:0];
UITouch * second = [twoTouches objectAtIndex:1];
CGFloat currentDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);
if(initialDistance == 0)
initialDistance = currentDistance;
else {
CGFloat difference = currentDistance - initialDistance;
if(difference > 10){
scaleFactor+= 0.1;
initialDistance = currentDistance;
}
else if (difference < -10)
{
scaleFactor-= 0.1;
initialDistance = currentDistance;
}
if(scaleFactor > 3) scaleFactor = 3;
if(scaleFactor < 0.3) scaleFactor = 0.3;
scaleLabel.text = [NSString stringWithFormat:@"%.2f", scaleFactor];
picker.cameraViewTransform = CGAffineTransformMakeScale(scaleFactor, scaleFactor);
}
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
initialDistance = 0;
}
if([touches count] == 2){
NSArray * twoTouches = [touches allObjects];
UITouch * first = [twoTouches objectAtIndex:0];
UITouch * second = [twoTouches objectAtIndex:1];
initialDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
if([touches count] == 2){
NSArray * twoTouches = [touches allObjects];
UITouch * first = [twoTouches objectAtIndex:0];
UITouch * second = [twoTouches objectAtIndex:1];
CGFloat currentDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);
if(initialDistance == 0)
initialDistance = currentDistance;
else {
CGFloat difference = currentDistance - initialDistance;
if(difference > 10){
scaleFactor+= 0.1;
initialDistance = currentDistance;
}
else if (difference < -10)
{
scaleFactor-= 0.1;
initialDistance = currentDistance;
}
if(scaleFactor > 3) scaleFactor = 3;
if(scaleFactor < 0.3) scaleFactor = 0.3;
scaleLabel.text = [NSString stringWithFormat:@"%.2f", scaleFactor];
picker.cameraViewTransform = CGAffineTransformMakeScale(scaleFactor, scaleFactor);
}
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
initialDistance = 0;
}
"프로그래밍 / iPhone" 분류의 다른 글
| [iPhone 개발 Tip #4] 카메라 AF 상태 체크하기 (0) | 2010/06/07 |
| [iPhone 개발 Tip #3] 새로운 XCODE를 다운 받았을 경우 (4) | 2010/06/02 |
| [iPhone 개발 Tip #2] delegate 이렇게 쓰면 큰일난다! (0) | 2010/05/27 |
| Apple 개발자 등록 프로그램 종류와 가격 (0) | 2010/03/10 |
| iPhone 3GS vs Nexus One (0) | 2010/01/18 |
| iPhone 3GS 를 사용하다~ SKT 개통? (2) | 2009/08/11 |
| iPhone에서 ARToolkit 사용하기 (13) | 2009/08/03 |
| iPhone에도 3.1부터 AR(증강현실)을 사용가능? (2) | 2009/07/27 |
프로그래밍/iPhone
2009/07/29 15:03

댓글을 달아 주세요
안녕하세요.
한글로 쓴 아이폰 앱 개발 블로그는 처음 접하는데 내용도 상당히 좋은 것 같습니다. 앞으로도 좋은 글 많이 부탁합니다.
하하 감사합니다~
자주 찾아주세요~
저는 비디오 방면에는 익숙하지 않지만 preview frame을 가져오는 방법중 비디오 레코딩을 이용하는 방법은 어떨까요? 레코딩하는 속도는 30fps이니까 라이브로 비디오 내용을 억세스 할수 있다면 가장 빠른 방법 같습니다만 애플이 라이브 비디오 억세스를 못하게 해놓았겠죠?
takePicture란 메소드가 정확히 어떤일을 하는건가요?
프리뷰를 보면서 사진을 여러장 찍을수 있다라는 말이...이해가 잘 안가서요....
takePicture 함수는 카메라쪽 드라이버에게 사진을 찍으라고 신호를 주는 비동기 함수라고 생각하시면 되겠습니다.
보통 카메라들이 셔터를 누르고 실제 사진이 찍히는데 조금 딜레이가 있죠?
여기서 셔터를 누르는 역할을 하는 것이 takePicture 함수입니다. 앞서 말씀드린 듯이 비동기 함수이기에 프리뷰를 보면서도 사진 이미지가 delegate로 전달됩니다.
아 그렇군요... 친절한 답변 감사드립니다.
이제 시작해서 모르는게 너무 많은데..하나씩 하나씩 해 볼려고 합니다.
님의 블로그도 많은 도움을 받고 있습니다.
감사드립니다 ^^