Skip to content

Commit

Permalink
Updated Code to detect if the device supports AVCaptureDevice devices…
Browse files Browse the repository at this point in the history
… for Video.

Since we are now using AVCaptureDevice instead of the CameraImagePicker
to do AR we need to make sure it supports Video Capture instead.
  • Loading branch information
nielswh committed Nov 20, 2011
1 parent 663ea8a commit 5de0c88
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -50,3 +50,7 @@ ARKitDemo/ARKitDemo.xcodeproj/project.xcworkspace/xcuserdata/nielswhansen.xcuser
ARKitDemo/ARKitDemo.xcodeproj/xcuserdata/nielswhansen.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist

ARKitDemo/ARKitDemo.xcodeproj/xcuserdata/nielswhansen.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist

ARKitDemo/ARKitDemo.xcodeproj/project.xcworkspace/xcuserdata/nielswhansen.xcuserdatad/UserInterfaceState.xcuserstate

ARKitDemo/ARKitDemo.xcodeproj/project.xcworkspace/xcuserdata/nielswhansen.xcuserdatad/UserInterfaceState.xcuserstate
3 changes: 2 additions & 1 deletion ARKit/ARKit.h
Expand Up @@ -2,11 +2,12 @@
// ARKit.h
// ARKitDemo
//
// Created by Jared Crawford on 2/13/10.
// Modified by Niels Hansen on 11/20/11.
// Copyright 2011 Agilite Software. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>

#import "ARViewController.h"
#import "ARLocationDelegate.h"
Expand Down
35 changes: 23 additions & 12 deletions ARKit/ARKit.m
Expand Up @@ -2,7 +2,7 @@
// ARKit.m
// ARKitDemo
//
// Created by Jared Crawford on 2/13/10.
// Modifed by Niels Hansen 11/20/11.
// Copyright 2011 Agilite Software. All rights reserved.
//

Expand All @@ -12,20 +12,31 @@
@implementation ARKit

+(BOOL)deviceSupportsAR{

//Detect camera, if not there, return NO
if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
return NO;
}



// Go thru and see if the device supports Video Capture.
NSArray *devices = [AVCaptureDevice devices];

BOOL suportsVideo = NO;

if (devices != nil && [devices count] > 0) {
for (AVCaptureDevice *device in devices) {
if ([device hasMediaType:AVMediaTypeVideo]) {
suportsVideo = YES;
break;
}
}
}

if (!suportsVideo)
return NO;

//TODO: Check to see if Device supports the Gyroscope (iPhone4 and higher)


if(![CLLocationManager headingAvailable]){
return NO;
}

//cannot detect presence of GPS
//I could look at location accuracy, but the GPS takes too long to
//initialize to be effective for a quick check
//I'll assume if you made it this far, it's there

return YES;
}
Expand Down
4 changes: 0 additions & 4 deletions ARKit/ARViewController.m
Expand Up @@ -51,12 +51,8 @@ - (void)loadView {
[self setAgController:arc];
[arc release];
[locations release];


}



- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
Expand Down
1 change: 1 addition & 0 deletions ARKit/AugmentedRealityController.m
Expand Up @@ -71,6 +71,7 @@ - (id)initWithViewController:(ARViewController *)vc {
[self setRootViewController: vc];
[self setMaximumScaleDistance: 0.0];
[self setMinimumScaleFactor: 1.0];

[self setScaleViewsBasedOnDistance: NO];
[self setRotateViewsBasedOnPerspective: NO];
[self setMaximumRotationAngle: M_PI / 6.0];
Expand Down
8 changes: 4 additions & 4 deletions ARKitDemo/ARKitDemo.xcodeproj/project.pbxproj
Expand Up @@ -59,8 +59,8 @@
69E66635111BAF3500BD3E6D /* GEOLocations.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GEOLocations.m; sourceTree = "<group>"; };
7F4C199F112674030093704B /* ARLocationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARLocationDelegate.h; sourceTree = "<group>"; };
7F4C19A0112674030093704B /* ARLocationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARLocationDelegate.m; sourceTree = "<group>"; };
7F4C19F4112677260093704B /* ARViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARViewController.h; sourceTree = "<group>"; };
7F4C19F5112677260093704B /* ARViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARViewController.m; sourceTree = "<group>"; };
7F4C19F4112677260093704B /* ARViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARViewController.h; path = ../../ARKit/ARViewController.h; sourceTree = "<group>"; };
7F4C19F5112677260093704B /* ARViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ARViewController.m; path = ../../ARKit/ARViewController.m; sourceTree = "<group>"; };
7F4C19F8112678E50093704B /* ARKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARKit.h; sourceTree = "<group>"; };
7F4C19F9112678E50093704B /* ARKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARKit.m; sourceTree = "<group>"; };
8C0F54F0141E66E5009D0D64 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -96,6 +96,8 @@
080E96DDFE201D6D7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
7F4C19F4112677260093704B /* ARViewController.h */,
7F4C19F5112677260093704B /* ARViewController.m */,
1D3623240D0F684500981E51 /* ARKitDemoAppDelegate.h */,
1D3623250D0F684500981E51 /* ARKitDemoAppDelegate.m */,
8C0F54F0141E66E5009D0D64 /* MainViewController.h */,
Expand Down Expand Up @@ -165,8 +167,6 @@
69E6662B111BAF3500BD3E6D /* ARKit */ = {
isa = PBXGroup;
children = (
7F4C19F4112677260093704B /* ARViewController.h */,
7F4C19F5112677260093704B /* ARViewController.m */,
69E6662C111BAF3500BD3E6D /* ARCoordinate.h */,
69E6662D111BAF3500BD3E6D /* ARCoordinate.m */,
69E6662E111BAF3500BD3E6D /* ARGeoCoordinate.h */,
Expand Down
Binary file not shown.
Expand Up @@ -2,4 +2,34 @@
<Bucket
type = "1"
version = "1.0">
<FileBreakpoints>
<FileBreakpoint
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
isPathRelative = "0"
filePath = "/Users/nielswhansen/Documents/iPhone-AR-Toolkit/ARKit/ARViewController.m"
timestampString = "343513671.38727"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "69"
endingLineNumber = "69"
landmarkName = "-locationClicked:"
landmarkType = "5">
</FileBreakpoint>
<FileBreakpoint
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
isPathRelative = "0"
filePath = "/Users/nielswhansen/Documents/iPhone-AR-Toolkit/ARKit/ARKit.m"
timestampString = "343515311.809868"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "18"
endingLineNumber = "18"
landmarkName = "+deviceSupportsAR"
landmarkType = "5">
</FileBreakpoint>
</FileBreakpoints>
</Bucket>
12 changes: 6 additions & 6 deletions ARKitDemo/Classes/MainViewController.m
Expand Up @@ -41,17 +41,17 @@ - (void)didReceiveMemoryWarning

-(IBAction) displayAR:(id)sender {

ARKitDemoAppDelegate *appDelegate = (ARKitDemoAppDelegate*)[[UIApplication sharedApplication] delegate];

if([ARKit deviceSupportsAR]){
ARViewController *newCameraViewController = [[ARViewController alloc] initWithDelegate:self];
[self setCameraViewController:newCameraViewController];
[newCameraViewController release];
ARViewController *arvc = [[ARViewController alloc] initWithDelegate:self];
[self setCameraViewController:arvc];
[arvc release];
[cameraViewController setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:cameraViewController animated:YES];
newCameraViewController = nil;
arvc = nil;
}
else {
ARKitDemoAppDelegate *appDelegate = (ARKitDemoAppDelegate*)[[UIApplication sharedApplication] delegate];

UIViewController *newInfoViewController = [[UIViewController alloc] init];
[self setInfoViewController:newInfoViewController];
[newInfoViewController release];
Expand Down

0 comments on commit 5de0c88

Please sign in to comment.