├── .DS_Store
├── README.md
├── openCViOSFaceTrackingTutorial.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── evangelosgeorgiou.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── evangelosgeorgiou.xcuserdatad
│ └── xcschemes
│ ├── openCViOSFaceTrackingTutorial.xcscheme
│ └── xcschememanagement.plist
├── openCViOSFaceTrackingTutorial
├── AppDelegate.h
├── AppDelegate.mm
├── Default-568h@2x.png
├── Default.png
├── Default@2x.png
├── ViewController.h
├── ViewController.mm
├── en.lproj
│ ├── InfoPlist.strings
│ └── ViewController.xib
├── haarcascade_frontalface_alt2.xml
├── main.mm
├── openCViOSFaceTrackingTutorial-Info.plist
└── openCViOSFaceTrackingTutorial-Prefix.pch
└── opencv2.framework
├── .DS_Store
├── Headers
├── Resources
├── Versions
├── .DS_Store
├── A
│ ├── .DS_Store
│ ├── Headers
│ │ ├── calib3d
│ │ │ └── calib3d.hpp
│ │ ├── contrib
│ │ │ ├── contrib.hpp
│ │ │ ├── detection_based_tracker.hpp
│ │ │ ├── hybridtracker.hpp
│ │ │ ├── openfabmap.hpp
│ │ │ └── retina.hpp
│ │ ├── core
│ │ │ ├── core.hpp
│ │ │ ├── core_c.h
│ │ │ ├── cuda_devptrs.hpp
│ │ │ ├── devmem2d.hpp
│ │ │ ├── eigen.hpp
│ │ │ ├── gpumat.hpp
│ │ │ ├── internal.hpp
│ │ │ ├── mat.hpp
│ │ │ ├── opengl_interop.hpp
│ │ │ ├── operations.hpp
│ │ │ ├── types_c.h
│ │ │ ├── version.hpp
│ │ │ └── wimage.hpp
│ │ ├── features2d
│ │ │ └── features2d.hpp
│ │ ├── flann
│ │ │ ├── all_indices.h
│ │ │ ├── allocator.h
│ │ │ ├── any.h
│ │ │ ├── autotuned_index.h
│ │ │ ├── composite_index.h
│ │ │ ├── config.h
│ │ │ ├── defines.h
│ │ │ ├── dist.h
│ │ │ ├── dummy.h
│ │ │ ├── dynamic_bitset.h
│ │ │ ├── flann.hpp
│ │ │ ├── flann_base.hpp
│ │ │ ├── general.h
│ │ │ ├── ground_truth.h
│ │ │ ├── hdf5.h
│ │ │ ├── heap.h
│ │ │ ├── hierarchical_clustering_index.h
│ │ │ ├── index_testing.h
│ │ │ ├── kdtree_index.h
│ │ │ ├── kdtree_single_index.h
│ │ │ ├── kmeans_index.h
│ │ │ ├── linear_index.h
│ │ │ ├── logger.h
│ │ │ ├── lsh_index.h
│ │ │ ├── lsh_table.h
│ │ │ ├── matrix.h
│ │ │ ├── miniflann.hpp
│ │ │ ├── nn_index.h
│ │ │ ├── object_factory.h
│ │ │ ├── params.h
│ │ │ ├── random.h
│ │ │ ├── result_set.h
│ │ │ ├── sampling.h
│ │ │ ├── saving.h
│ │ │ ├── simplex_downhill.h
│ │ │ └── timer.h
│ │ ├── highgui
│ │ │ ├── cap_ios.h
│ │ │ ├── highgui.hpp
│ │ │ └── highgui_c.h
│ │ ├── imgproc
│ │ │ ├── imgproc.hpp
│ │ │ ├── imgproc_c.h
│ │ │ └── types_c.h
│ │ ├── legacy
│ │ │ ├── blobtrack.hpp
│ │ │ ├── compat.hpp
│ │ │ ├── legacy.hpp
│ │ │ └── streams.hpp
│ │ ├── ml
│ │ │ └── ml.hpp
│ │ ├── nonfree
│ │ │ ├── features2d.hpp
│ │ │ └── nonfree.hpp
│ │ ├── objdetect
│ │ │ └── objdetect.hpp
│ │ ├── opencv.hpp
│ │ ├── opencv_modules.hpp
│ │ ├── photo
│ │ │ ├── photo.hpp
│ │ │ └── photo_c.h
│ │ ├── stitching
│ │ │ ├── detail
│ │ │ │ ├── autocalib.hpp
│ │ │ │ ├── blenders.hpp
│ │ │ │ ├── camera.hpp
│ │ │ │ ├── exposure_compensate.hpp
│ │ │ │ ├── matchers.hpp
│ │ │ │ ├── motion_estimators.hpp
│ │ │ │ ├── seam_finders.hpp
│ │ │ │ ├── util.hpp
│ │ │ │ ├── util_inl.hpp
│ │ │ │ ├── warpers.hpp
│ │ │ │ └── warpers_inl.hpp
│ │ │ ├── stitcher.hpp
│ │ │ └── warpers.hpp
│ │ ├── video
│ │ │ ├── background_segm.hpp
│ │ │ ├── tracking.hpp
│ │ │ └── video.hpp
│ │ ├── videostab
│ │ │ ├── deblurring.hpp
│ │ │ ├── fast_marching.hpp
│ │ │ ├── fast_marching_inl.hpp
│ │ │ ├── frame_source.hpp
│ │ │ ├── global_motion.hpp
│ │ │ ├── inpainting.hpp
│ │ │ ├── log.hpp
│ │ │ ├── motion_stabilizing.hpp
│ │ │ ├── optical_flow.hpp
│ │ │ ├── stabilizer.hpp
│ │ │ └── videostab.hpp
│ │ └── world
│ │ │ └── world.hpp
│ ├── Resources
│ │ ├── .DS_Store
│ │ └── Info.plist
│ └── opencv2
└── Current
└── opencv2
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/egeorgiou/openCViOSFaceTrackingTutorial/b58fc338e6eea977cf45362fed6880ef1a9d024d/.DS_Store
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | openCViOSFaceTrackingTutorial
2 | =============================
3 |
4 | Tutorial: openCV xCode iOS - Face Tracking with Video Capture
5 |
6 | This is a tutorial showing how openCV can be added to your iOS xCode project and how to capture a video stream from your camera onto a UIImageView and then tracking faces in each image frame.
7 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial.xcodeproj/project.xcworkspace/xcuserdata/evangelosgeorgiou.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/egeorgiou/openCViOSFaceTrackingTutorial/b58fc338e6eea977cf45362fed6880ef1a9d024d/openCViOSFaceTrackingTutorial.xcodeproj/project.xcworkspace/xcuserdata/evangelosgeorgiou.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial.xcodeproj/xcuserdata/evangelosgeorgiou.xcuserdatad/xcschemes/openCViOSFaceTrackingTutorial.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial.xcodeproj/xcuserdata/evangelosgeorgiou.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | openCViOSFaceTrackingTutorial.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 449A5FEB16F497F200249104
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // openCViOSFaceTrackingTutorial
4 | //
5 | // Created by Evangelos Georgiou on 16/03/2013.
6 | // Copyright (c) 2013 Evangelos Georgiou. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class ViewController;
12 |
13 | @interface AppDelegate : UIResponder
14 |
15 | @property (strong, nonatomic) UIWindow *window;
16 |
17 | @property (strong, nonatomic) ViewController *viewController;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/AppDelegate.mm:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // openCViOSFaceTrackingTutorial
4 | //
5 | // Created by Evangelos Georgiou on 16/03/2013.
6 | // Copyright (c) 2013 Evangelos Georgiou. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | #import "ViewController.h"
12 |
13 | @implementation AppDelegate
14 |
15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
16 | {
17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
18 | // Override point for customization after application launch.
19 | self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
20 | self.window.rootViewController = self.viewController;
21 | [self.window makeKeyAndVisible];
22 | return YES;
23 | }
24 |
25 | - (void)applicationWillResignActive:(UIApplication *)application
26 | {
27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
28 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
29 | }
30 |
31 | - (void)applicationDidEnterBackground:(UIApplication *)application
32 | {
33 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
35 | }
36 |
37 | - (void)applicationWillEnterForeground:(UIApplication *)application
38 | {
39 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
40 | }
41 |
42 | - (void)applicationDidBecomeActive:(UIApplication *)application
43 | {
44 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
45 | }
46 |
47 | - (void)applicationWillTerminate:(UIApplication *)application
48 | {
49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
50 | }
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/egeorgiou/openCViOSFaceTrackingTutorial/b58fc338e6eea977cf45362fed6880ef1a9d024d/openCViOSFaceTrackingTutorial/Default-568h@2x.png
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/egeorgiou/openCViOSFaceTrackingTutorial/b58fc338e6eea977cf45362fed6880ef1a9d024d/openCViOSFaceTrackingTutorial/Default.png
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/egeorgiou/openCViOSFaceTrackingTutorial/b58fc338e6eea977cf45362fed6880ef1a9d024d/openCViOSFaceTrackingTutorial/Default@2x.png
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // openCViOSFaceTrackingTutorial
4 | //
5 | // Created by Evangelos Georgiou on 16/03/2013.
6 | // Copyright (c) 2013 Evangelos Georgiou. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import
12 | #import
13 | #import
14 |
15 | using namespace cv;
16 |
17 | @interface ViewController : UIViewController
18 | {
19 | IBOutlet UIImageView* imageView;
20 |
21 | CvVideoCamera* videoCamera;
22 | CascadeClassifier faceCascade;
23 | }
24 |
25 | @property (nonatomic, retain) CvVideoCamera* videoCamera;
26 |
27 | - (IBAction)startCamera:(id)sender;
28 | - (IBAction)stopCamera:(id)sender;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/ViewController.mm:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // openCViOSFaceTrackingTutorial
4 | //
5 | // Created by Evangelos Georgiou on 16/03/2013.
6 | // Copyright (c) 2013 Evangelos Georgiou. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | NSString* const faceCascadeFilename = @"haarcascade_frontalface_alt2";
12 | const int HaarOptions = CV_HAAR_FIND_BIGGEST_OBJECT | CV_HAAR_DO_ROUGH_SEARCH;
13 |
14 | @interface ViewController ()
15 |
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | @synthesize videoCamera;
21 |
22 | - (void)viewDidLoad
23 | {
24 | [super viewDidLoad];
25 | // Do any additional setup after loading the view, typically from a nib.
26 |
27 | self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
28 | self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;
29 | self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
30 | self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
31 | self.videoCamera.defaultFPS = 30;
32 | self.videoCamera.grayscaleMode = NO;
33 | self.videoCamera.delegate = self;
34 |
35 | NSString* faceCascadePath = [[NSBundle mainBundle] pathForResource:faceCascadeFilename ofType:@"xml"];
36 | faceCascade.load([faceCascadePath UTF8String]);
37 | }
38 |
39 | - (void)didReceiveMemoryWarning
40 | {
41 | [super didReceiveMemoryWarning];
42 | // Dispose of any resources that can be recreated.
43 | }
44 |
45 | #pragma mark - Protocol CvVideoCameraDelegate
46 |
47 | #ifdef __cplusplus
48 | - (void)processImage:(Mat&)image;
49 | {
50 | Mat grayscaleFrame;
51 | cvtColor(image, grayscaleFrame, CV_BGR2GRAY);
52 | equalizeHist(grayscaleFrame, grayscaleFrame);
53 |
54 | std::vector faces;
55 | faceCascade.detectMultiScale(grayscaleFrame, faces, 1.1, 2, HaarOptions, cv::Size(60, 60));
56 |
57 | for (int i = 0; i < faces.size(); i++)
58 | {
59 | cv::Point pt1(faces[i].x + faces[i].width, faces[i].y + faces[i].height);
60 | cv::Point pt2(faces[i].x, faces[i].y);
61 |
62 | cv::rectangle(image, pt1, pt2, cvScalar(0, 255, 0, 0), 1, 8 ,0);
63 | }
64 | }
65 | #endif
66 |
67 | #pragma mark - UI Actions
68 |
69 | - (IBAction)startCamera:(id)sender
70 | {
71 | [self.videoCamera start];
72 | }
73 |
74 | - (IBAction)stopCamera:(id)sender
75 | {
76 | [self.videoCamera stop];
77 | }
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/main.mm:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // openCViOSFaceTrackingTutorial
4 | //
5 | // Created by Evangelos Georgiou on 16/03/2013.
6 | // Copyright (c) 2013 Evangelos Georgiou. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char *argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/openCViOSFaceTrackingTutorial-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | com.mymobilerobots.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/openCViOSFaceTrackingTutorial/openCViOSFaceTrackingTutorial-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'openCViOSFaceTrackingTutorial' target in the 'openCViOSFaceTrackingTutorial' project
3 | //
4 |
5 | #import
6 |
7 | #ifndef __IPHONE_4_0
8 | #warning "This project uses features only available in iOS SDK 4.0 and later."
9 | #endif
10 |
11 | #ifdef __cplusplus
12 | #import
13 | #endif
14 |
15 | #ifdef __OBJC__
16 | #import
17 | #import
18 | #endif
19 |
--------------------------------------------------------------------------------
/opencv2.framework/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/egeorgiou/openCViOSFaceTrackingTutorial/b58fc338e6eea977cf45362fed6880ef1a9d024d/opencv2.framework/.DS_Store
--------------------------------------------------------------------------------
/opencv2.framework/Headers:
--------------------------------------------------------------------------------
1 | Versions/A/Headers
--------------------------------------------------------------------------------
/opencv2.framework/Resources:
--------------------------------------------------------------------------------
1 | Versions/A/Resources
--------------------------------------------------------------------------------
/opencv2.framework/Versions/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/egeorgiou/openCViOSFaceTrackingTutorial/b58fc338e6eea977cf45362fed6880ef1a9d024d/opencv2.framework/Versions/.DS_Store
--------------------------------------------------------------------------------
/opencv2.framework/Versions/A/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/egeorgiou/openCViOSFaceTrackingTutorial/b58fc338e6eea977cf45362fed6880ef1a9d024d/opencv2.framework/Versions/A/.DS_Store
--------------------------------------------------------------------------------
/opencv2.framework/Versions/A/Headers/contrib/detection_based_tracker.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID)
4 |
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | class DetectionBasedTracker
11 | {
12 | public:
13 | struct Parameters
14 | {
15 | int minObjectSize;
16 | int maxObjectSize;
17 | double scaleFactor;
18 | int maxTrackLifetime;
19 | int minNeighbors;
20 | int minDetectionPeriod; //the minimal time between run of the big object detector (on the whole frame) in ms (1000 mean 1 sec), default=0
21 |
22 | Parameters();
23 | };
24 |
25 | DetectionBasedTracker(const std::string& cascadeFilename, const Parameters& params);
26 | virtual ~DetectionBasedTracker();
27 |
28 | virtual bool run();
29 | virtual void stop();
30 | virtual void resetTracking();
31 |
32 | virtual void process(const cv::Mat& imageGray);
33 |
34 | bool setParameters(const Parameters& params);
35 | const Parameters& getParameters();
36 |
37 |
38 | typedef std::pair Object;
39 | virtual void getObjects(std::vector& result) const;
40 | virtual void getObjects(std::vector