├── .gitattributes ├── .gitignore ├── Chapter 1 ├── CoolPig.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── Joe.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── Joe.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── CoolPig.xcscheme │ │ └── xcschememanagement.plist └── CoolPig │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── AppIcon_120-1.png │ │ ├── AppIcon_120.png │ │ ├── AppIcon_152.png │ │ ├── AppIcon_167.png │ │ ├── AppIcon_180.png │ │ ├── AppIcon_29.png │ │ ├── AppIcon_40.png │ │ ├── AppIcon_58-1.png │ │ ├── AppIcon_58.png │ │ ├── AppIcon_76.png │ │ ├── AppIcon_80-1.png │ │ ├── AppIcon_80.png │ │ ├── AppIcon_87.png │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── Piggy.png │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── Chapter 2 └── 9491OS_02_code │ ├── LightWork.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── Joe.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── Joe.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── LightWork.xcscheme │ │ └── xcschememanagement.plist │ └── LightWork │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── AppIcon_120-1.png │ │ ├── AppIcon_120.png │ │ ├── AppIcon_152.png │ │ ├── AppIcon_167.png │ │ ├── AppIcon_180.png │ │ ├── AppIcon_29.png │ │ ├── AppIcon_40.png │ │ ├── AppIcon_58-1.png │ │ ├── AppIcon_58.png │ │ ├── AppIcon_76.png │ │ ├── AppIcon_80-1.png │ │ ├── AppIcon_80.png │ │ ├── AppIcon_87.png │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Fleur.jpg │ ├── Info.plist │ ├── SwitchCamera.png │ ├── SwitchCamera@2x.png │ ├── SwitchCamera@3x.png │ ├── VideoCamera.h │ ├── VideoCamera.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── Chapter 3 ├── LightWork.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── Joe.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── Joe.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── LightWork.xcscheme │ │ └── xcschememanagement.plist └── LightWork │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── AppIcon_120-1.png │ │ ├── AppIcon_120.png │ │ ├── AppIcon_152.png │ │ ├── AppIcon_167.png │ │ ├── AppIcon_180.png │ │ ├── AppIcon_29.png │ │ ├── AppIcon_40.png │ │ ├── AppIcon_58-1.png │ │ ├── AppIcon_58.png │ │ ├── AppIcon_76.png │ │ ├── AppIcon_80-1.png │ │ ├── AppIcon_80.png │ │ ├── AppIcon_87.png │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Fleur.jpg │ ├── Info.plist │ ├── SwitchCamera.png │ ├── SwitchCamera@2x.png │ ├── SwitchCamera@3x.png │ ├── VideoCamera.h │ ├── VideoCamera.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── Chapter 4 ├── ManyMasks.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── Joe.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── Joe.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── ManyMasks.xcscheme │ │ └── xcschememanagement.plist └── ManyMasks │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── AppIcon_120-1.png │ │ ├── AppIcon_120.png │ │ ├── AppIcon_152.png │ │ ├── AppIcon_167.png │ │ ├── AppIcon_180.png │ │ ├── AppIcon_29.png │ │ ├── AppIcon_40.png │ │ ├── AppIcon_58-1.png │ │ ├── AppIcon_58.png │ │ ├── AppIcon_76.png │ │ ├── AppIcon_80-1.png │ │ ├── AppIcon_80.png │ │ ├── AppIcon_87.png │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── CaptureViewController.h │ ├── CaptureViewController.m │ ├── Face.cpp │ ├── Face.h │ ├── FaceDetector.cpp │ ├── FaceDetector.h │ ├── GeomUtils.cpp │ ├── GeomUtils.h │ ├── Info.plist │ ├── Mask.png │ ├── ReviewViewController.h │ ├── ReviewViewController.m │ ├── Species.h │ ├── SwitchCamera.png │ ├── SwitchCamera@2x.png │ ├── SwitchCamera@3x.png │ ├── VideoCamera.h │ ├── VideoCamera.m │ ├── haarcascade_frontalcatface_extended.xml │ ├── haarcascade_frontalface_alt.xml │ ├── haarcascade_lefteye_2splits.xml │ ├── haarcascade_righteye_2splits.xml │ └── main.m ├── Chapter 5 ├── BeanCounter.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── Joe.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── Joe.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── BeanCounter.xcscheme │ │ └── xcschememanagement.plist └── BeanCounter │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── AppIcon_120-1.png │ │ ├── AppIcon_120.png │ │ ├── AppIcon_152.png │ │ ├── AppIcon_167.png │ │ ├── AppIcon_180.png │ │ ├── AppIcon_29.png │ │ ├── AppIcon_40.png │ │ ├── AppIcon_58-1.png │ │ ├── AppIcon_58.png │ │ ├── AppIcon_76.png │ │ ├── AppIcon_80-1.png │ │ ├── AppIcon_80.png │ │ ├── AppIcon_87.png │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Blob.cpp │ ├── Blob.h │ ├── BlobClassifier.cpp │ ├── BlobClassifier.h │ ├── BlobClassifierTraining.plist │ ├── BlobDescriptor.cpp │ ├── BlobDescriptor.h │ ├── BlobDetector.cpp │ ├── BlobDetector.h │ ├── CanadianDime_Heads_000.png │ ├── CanadianDime_Tails_000.png │ ├── CanadianNickel_Heads_000.png │ ├── CanadianNickel_Tails_000.png │ ├── CanadianQuarter_Heads_000.png │ ├── CanadianQuarter_Tails_000.png │ ├── CaptureViewController.h │ ├── CaptureViewController.m │ ├── Info.plist │ ├── Loonie_Heads_000.png │ ├── Loonie_Tails_000.png │ ├── PintoBean_000.png │ ├── ReviewViewController.h │ ├── ReviewViewController.m │ ├── RomanoBean_000.png │ ├── SwitchCamera.png │ ├── SwitchCamera@2x.png │ ├── SwitchCamera@3x.png │ ├── TheQueen'sBeans.jpg │ ├── Toonie_Heads_000.png │ ├── Toonie_Tails_000.png │ ├── VideoCamera.h │ ├── VideoCamera.m │ └── main.m ├── LICENSE ├── README.md └── Software and hardware list.pdf /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig.xcodeproj/project.xcworkspace/xcuserdata/Joe.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig.xcodeproj/project.xcworkspace/xcuserdata/Joe.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Chapter 1/CoolPig.xcodeproj/xcuserdata/Joe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig.xcodeproj/xcuserdata/Joe.xcuserdatad/xcschemes/CoolPig.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig.xcodeproj/xcuserdata/Joe.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CoolPig.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D8F25D451BE986C2008667B9 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CoolPig 4 | // 5 | // Created by Joseph Howse on 2015-11-03. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface AppDelegate : UIResponder 37 | 38 | @property (strong, nonatomic) UIWindow *window; 39 | 40 | 41 | @end 42 | 43 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CoolPig 4 | // 5 | // Created by Joseph Howse on 2015-11-03. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import "AppDelegate.h" 35 | 36 | @interface AppDelegate () 37 | 38 | @end 39 | 40 | @implementation AppDelegate 41 | 42 | 43 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 44 | // Override point for customization after application launch. 45 | return YES; 46 | } 47 | 48 | - (void)applicationWillResignActive:(UIApplication *)application { 49 | // 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. 50 | // 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. 51 | } 52 | 53 | - (void)applicationDidEnterBackground:(UIApplication *)application { 54 | // 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. 55 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 56 | } 57 | 58 | - (void)applicationWillEnterForeground:(UIApplication *)application { 59 | // 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. 60 | } 61 | 62 | - (void)applicationDidBecomeActive:(UIApplication *)application { 63 | // 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. 64 | } 65 | 66 | - (void)applicationWillTerminate:(UIApplication *)application { 67 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_120-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_120-1.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_120.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_152.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_167.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_180.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_29.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_40.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_58-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_58-1.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_58.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_76.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_80-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_80-1.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_80.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/AppIcon_87.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "AppIcon_58.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "AppIcon_87.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "AppIcon_80.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "AppIcon_120.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "AppIcon_120-1.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "AppIcon_180.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "29x29", 41 | "idiom" : "ipad", 42 | "filename" : "AppIcon_29.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "29x29", 47 | "idiom" : "ipad", 48 | "filename" : "AppIcon_58-1.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "40x40", 53 | "idiom" : "ipad", 54 | "filename" : "AppIcon_40.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "40x40", 59 | "idiom" : "ipad", 60 | "filename" : "AppIcon_80-1.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "76x76", 65 | "idiom" : "ipad", 66 | "filename" : "AppIcon_76.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "76x76", 71 | "idiom" : "ipad", 72 | "filename" : "AppIcon_152.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "83.5x83.5", 77 | "idiom" : "ipad", 78 | "filename" : "AppIcon_167.png", 79 | "scale" : "2x" 80 | } 81 | ], 82 | "info" : { 83 | "version" : 1, 84 | "author" : "xcode" 85 | } 86 | } -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIRequiresFullScreen 34 | 35 | UIStatusBarHidden 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UIViewControllerBasedStatusBarAppearance 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig/Piggy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 1/CoolPig/Piggy.png -------------------------------------------------------------------------------- /Chapter 1/CoolPig/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CoolPig 4 | // 5 | // Created by Joseph Howse on 2015-11-03. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface ViewController : UIViewController 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CoolPig 4 | // 5 | // Created by Joseph Howse on 2015-11-03. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | #import 36 | #import 37 | 38 | #ifdef WITH_OPENCV_CONTRIB 39 | #import 40 | #endif 41 | 42 | #import "ViewController.h" 43 | 44 | 45 | #define RAND_0_1() ((double)arc4random() / 0x100000000) 46 | 47 | 48 | @interface ViewController () { 49 | cv::Mat originalMat; 50 | cv::Mat updatedMat; 51 | } 52 | 53 | @property IBOutlet UIImageView *imageView; 54 | @property NSTimer *timer; 55 | 56 | - (void)updateImage; 57 | 58 | @end 59 | 60 | 61 | @implementation ViewController 62 | 63 | - (void)viewDidLoad { 64 | [super viewDidLoad]; 65 | 66 | // Load a UIImage from a resource file. 67 | UIImage *originalImage = [UIImage imageNamed:@"Piggy.png"]; 68 | 69 | // Convert the UIImage to a cv::Mat. 70 | UIImageToMat(originalImage, originalMat); 71 | 72 | switch (originalMat.type()) { 73 | case CV_8UC1: 74 | // The cv::Mat is in grayscale format. 75 | // Convert it to RGB format. 76 | cv::cvtColor(originalMat, originalMat, cv::COLOR_GRAY2RGB); 77 | break; 78 | case CV_8UC4: 79 | // The cv::Mat is in RGBA format. 80 | // Convert it to RGB format. 81 | cv::cvtColor(originalMat, originalMat, cv::COLOR_RGBA2RGB); 82 | #ifdef WITH_OPENCV_CONTRIB 83 | // Adjust the white balance. 84 | cv::xphoto::autowbGrayworld(originalMat, originalMat); 85 | #endif 86 | break; 87 | case CV_8UC3: 88 | // The cv::Mat is in RGB format. 89 | #ifdef WITH_OPENCV_CONTRIB 90 | // Adjust the white balance. 91 | cv::xphoto::autowbGrayworld(originalMat, originalMat); 92 | #endif 93 | break; 94 | default: 95 | break; 96 | } 97 | 98 | // Call an update method every 2 seconds. 99 | self.timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(updateImage) userInfo:nil repeats:YES]; 100 | } 101 | 102 | - (void)updateImage { 103 | // Generate a random color. 104 | double r = 0.5 + RAND_0_1() * 1.0; 105 | double g = 0.6 + RAND_0_1() * 0.8; 106 | double b = 0.4 + RAND_0_1() * 1.2; 107 | cv::Scalar randomColor(r, g, b); 108 | 109 | // Create an updated, tinted cv::Mat by multiplying the original cv::Mat and the random color. 110 | cv::multiply(originalMat, randomColor, updatedMat); 111 | 112 | // Convert the updated cv::Mat to a UIImage and display it in the UIImageView. 113 | self.imageView.image = MatToUIImage(updatedMat); 114 | } 115 | 116 | @end 117 | -------------------------------------------------------------------------------- /Chapter 1/CoolPig/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CoolPig 4 | // 5 | // Created by Joseph Howse on 2015-11-03. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | #import "AppDelegate.h" 36 | 37 | int main(int argc, char * argv[]) { 38 | @autoreleasepool { 39 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork.xcodeproj/project.xcworkspace/xcuserdata/Joe.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork.xcodeproj/project.xcworkspace/xcuserdata/Joe.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork.xcodeproj/xcuserdata/Joe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork.xcodeproj/xcuserdata/Joe.xcuserdatad/xcschemes/LightWork.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork.xcodeproj/xcuserdata/Joe.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | LightWork.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D89870771C19232800D432E9 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // LightWork 4 | // 5 | // Created by Joseph Howse on 2015-12-09. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface AppDelegate : UIResponder 37 | 38 | @property (strong, nonatomic) UIWindow *window; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // LightWork 4 | // 5 | // Created by Joseph Howse on 2015-12-09. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import "AppDelegate.h" 35 | 36 | @interface AppDelegate () 37 | 38 | @end 39 | 40 | @implementation AppDelegate 41 | 42 | 43 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 44 | // Override point for customization after application launch. 45 | return YES; 46 | } 47 | 48 | - (void)applicationWillResignActive:(UIApplication *)application { 49 | // 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. 50 | // 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. 51 | } 52 | 53 | - (void)applicationDidEnterBackground:(UIApplication *)application { 54 | // 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. 55 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 56 | } 57 | 58 | - (void)applicationWillEnterForeground:(UIApplication *)application { 59 | // 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. 60 | } 61 | 62 | - (void)applicationDidBecomeActive:(UIApplication *)application { 63 | // 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. 64 | } 65 | 66 | - (void)applicationWillTerminate:(UIApplication *)application { 67 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_120-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_120-1.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_120.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_152.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_167.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_180.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_29.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_40.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_58-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_58-1.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_58.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_76.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_80-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_80-1.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_80.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_87.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "AppIcon_58.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "AppIcon_87.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "AppIcon_80.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "AppIcon_120.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "AppIcon_120-1.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "AppIcon_180.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "29x29", 41 | "idiom" : "ipad", 42 | "filename" : "AppIcon_29.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "29x29", 47 | "idiom" : "ipad", 48 | "filename" : "AppIcon_58-1.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "40x40", 53 | "idiom" : "ipad", 54 | "filename" : "AppIcon_40.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "40x40", 59 | "idiom" : "ipad", 60 | "filename" : "AppIcon_80-1.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "76x76", 65 | "idiom" : "ipad", 66 | "filename" : "AppIcon_76.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "76x76", 71 | "idiom" : "ipad", 72 | "filename" : "AppIcon_152.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "83.5x83.5", 77 | "idiom" : "ipad", 78 | "filename" : "AppIcon_167.png", 79 | "scale" : "2x" 80 | } 81 | ], 82 | "info" : { 83 | "version" : 1, 84 | "author" : "xcode" 85 | } 86 | } -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Fleur.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/Fleur.jpg -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | video-camera 33 | 34 | UIRequiresFullScreen 35 | 36 | UIStatusBarHidden 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationPortraitUpsideDown 42 | UIInterfaceOrientationLandscapeLeft 43 | UIInterfaceOrientationLandscapeRight 44 | 45 | UISupportedInterfaceOrientations~ipad 46 | 47 | UIInterfaceOrientationPortrait 48 | UIInterfaceOrientationPortraitUpsideDown 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UIViewControllerBasedStatusBarAppearance 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/SwitchCamera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/SwitchCamera.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/SwitchCamera@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/SwitchCamera@2x.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/SwitchCamera@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 2/9491OS_02_code/LightWork/SwitchCamera@3x.png -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/VideoCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoCamera.h 3 | // LightWork 4 | // 5 | // Created by Joseph Howse on 2015-12-11. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | 37 | @interface VideoCamera : CvVideoCamera 38 | 39 | @property BOOL letterboxPreview; 40 | 41 | - (void)setPointOfInterestInParentViewSpace:(CGPoint)point; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // LightWork 4 | // 5 | // Created by Joseph Howse on 2015-12-09. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface ViewController : UIViewController 37 | 38 | @end 39 | 40 | -------------------------------------------------------------------------------- /Chapter 2/9491OS_02_code/LightWork/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LightWork 4 | // 5 | // Created by Joseph Howse on 2015-12-09. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | #import "AppDelegate.h" 36 | 37 | int main(int argc, char * argv[]) { 38 | @autoreleasepool { 39 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Chapter 3/LightWork.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter 3/LightWork.xcodeproj/project.xcworkspace/xcuserdata/Joe.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork.xcodeproj/project.xcworkspace/xcuserdata/Joe.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Chapter 3/LightWork.xcodeproj/xcuserdata/Joe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Chapter 3/LightWork.xcodeproj/xcuserdata/Joe.xcuserdatad/xcschemes/LightWork.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Chapter 3/LightWork.xcodeproj/xcuserdata/Joe.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | LightWork.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D89870771C19232800D432E9 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Chapter 3/LightWork/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // LightWork 4 | // 5 | // Created by Joseph Howse on 2015-12-09. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface AppDelegate : UIResponder 37 | 38 | @property (strong, nonatomic) UIWindow *window; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Chapter 3/LightWork/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // LightWork 4 | // 5 | // Created by Joseph Howse on 2015-12-09. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import "AppDelegate.h" 35 | 36 | @interface AppDelegate () 37 | 38 | @end 39 | 40 | @implementation AppDelegate 41 | 42 | 43 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 44 | // Override point for customization after application launch. 45 | return YES; 46 | } 47 | 48 | - (void)applicationWillResignActive:(UIApplication *)application { 49 | // 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. 50 | // 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. 51 | } 52 | 53 | - (void)applicationDidEnterBackground:(UIApplication *)application { 54 | // 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. 55 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 56 | } 57 | 58 | - (void)applicationWillEnterForeground:(UIApplication *)application { 59 | // 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. 60 | } 61 | 62 | - (void)applicationDidBecomeActive:(UIApplication *)application { 63 | // 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. 64 | } 65 | 66 | - (void)applicationWillTerminate:(UIApplication *)application { 67 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_120-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_120-1.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_120.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_152.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_167.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_180.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_29.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_40.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_58-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_58-1.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_58.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_76.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_80-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_80-1.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_80.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/AppIcon_87.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "AppIcon_58.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "AppIcon_87.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "AppIcon_80.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "AppIcon_120.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "AppIcon_120-1.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "AppIcon_180.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "29x29", 41 | "idiom" : "ipad", 42 | "filename" : "AppIcon_29.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "29x29", 47 | "idiom" : "ipad", 48 | "filename" : "AppIcon_58-1.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "40x40", 53 | "idiom" : "ipad", 54 | "filename" : "AppIcon_40.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "40x40", 59 | "idiom" : "ipad", 60 | "filename" : "AppIcon_80-1.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "76x76", 65 | "idiom" : "ipad", 66 | "filename" : "AppIcon_76.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "76x76", 71 | "idiom" : "ipad", 72 | "filename" : "AppIcon_152.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "83.5x83.5", 77 | "idiom" : "ipad", 78 | "filename" : "AppIcon_167.png", 79 | "scale" : "2x" 80 | } 81 | ], 82 | "info" : { 83 | "version" : 1, 84 | "author" : "xcode" 85 | } 86 | } -------------------------------------------------------------------------------- /Chapter 3/LightWork/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Chapter 3/LightWork/Fleur.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/Fleur.jpg -------------------------------------------------------------------------------- /Chapter 3/LightWork/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | video-camera 33 | 34 | UIRequiresFullScreen 35 | 36 | UIStatusBarHidden 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UISupportedInterfaceOrientations~ipad 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationPortraitUpsideDown 48 | UIInterfaceOrientationLandscapeLeft 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | UIViewControllerBasedStatusBarAppearance 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Chapter 3/LightWork/SwitchCamera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/SwitchCamera.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/SwitchCamera@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/SwitchCamera@2x.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/SwitchCamera@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 3/LightWork/SwitchCamera@3x.png -------------------------------------------------------------------------------- /Chapter 3/LightWork/VideoCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoCamera.h 3 | // LightWork 4 | // 5 | // Created by Joseph Howse on 2015-12-11. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | 37 | @interface VideoCamera : CvVideoCamera 38 | 39 | @property BOOL letterboxPreview; 40 | 41 | - (void)setPointOfInterestInParentViewSpace:(CGPoint)point; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Chapter 3/LightWork/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // LightWork 4 | // 5 | // Created by Joseph Howse on 2015-12-09. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface ViewController : UIViewController 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Chapter 3/LightWork/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LightWork 4 | // 5 | // Created by Joseph Howse on 2015-12-09. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | #import "AppDelegate.h" 36 | 37 | int main(int argc, char * argv[]) { 38 | @autoreleasepool { 39 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks.xcodeproj/project.xcworkspace/xcuserdata/Joe.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks.xcodeproj/project.xcworkspace/xcuserdata/Joe.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Chapter 4/ManyMasks.xcodeproj/xcuserdata/Joe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks.xcodeproj/xcuserdata/Joe.xcuserdatad/xcschemes/ManyMasks.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks.xcodeproj/xcuserdata/Joe.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ManyMasks.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D8BCDDAC1C8B268E00A92DA1 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-05. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface AppDelegate : UIResponder 37 | 38 | @property (strong, nonatomic) UIWindow *window; 39 | 40 | 41 | @end 42 | 43 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-05. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import "AppDelegate.h" 35 | 36 | @interface AppDelegate () 37 | 38 | @end 39 | 40 | @implementation AppDelegate 41 | 42 | 43 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 44 | // Override point for customization after application launch. 45 | return YES; 46 | } 47 | 48 | - (void)applicationWillResignActive:(UIApplication *)application { 49 | // 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. 50 | // 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. 51 | } 52 | 53 | - (void)applicationDidEnterBackground:(UIApplication *)application { 54 | // 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. 55 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 56 | } 57 | 58 | - (void)applicationWillEnterForeground:(UIApplication *)application { 59 | // 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. 60 | } 61 | 62 | - (void)applicationDidBecomeActive:(UIApplication *)application { 63 | // 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. 64 | } 65 | 66 | - (void)applicationWillTerminate:(UIApplication *)application { 67 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_120-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_120-1.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_120.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_152.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_167.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_180.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_29.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_40.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_58-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_58-1.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_58.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_76.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_80-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_80-1.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_80.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/AppIcon_87.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "AppIcon_58.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "AppIcon_87.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "AppIcon_80.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "AppIcon_120.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "AppIcon_120-1.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "AppIcon_180.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "29x29", 41 | "idiom" : "ipad", 42 | "filename" : "AppIcon_29.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "29x29", 47 | "idiom" : "ipad", 48 | "filename" : "AppIcon_58-1.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "40x40", 53 | "idiom" : "ipad", 54 | "filename" : "AppIcon_40.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "40x40", 59 | "idiom" : "ipad", 60 | "filename" : "AppIcon_80-1.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "76x76", 65 | "idiom" : "ipad", 66 | "filename" : "AppIcon_76.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "76x76", 71 | "idiom" : "ipad", 72 | "filename" : "AppIcon_152.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "83.5x83.5", 77 | "idiom" : "ipad", 78 | "filename" : "AppIcon_167.png", 79 | "scale" : "2x" 80 | } 81 | ], 82 | "info" : { 83 | "version" : 1, 84 | "author" : "xcode" 85 | } 86 | } -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 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 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/CaptureViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CaptureViewController.h 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-05. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface CaptureViewController : UIViewController 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Face.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Face.cpp 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-05. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #include 35 | 36 | #include "Face.h" 37 | 38 | Face::Face(Species species, const cv::Mat &mat, const cv::Point2f &leftEyeCenter, const cv::Point2f &rightEyeCenter, const cv::Point2f &noseTip) 39 | : species(species) 40 | , leftEyeCenter(leftEyeCenter) 41 | , rightEyeCenter(rightEyeCenter) 42 | , noseTip(noseTip) 43 | { 44 | mat.copyTo(this->mat); 45 | } 46 | 47 | Face::Face() { 48 | } 49 | 50 | Face::Face(const Face &other) 51 | : species(other.species) 52 | , leftEyeCenter(other.leftEyeCenter) 53 | , rightEyeCenter(other.rightEyeCenter) 54 | , noseTip(other.noseTip) 55 | { 56 | other.mat.copyTo(mat); 57 | } 58 | 59 | Face::Face(const Face &face0, const Face &face1) { 60 | if (face0.mat.total() > face1.mat.total()) { 61 | initMergedFace(face0, face1); 62 | } else { 63 | initMergedFace(face1, face0); 64 | } 65 | } 66 | 67 | bool Face::isEmpty() const { 68 | return mat.empty(); 69 | } 70 | 71 | Species Face::getSpecies() const { 72 | return species; 73 | } 74 | 75 | const cv::Mat &Face::getMat() const { 76 | return mat; 77 | } 78 | 79 | int Face::getWidth() const { 80 | return mat.cols; 81 | } 82 | 83 | int Face::getHeight() const { 84 | return mat.rows; 85 | } 86 | 87 | const cv::Point2f &Face::getLeftEyeCenter() const { 88 | return leftEyeCenter; 89 | } 90 | 91 | const cv::Point2f &Face::getRightEyeCenter() const { 92 | return rightEyeCenter; 93 | } 94 | 95 | const cv::Point2f &Face::getNoseTip() const { 96 | return noseTip; 97 | } 98 | 99 | void Face::initMergedFace(const Face &biggerFace, const Face &smallerFace) { 100 | 101 | // Determine the species of the merged face. 102 | if (biggerFace.species == Human && smallerFace.species == Human) { 103 | species = Human; 104 | } else if (biggerFace.species == Cat && smallerFace.species == Cat) { 105 | species = Cat; 106 | } else { 107 | species = Hybrid; 108 | } 109 | 110 | // Warp the smaller face to align the eyes and nose with the bigger face. 111 | cv::Point2f srcPoints[3] = { 112 | smallerFace.getLeftEyeCenter(), 113 | smallerFace.getRightEyeCenter(), 114 | smallerFace.getNoseTip() 115 | }; 116 | cv::Point2f dstPoints[3] = { 117 | biggerFace.leftEyeCenter, 118 | biggerFace.rightEyeCenter, 119 | biggerFace.noseTip 120 | }; 121 | cv::Mat affineTransform = cv::getAffineTransform(srcPoints, dstPoints); 122 | cv::Size dstSize(biggerFace.mat.cols, biggerFace.mat.rows); 123 | cv::warpAffine(smallerFace.mat, mat, affineTransform, dstSize); 124 | 125 | // Perform any necessary color conversion. 126 | // Then, blend the warped face and the original bigger face. 127 | switch (mat.channels() - biggerFace.mat.channels()) { 128 | case 3: { 129 | // The warped face is BGRA and the bigger face is grayscale. 130 | cv::Mat otherMat; 131 | cv::cvtColor(biggerFace.mat, otherMat, cv::COLOR_GRAY2BGRA); 132 | cv::multiply(mat, otherMat, mat, 1.0 / 255.0); 133 | break; 134 | } 135 | case 2: { 136 | // The warped face is BGR and the bigger face is grayscale. 137 | cv::Mat otherMat; 138 | cv::cvtColor(biggerFace.mat, otherMat, cv::COLOR_GRAY2BGR); 139 | cv::multiply(mat, otherMat, mat, 1.0 / 255.0); 140 | break; 141 | } 142 | case 1: { 143 | // The warped face is BGRA and the bigger face is BGR. 144 | cv::Mat otherMat; 145 | cv::cvtColor(biggerFace.mat, otherMat, cv::COLOR_BGR2BGRA); 146 | cv::multiply(mat, otherMat, mat, 1.0 / 255.0); 147 | break; 148 | } 149 | case -1: 150 | // The warped face is BGR and the bigger face is BGRA. 151 | cv::cvtColor(mat, mat, cv::COLOR_BGR2BGRA); 152 | cv::multiply(mat, biggerFace.mat, mat, 1.0 / 255.0); 153 | break; 154 | case -2: 155 | // The warped face is grayscale and the bigger face is BGR. 156 | cv::cvtColor(mat, mat, cv::COLOR_GRAY2BGR); 157 | cv::multiply(mat, biggerFace.mat, mat, 1.0 / 255.0); 158 | break; 159 | case -3: 160 | // The warped face is grayscale and the bigger face is BGRA. 161 | cv::cvtColor(mat, mat, cv::COLOR_GRAY2BGRA); 162 | cv::multiply(mat, biggerFace.mat, mat, 1.0 / 255.0); 163 | break; 164 | default: 165 | // The color formats are the same. 166 | cv::multiply(mat, biggerFace.mat, mat, 1.0 / 255.0); 167 | break; 168 | } 169 | 170 | // The points of interest match the original bigger face. 171 | leftEyeCenter = biggerFace.leftEyeCenter; 172 | rightEyeCenter = biggerFace.rightEyeCenter; 173 | noseTip = biggerFace.noseTip; 174 | } 175 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Face.h: -------------------------------------------------------------------------------- 1 | // 2 | // Face.h 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-05. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #ifndef FACE_H 35 | #define FACE_H 36 | 37 | #include 38 | 39 | #include "Species.h" 40 | 41 | class Face { 42 | 43 | public: 44 | Face(Species species, const cv::Mat &mat, const cv::Point2f &leftEyeCenter, const cv::Point2f &rightEyeCenter, const cv::Point2f &noseTip); 45 | 46 | /** 47 | * Construct an empty face. 48 | */ 49 | Face(); 50 | 51 | /** 52 | * Construct a face by copying another face. 53 | */ 54 | Face(const Face &other); 55 | 56 | /** 57 | * Construct a face by merging two other faces. 58 | */ 59 | Face(const Face &face0, const Face &face1); 60 | 61 | bool isEmpty() const; 62 | 63 | Species getSpecies() const; 64 | 65 | const cv::Mat &getMat() const; 66 | int getWidth() const; 67 | int getHeight() const; 68 | 69 | const cv::Point2f &getLeftEyeCenter() const; 70 | const cv::Point2f &getRightEyeCenter() const; 71 | const cv::Point2f &getNoseTip() const; 72 | 73 | private: 74 | void initMergedFace(const Face &biggerFace, const Face &smallerFace); 75 | 76 | Species species; 77 | 78 | cv::Mat mat; 79 | 80 | cv::Point2f leftEyeCenter; 81 | cv::Point2f rightEyeCenter; 82 | cv::Point2f noseTip; 83 | }; 84 | 85 | #endif // !FACE_H 86 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/FaceDetector.h: -------------------------------------------------------------------------------- 1 | // 2 | // FaceDetector.h 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-06. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #ifndef FACE_DETECTOR_H 35 | #define FACE_DETECTOR_H 36 | 37 | #include 38 | 39 | #include "Face.h" 40 | 41 | class FaceDetector { 42 | 43 | public: 44 | FaceDetector(const std::string &humanFaceCascadePath, const std::string &catFaceCascadePath, const std::string &humanLeftEyeCascadePath, const std::string &humanRightEyeCascadePath); 45 | 46 | void detect(cv::Mat &image, std::vector &faces, double resizeFactor = 1.0, bool draw = false); 47 | 48 | private: 49 | void equalize(const cv::Mat &image); 50 | void detectInnerComponents(cv::Mat &image, std::vector &faces, double resizeFactor, bool draw, Species species, cv::Rect faceRect); 51 | 52 | cv::CascadeClassifier humanFaceClassifier; 53 | cv::CascadeClassifier catFaceClassifier; 54 | cv::CascadeClassifier humanLeftEyeClassifier; 55 | cv::CascadeClassifier humanRightEyeClassifier; 56 | 57 | #ifdef WITH_CLAHE 58 | cv::Ptr clahe; 59 | #endif 60 | 61 | cv::Mat resizedImage; 62 | cv::Mat equalizedImage; 63 | }; 64 | 65 | #endif // !FACE_DETECTOR_H 66 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/GeomUtils.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // GeomUtils.cpp 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-12. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #include "GeomUtils.h" 35 | 36 | bool GeomUtils::intersects(const cv::Rect &rect0, const cv::Rect &rect1) 37 | { 38 | return 39 | rect0.x < rect1.x + rect1.width && 40 | rect0.x + rect0.width > rect1.x && 41 | rect0.y < rect1.y + rect1.height && 42 | rect0.y + rect0.height > rect1.y; 43 | } -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/GeomUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // GeomUtils.h 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-12. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #ifndef GEOM_UTILS_H 35 | #define GEOM_UTILS_H 36 | 37 | #include 38 | 39 | namespace GeomUtils { 40 | bool intersects(const cv::Rect &rect0, const cv::Rect &rect1); 41 | } 42 | 43 | #endif // !GEOM_UTILS_H 44 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIRequiresFullScreen 34 | 35 | UIStatusBarHidden 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UIViewControllerBasedStatusBarAppearance 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/Mask.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/ReviewViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ReviewViewController.h 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-12. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface ReviewViewController : UIViewController 37 | 38 | @property UIImage *image; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/Species.h: -------------------------------------------------------------------------------- 1 | // 2 | // Species.h 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-05. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #ifndef SPECIES_H 35 | #define SPECIES_H 36 | 37 | enum Species { 38 | Human, 39 | Cat, 40 | Hybrid 41 | }; 42 | 43 | #endif // !SPECIES_H 44 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/SwitchCamera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/SwitchCamera.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/SwitchCamera@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/SwitchCamera@2x.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/SwitchCamera@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 4/ManyMasks/SwitchCamera@3x.png -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/VideoCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoCamera.h 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2015-12-11. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | 37 | @interface VideoCamera : CvVideoCamera 38 | 39 | @property BOOL letterboxPreview; 40 | 41 | - (void)setPointOfInterestInParentViewSpace:(CGPoint)point; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Chapter 4/ManyMasks/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ManyMasks 4 | // 5 | // Created by Joseph Howse on 2016-03-05. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | #import "AppDelegate.h" 36 | 37 | int main(int argc, char * argv[]) { 38 | @autoreleasepool { 39 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter.xcodeproj/project.xcworkspace/xcuserdata/Joe.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter.xcodeproj/project.xcworkspace/xcuserdata/Joe.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Chapter 5/BeanCounter.xcodeproj/xcuserdata/Joe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter.xcodeproj/xcuserdata/Joe.xcuserdatad/xcschemes/BeanCounter.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter.xcodeproj/xcuserdata/Joe.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BeanCounter.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D89DB9971CB8A04A00B057B6 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-08. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface AppDelegate : UIResponder 37 | 38 | @property (strong, nonatomic) UIWindow *window; 39 | 40 | 41 | @end 42 | 43 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-08. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import "AppDelegate.h" 35 | 36 | @interface AppDelegate () 37 | 38 | @end 39 | 40 | @implementation AppDelegate 41 | 42 | 43 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 44 | // Override point for customization after application launch. 45 | return YES; 46 | } 47 | 48 | - (void)applicationWillResignActive:(UIApplication *)application { 49 | // 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. 50 | // 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. 51 | } 52 | 53 | - (void)applicationDidEnterBackground:(UIApplication *)application { 54 | // 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. 55 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 56 | } 57 | 58 | - (void)applicationWillEnterForeground:(UIApplication *)application { 59 | // 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. 60 | } 61 | 62 | - (void)applicationDidBecomeActive:(UIApplication *)application { 63 | // 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. 64 | } 65 | 66 | - (void)applicationWillTerminate:(UIApplication *)application { 67 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_120-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_120-1.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_120.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_152.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_167.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_180.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_29.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_40.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_58-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_58-1.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_58.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_76.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_80-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_80-1.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_80.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/AppIcon_87.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "AppIcon_58.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "AppIcon_87.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "AppIcon_80.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "AppIcon_120.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "AppIcon_120-1.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "AppIcon_180.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "29x29", 41 | "idiom" : "ipad", 42 | "filename" : "AppIcon_29.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "29x29", 47 | "idiom" : "ipad", 48 | "filename" : "AppIcon_58-1.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "40x40", 53 | "idiom" : "ipad", 54 | "filename" : "AppIcon_40.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "40x40", 59 | "idiom" : "ipad", 60 | "filename" : "AppIcon_80-1.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "76x76", 65 | "idiom" : "ipad", 66 | "filename" : "AppIcon_76.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "76x76", 71 | "idiom" : "ipad", 72 | "filename" : "AppIcon_152.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "83.5x83.5", 77 | "idiom" : "ipad", 78 | "filename" : "AppIcon_167.png", 79 | "scale" : "2x" 80 | } 81 | ], 82 | "info" : { 83 | "version" : 1, 84 | "author" : "xcode" 85 | } 86 | } -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Blob.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Blob.cpp 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-09. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import "Blob.h" 35 | 36 | Blob::Blob(const cv::Mat &mat, uint32_t label) 37 | : label(label) 38 | { 39 | mat.copyTo(this->mat); 40 | } 41 | 42 | Blob::Blob() { 43 | } 44 | 45 | Blob::Blob(const Blob &other) 46 | : label(other.label) 47 | { 48 | other.mat.copyTo(mat); 49 | } 50 | 51 | bool Blob::isEmpty() const { 52 | return mat.empty(); 53 | } 54 | 55 | uint32_t Blob::getLabel() const { 56 | return label; 57 | } 58 | 59 | void Blob::setLabel(uint32_t value) { 60 | label = value; 61 | } 62 | 63 | const cv::Mat &Blob::getMat() const { 64 | return mat; 65 | } 66 | 67 | int Blob::getWidth() const { 68 | return mat.cols; 69 | } 70 | 71 | int Blob::getHeight() const { 72 | return mat.rows; 73 | } 74 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Blob.h: -------------------------------------------------------------------------------- 1 | // 2 | // Blob.h 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-09. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #ifndef BLOB_H 35 | #define BLOB_H 36 | 37 | #include 38 | 39 | class Blob 40 | { 41 | public: 42 | Blob(const cv::Mat &mat, uint32_t label = 0ul); 43 | 44 | /** 45 | * Construct an empty blob. 46 | */ 47 | Blob(); 48 | 49 | /** 50 | * Construct a blob by copying another blob. 51 | */ 52 | Blob(const Blob &other); 53 | 54 | bool isEmpty() const; 55 | 56 | uint32_t getLabel() const; 57 | void setLabel(uint32_t value); 58 | 59 | const cv::Mat &getMat() const; 60 | int getWidth() const; 61 | int getHeight() const; 62 | 63 | private: 64 | uint32_t label; 65 | 66 | cv::Mat mat; 67 | }; 68 | 69 | #endif // BLOB_H 70 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/BlobClassifier.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // BlobClassifier.cpp 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-10. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #include 35 | 36 | #include "BlobClassifier.h" 37 | 38 | #ifdef WITH_OPENCV_CONTRIB 39 | #include 40 | #endif 41 | 42 | const int HISTOGRAM_NUM_BINS_PER_CHANNEL = 32; 43 | const int HISTOGRAM_COMPARISON_METHOD = cv::HISTCMP_CHISQR_ALT; 44 | 45 | const float HISTOGRAM_DISTANCE_WEIGHT = 0.98f; 46 | const float KEYPOINT_MATCHING_DISTANCE_WEIGHT = 1.0f - HISTOGRAM_DISTANCE_WEIGHT; 47 | 48 | BlobClassifier::BlobClassifier() 49 | : clahe(cv::createCLAHE()) 50 | #ifdef WITH_OPENCV_CONTRIB 51 | , featureDetectorAndDescriptorExtractor(cv::xfeatures2d::SURF::create()) 52 | , descriptorMatcher(cv::DescriptorMatcher::create("FlannBased")) 53 | #else 54 | , featureDetectorAndDescriptorExtractor(cv::ORB::create()) 55 | , descriptorMatcher(cv::DescriptorMatcher::create("BruteForce-HammingLUT")) 56 | #endif 57 | { 58 | } 59 | 60 | void BlobClassifier::update(const Blob &referenceBlob) { 61 | referenceBlobDescriptors.push_back(createBlobDescriptor(referenceBlob)); 62 | } 63 | 64 | void BlobClassifier::clear() { 65 | referenceBlobDescriptors.clear(); 66 | } 67 | 68 | void BlobClassifier::classify(Blob &detectedBlob) const { 69 | BlobDescriptor detectedBlobDescriptor = createBlobDescriptor(detectedBlob); 70 | float bestDistance = FLT_MAX; 71 | uint32_t bestLabel = 0; 72 | for (const BlobDescriptor &referenceBlobDescriptor : referenceBlobDescriptors) { 73 | float distance = findDistance(detectedBlobDescriptor, referenceBlobDescriptor); 74 | if (distance < bestDistance) { 75 | bestDistance = distance; 76 | bestLabel = referenceBlobDescriptor.getLabel(); 77 | } 78 | } 79 | detectedBlob.setLabel(bestLabel); 80 | } 81 | 82 | BlobDescriptor BlobClassifier::createBlobDescriptor(const Blob &blob) const { 83 | 84 | const cv::Mat &mat = blob.getMat(); 85 | int numChannels = mat.channels(); 86 | 87 | // Calculate the histogram of the blob's image. 88 | cv::Mat histogram; 89 | int channels[] = { 0, 1, 2 }; 90 | int numBins[] = { HISTOGRAM_NUM_BINS_PER_CHANNEL, HISTOGRAM_NUM_BINS_PER_CHANNEL, HISTOGRAM_NUM_BINS_PER_CHANNEL }; 91 | float range[] = { 0.0f, 256.0f }; 92 | const float *ranges[] = { range, range, range }; 93 | cv::calcHist(&mat, 1, channels, cv::Mat(), histogram, 3, numBins, ranges); 94 | 95 | // Normalize the histogram. 96 | histogram *= (1.0f / (mat.rows * mat.cols)); 97 | 98 | // Convert the blob's image to grayscale. 99 | cv::Mat grayMat; 100 | switch (numChannels) { 101 | case 4: 102 | cv::cvtColor(mat, grayMat, cv::COLOR_BGRA2GRAY); 103 | break; 104 | default: 105 | cv::cvtColor(mat, grayMat, cv::COLOR_BGR2GRAY); 106 | break; 107 | } 108 | 109 | // Adaptively equalize the grayscale image to enhance local contrast. 110 | clahe->apply(grayMat, grayMat); 111 | 112 | // Detect features in the grayscale image. 113 | std::vector keypoints; 114 | featureDetectorAndDescriptorExtractor->detect(grayMat, keypoints); 115 | 116 | // Extract descriptors of the features. 117 | cv::Mat keypointDescriptors; 118 | featureDetectorAndDescriptorExtractor->compute(grayMat, keypoints, keypointDescriptors); 119 | 120 | return BlobDescriptor(histogram, keypointDescriptors, blob.getLabel()); 121 | } 122 | 123 | float BlobClassifier::findDistance(const BlobDescriptor &detectedBlobDescriptor, const BlobDescriptor &referenceBlobDescriptor) const { 124 | 125 | // Calculate the histogram distance. 126 | float histogramDistance = (float)cv::compareHist(detectedBlobDescriptor.getNormalizedHistogram(), referenceBlobDescriptor.getNormalizedHistogram(), HISTOGRAM_COMPARISON_METHOD); 127 | 128 | // Calculate the keypoint matching distance. 129 | float keypointMatchingDistance = 0.0f; 130 | std::vector keypointMatches; 131 | descriptorMatcher->match(detectedBlobDescriptor.getKeypointDescriptors(), referenceBlobDescriptor.getKeypointDescriptors(), keypointMatches); 132 | for (const cv::DMatch &keypointMatch : keypointMatches) { 133 | keypointMatchingDistance += keypointMatch.distance; 134 | } 135 | 136 | return histogramDistance * HISTOGRAM_DISTANCE_WEIGHT + keypointMatchingDistance * KEYPOINT_MATCHING_DISTANCE_WEIGHT; 137 | } 138 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/BlobClassifier.h: -------------------------------------------------------------------------------- 1 | // 2 | // BlobClassifier.h 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-10. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #ifndef BLOB_CLASSIFIER_H 35 | #define BLOB_CLASSIFIER_H 36 | 37 | #import "Blob.h" 38 | #import "BlobDescriptor.h" 39 | 40 | #include 41 | 42 | class BlobClassifier 43 | { 44 | public: 45 | BlobClassifier(); 46 | 47 | /** 48 | * Add a reference blob to the classification model. 49 | */ 50 | void update(const Blob &referenceBlob); 51 | 52 | /** 53 | * Clear the classification model. 54 | */ 55 | void clear(); 56 | 57 | /** 58 | * Classify a blob that was detected in a scene. 59 | */ 60 | void classify(Blob &detectedBlob) const; 61 | 62 | private: 63 | BlobDescriptor createBlobDescriptor(const Blob &blob) const; 64 | float findDistance(const BlobDescriptor &detectedBlobDescriptor, const BlobDescriptor &referenceBlobDescriptor) const; 65 | 66 | /** 67 | * An adaptive equalizer to enhance local contrast. 68 | */ 69 | cv::Ptr clahe; 70 | 71 | /** 72 | * A feature detector and descriptor extractor. 73 | * It finds features in images. 74 | * Then, it creates descriptors of the features. 75 | */ 76 | cv::Ptr featureDetectorAndDescriptorExtractor; 77 | 78 | /** 79 | * A descriptor matcher. 80 | * It matches features based on their descriptors. 81 | */ 82 | cv::Ptr descriptorMatcher; 83 | 84 | /** 85 | * Descriptors of the reference blobs. 86 | */ 87 | std::vector referenceBlobDescriptors; 88 | }; 89 | 90 | #endif // !BLOB_CLASSIFIER_H 91 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/BlobClassifierTraining.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | labelDescriptions 6 | 7 | unidentified 8 | Canadian penny 9 | Canadian nickel 10 | Canadian dime 11 | Canadian quarter 12 | loonie, Canadian dollar 13 | toonie, Canadian two-dollar 14 | pinto bean 15 | romano bean 16 | 17 | blobs 18 | 19 | 20 | imageFilename 21 | CanadianNickel_Heads_000.png 22 | label 23 | 2 24 | 25 | 26 | imageFilename 27 | CanadianNickel_Tails_000.png 28 | label 29 | 2 30 | 31 | 32 | imageFilename 33 | CanadianDime_Heads_000.png 34 | label 35 | 3 36 | 37 | 38 | imageFilename 39 | CanadianDime_Tails_000.png 40 | label 41 | 3 42 | 43 | 44 | imageFilename 45 | CanadianQuarter_Heads_000.png 46 | label 47 | 4 48 | 49 | 50 | imageFilename 51 | CanadianQuarter_Tails_000.png 52 | label 53 | 4 54 | 55 | 56 | imageFilename 57 | Loonie_Heads_000.png 58 | label 59 | 5 60 | 61 | 62 | imageFilename 63 | Loonie_Tails_000.png 64 | label 65 | 5 66 | 67 | 68 | imageFilename 69 | Toonie_Heads_000.png 70 | label 71 | 6 72 | 73 | 74 | imageFilename 75 | Toonie_Tails_000.png 76 | label 77 | 6 78 | 79 | 80 | imageFilename 81 | PintoBean_000.png 82 | label 83 | 7 84 | 85 | 86 | imageFilename 87 | RomanoBean_000.png 88 | label 89 | 8 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/BlobDescriptor.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // BlobDescriptor.cpp 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-15. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #include "BlobDescriptor.h" 35 | 36 | BlobDescriptor::BlobDescriptor(const cv::Mat &normalizedHistogram, const cv::Mat &keypointDescriptors, uint32_t label) 37 | : normalizedHistogram(normalizedHistogram) 38 | , keypointDescriptors(keypointDescriptors) 39 | , label(label) 40 | { 41 | } 42 | 43 | const cv::Mat &BlobDescriptor::getNormalizedHistogram() const { 44 | return normalizedHistogram; 45 | } 46 | 47 | const cv::Mat &BlobDescriptor::getKeypointDescriptors() const { 48 | return keypointDescriptors; 49 | } 50 | 51 | uint32_t BlobDescriptor::getLabel() const { 52 | return label; 53 | } 54 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/BlobDescriptor.h: -------------------------------------------------------------------------------- 1 | // 2 | // BlobDescriptor.h 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-15. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #ifndef BLOB_DESCRIPTOR_H 35 | #define BLOB_DESCRIPTOR_H 36 | 37 | #include 38 | 39 | class BlobDescriptor 40 | { 41 | public: 42 | BlobDescriptor(const cv::Mat &normalizedHistogram, const cv::Mat &keypointDescriptors, uint32_t label); 43 | 44 | const cv::Mat &getNormalizedHistogram() const; 45 | const cv::Mat &getKeypointDescriptors() const; 46 | uint32_t getLabel() const; 47 | 48 | private: 49 | cv::Mat normalizedHistogram; 50 | cv::Mat keypointDescriptors; 51 | uint32_t label; 52 | }; 53 | 54 | #endif // !BLOB_DESCRIPTOR_H 55 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/BlobDetector.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // BlobDetector.cpp 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-10. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #include 35 | 36 | #include "BlobDetector.h" 37 | 38 | const double MASK_STD_DEVS_FROM_MEAN = 1.0; 39 | const double MASK_EROSION_KERNEL_RELATIVE_SIZE_IN_IMAGE = 0.005; 40 | const int MASK_NUM_EROSION_ITERATIONS = 8; 41 | 42 | const double BLOB_RELATIVE_MIN_SIZE_IN_IMAGE = 0.05; 43 | 44 | const cv::Scalar DRAW_RECT_COLOR(0, 255, 0); // Green 45 | 46 | void BlobDetector::detect(cv::Mat &image, std::vector &blobs, double resizeFactor, bool draw) 47 | { 48 | blobs.clear(); 49 | 50 | if (resizeFactor == 1.0) { 51 | createMask(image); 52 | } else { 53 | cv::resize(image, resizedImage, cv::Size(), resizeFactor, resizeFactor, cv::INTER_AREA); 54 | createMask(resizedImage); 55 | } 56 | 57 | // Find the edges in the mask. 58 | cv::Canny(mask, edges, 191, 255); 59 | 60 | // Find the contours of the edges. 61 | cv::findContours(edges, contours, hierarchy, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE); 62 | 63 | std::vector rects; 64 | int blobMinSize = (int)(MIN(image.rows, image.cols) * BLOB_RELATIVE_MIN_SIZE_IN_IMAGE); 65 | for (std::vector contour : contours) { 66 | 67 | // Find the contour's bounding rectangle. 68 | cv::Rect rect = cv::boundingRect(contour); 69 | 70 | // Restore the bounding rectangle to the original scale. 71 | rect.x /= resizeFactor; 72 | rect.y /= resizeFactor; 73 | rect.width /= resizeFactor; 74 | rect.height /= resizeFactor; 75 | 76 | if (rect.width < blobMinSize || rect.height < blobMinSize) { 77 | continue; 78 | } 79 | 80 | // Create the blob from the sub-image inside the bounding rectangle. 81 | blobs.push_back(Blob(cv::Mat(image, rect))); 82 | 83 | // Remember the bounding rectangle in order to draw it later. 84 | rects.push_back(rect); 85 | } 86 | 87 | if (draw) { 88 | // Draw the bounding rectangles. 89 | for (const cv::Rect &rect : rects) { 90 | cv::rectangle(image, rect.tl(), rect.br(), DRAW_RECT_COLOR); 91 | } 92 | } 93 | } 94 | 95 | const cv::Mat &BlobDetector::getMask() const { 96 | return mask; 97 | } 98 | 99 | void BlobDetector::createMask(const cv::Mat &image) { 100 | 101 | // Find the image's mean color. 102 | // Presumably, this is the background color. 103 | // Also find the standard deviation. 104 | cv::Scalar meanColor; 105 | cv::Scalar stdDevColor; 106 | cv::meanStdDev(image, meanColor, stdDevColor); 107 | 108 | // Create a mask based on a range around the mean color. 109 | cv::Scalar halfRange = MASK_STD_DEVS_FROM_MEAN * stdDevColor; 110 | cv::Scalar lowerBound = meanColor - halfRange; 111 | cv::Scalar upperBound = meanColor + halfRange; 112 | cv::inRange(image, lowerBound, upperBound, mask); 113 | 114 | // Erode the mask to merge neighboring blobs. 115 | int kernelWidth = (int)(MIN(image.cols, image.rows) * MASK_EROSION_KERNEL_RELATIVE_SIZE_IN_IMAGE); 116 | if (kernelWidth > 0) { 117 | cv::Size kernelSize(kernelWidth, kernelWidth); 118 | cv::Mat kernel = cv::getStructuringElement(cv::MORPH_RECT, kernelSize); 119 | cv::erode(mask, mask, kernel, cv::Point(-1, -1), MASK_NUM_EROSION_ITERATIONS); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/BlobDetector.h: -------------------------------------------------------------------------------- 1 | // 2 | // BlobDetector.h 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-10. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #ifndef BLOB_DETECTOR_H 35 | #define BLOB_DETECTOR_H 36 | 37 | #include "Blob.h" 38 | 39 | class BlobDetector 40 | { 41 | public: 42 | void detect(cv::Mat &image, std::vector &blob, double resizeFactor = 1.0, bool draw = false); 43 | 44 | const cv::Mat &getMask() const; 45 | 46 | private: 47 | void createMask(const cv::Mat &image); 48 | 49 | cv::Mat resizedImage; 50 | cv::Mat mask; 51 | cv::Mat edges; 52 | std::vector> contours; 53 | std::vector hierarchy; 54 | }; 55 | 56 | #endif // !BLOB_DETECTOR_H 57 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/CanadianDime_Heads_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/CanadianDime_Heads_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/CanadianDime_Tails_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/CanadianDime_Tails_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/CanadianNickel_Heads_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/CanadianNickel_Heads_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/CanadianNickel_Tails_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/CanadianNickel_Tails_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/CanadianQuarter_Heads_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/CanadianQuarter_Heads_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/CanadianQuarter_Tails_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/CanadianQuarter_Tails_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/CaptureViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CaptureViewController.h 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-08. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface CaptureViewController : UIViewController 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | video-camera 33 | 34 | UIRequiresFullScreen 35 | 36 | UIStatusBarHidden 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UISupportedInterfaceOrientations~ipad 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationPortraitUpsideDown 48 | UIInterfaceOrientationLandscapeLeft 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | UIViewControllerBasedStatusBarAppearance 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Loonie_Heads_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Loonie_Heads_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Loonie_Tails_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Loonie_Tails_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/PintoBean_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/PintoBean_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/ReviewViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ReviewViewController.h 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-03-12. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | @interface ReviewViewController : UIViewController 37 | 38 | @property UIImage *image; 39 | @property NSString *caption; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/RomanoBean_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/RomanoBean_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/SwitchCamera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/SwitchCamera.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/SwitchCamera@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/SwitchCamera@2x.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/SwitchCamera@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/SwitchCamera@3x.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/TheQueen'sBeans.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/TheQueen'sBeans.jpg -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Toonie_Heads_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Toonie_Heads_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/Toonie_Tails_000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Chapter 5/BeanCounter/Toonie_Tails_000.png -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/VideoCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoCamera.h 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2015-12-11. 6 | // Copyright © 2015 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | 36 | 37 | @interface VideoCamera : CvVideoCamera 38 | 39 | @property BOOL letterboxPreview; 40 | 41 | - (void)setPointOfInterestInParentViewSpace:(CGPoint)point; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Chapter 5/BeanCounter/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BeanCounter 4 | // 5 | // Created by Joseph Howse on 2016-04-08. 6 | // Copyright © 2016 Nummist Media Corporation Limited. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // (1) Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // (2) Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | 34 | #import 35 | #import "AppDelegate.h" 36 | 37 | int main(int argc, char * argv[]) { 38 | @autoreleasepool { 39 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Packt Publishing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # iOS-Application-Development-with-OpenCV3 5 | [iOS Application Development with OpenCV3](https://www.packtpub.com/application-development/ios-application-development-opencv?utm_source=GitHub&utm_medium=repository&utm_campaign=9781785289491) by [Packt Publishing](https://www.packtpub.com/) 6 | 7 | You need a computer running Mac OS 10.10 (or a later version) as well as an iPhone, iPad, or iPod Touch running iOS 9 (or a later version). 8 | 9 | On your computer, you need to install Apple's standard tools for iOS developers. These include Xcode, iOS SDK, and the Xcode Command Line Tools. You also need to set up OpenCV 3.1 (or a later version). All this software is free, and Chapter 1, Setting Up Software and Hardware, provides setup instructions. 10 | 11 | This book is great for developers who are new to iOS, computer vision, or both. 12 | Previous experience with Objective-C or C++ is recommended. 13 | 14 | Detailed installation steps (software-wise) 15 | The steps should be listed in a way that it prepares the system environment to be able to test the codes of the book. 16 | 17 | Mac Setup: 18 | * Download and install from Mac App Store the latest Xcode version (Currently 7.2). Or from the link, https://developer.apple.com/xcode/download/. 19 | * Download and install the Xamarin tools for Mac, https://xamarin.com/download. 20 | * Download and install the Xamarin Android Emulator. https://xamarin.com/android-player. 21 | * Check if Android SDK 5.1.1 is installed to test your apps with this SDK, open Xamarin Studio and go to Tools | Open Android SDK Manager… check the 5.1.1 (API 22) and click Install Packages… 22 | 23 | 24 | Windows Setup 25 | * Download Community Edition or Enterprise Trial edition, https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx. 26 | * Download and install the Xamarin tools for Windows, https://xamarin.com/download. 27 | * Download and install the Xamarin Android Emulator. https://xamarin.com/android-player 28 | * Check if Android SDK 5.1.1 is installed to test your apps with this SDK, open Xamarin Studio and go to Tools | Open Android SDK Manager… check the 5.1.1 (API 22) and click Install Packages… 29 | 30 | For more information refer to the following books: 31 | * [Instant OpenCV for iOS](https://www.packtpub.com/application-development/instant-opencv-ios?utm_source=GitHub&utm_medium=repository&utm_campaign=9781782163848) 32 | * [Integrating Facebook iOS SDK with Your Application](https://www.packtpub.com/web-development/integrating-facebook-ios-sdk-your-application?utm_source=GitHub&utm_medium=repository&utm_campaign=9781782168430) 33 | * [Application Development with Parse using iOS SDK](https://www.packtpub.com/application-development/application-development-parse-using-ios-sdk?utm_source=GitHub&utm_medium=repository&utm_campaign=9781783550333) 34 | ### Download a free PDF 35 | 36 | If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.
37 |

https://packt.link/free-ebook/9781785289491

-------------------------------------------------------------------------------- /Software and hardware list.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/iOS-Application-Development-with-OpenCV3/7ae7b5729c4472b955a9a265e8f14f78886db8fe/Software and hardware list.pdf --------------------------------------------------------------------------------