1 #import "VisageTrackerViewController.h" 2 #import "MobileCoreServices/UTCoreTypes.h" 3 #import "CustomGLView.h" 4 #import "TrackerWrapper.h" 8 @synthesize trackImage;
24 self.imgPicker = [[UIImagePickerController alloc] init];
25 self.imgPicker.delegate =
self;
26 self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
28 self.imgPicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
31 [
self.tracker initTracker:glView withInformer:self.createInformer];
34 -(IBAction)trackVideoAction:(
id)sender {
35 #if TARGET_IPHONE_SIMULATOR 36 [
self.tracker startTrackingFromVideo:nil];
38 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
39 self.popover = [[UIPopoverController alloc] initWithContentViewController:self.imgPicker];
40 [
self.popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 400.0, 400.0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
42 [
self presentViewController:self.imgPicker animated:YES completion:nil];
47 -(IBAction)trackImageAction:(
id)sender {
48 [
self.tracker startTrackingFromImage];
51 -(IBAction)trackStopAction:(
id)sender {
52 [
self.tracker stopTracker];
55 -(IBAction)trackCameraAction:(
id)sender {
56 [
self.tracker startTrackingFromCam];
59 -(IBAction)trackQuitAction:(
id)sender {
63 -(void) imagePickerController: (UIImagePickerController *) picker
64 didFinishPickingMediaWithInfo: (NSDictionary *) info
66 NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
68 NSString *moviePath = nil;
70 if (CFStringCompare ((__bridge CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo)
72 moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
75 NSString* tmpDir = NSTemporaryDirectory();
76 NSString* finalPath = [tmpDir stringByAppendingString:[moviePath lastPathComponent]];
79 if ([[NSFileManager defaultManager] isReadableFileAtPath:moviePath])
81 [[NSFileManager defaultManager] copyItemAtPath:moviePath toPath:finalPath error:&error];
85 NSLog(
@"ERROR. Failed to copy movie file to temporary directory.");
88 [
self dismissViewControllerAnimated:YES completion:nil];
90 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
91 [popover dismissPopoverAnimated:YES];
94 if ([[NSFileManager defaultManager] isReadableFileAtPath:finalPath])
97 [
self.tracker startTrackingFromVideo:finalPath];
101 NSLog(
@"ERROR. No file to open.");
105 - (void)didReceiveMemoryWarning {
107 [
super didReceiveMemoryWarning];
112 - (void)viewDidUnload {
113 [
super viewDidUnload];
120 [resultsDisplayTimer invalidate];
UIPopoverController * popover
Popover for video picker.
Implements default view controller and GUI actions.
IBOutlet UILabel * fpsLabel
Label for FPS display.
Informer * createInformer()
Method used for creating and initializing a new informer.
IBOutlet UILabel * statusLabel
Label for tracker status display.
Implements simple high-level Objective-C interface around VisageSDK::VisageTracker functionallity.
CustomGLView * glView
View for displaying tracking results frame and 3D face wireframe.
UIImagePickerController * imgPicker
Image picker for selectiong video file from album.
NSTimer * resultsDisplayTimer
Timer for periodically refreshing of the results display.
IBOutlet UILabel * infoLabel
Label for tracker information display.
TrackerWrapper * tracker
Wrapper class around C++ calls controlling the tracker.
IBOutlet UIToolbar * trackerToolbar
Toolbar for controlling the app.