Introduction¶
VDPhotoSelfieCapture arises due to the necessity of a more advanced and safer selfie capture technique. The SDK captures a selfie image and cuts face if found. The capture is made automatically due to its face detection techniques. Both images are captured using the front camera of the device.
Some permissions are needed and have to be written in the info.plist of the app using the framework:
- Camera.
The SDK is localized in English and Spanish. By default English language is selected and the language is automatically switched to Spanish if the device locale is Spanish.
The SDK can be configured using a dictionary. All possible keys and values can be checked in Configuration.
Note
If the live photo is activated, and the device is capable of it, check Liveness Check
Specifications¶
- iOS (iPhone only) minimum operating system version: 11.
- Additionally, some dependencies are needed.
- Internal dependencies.
- VDLibrary
- ImageProcessing
- Internal dependencies.
-
Full SDK implementation sizes in MB:
Architecture VDLibrary ImageProcessing SDK Total arm64 (device) 2.67 10.40 2.62 15.69 arm64 (simulator) 2.65 10.37 2.67 15.69 x86_64 (simulator) 2.62 16.07 2.69 21.38 TOTAL 5.65 36.81 5.63 48.09 These sizes have been calculated using
lipo -detailed_info
for fat libraries andgdu
ordu
for the rest of files. NodSYMs
folders are included in these sizes. The final AppStore and installed sizes may differ.If more than one architecture is supported the total size is the sum of each one of them, e.g. if all architectures are supported the combined size of this SDK and its dependencies will be a total of 48.09MB.
The final user is not affected by this total size because the store only distributes the specific architecture of the user's device once the app is downloaded and installed.
- Image is resized to 2MPx.
Integration¶
- Create a new Xcode project.
- Add permissions required into Info.plist:
- Camera Usage.
- Drag and drop all .xcframework into Xcode and copy inside project.
- Add all .xcframework into the targets general tab, inside Embedded Binaries and Linked Frameworks and Libraries (if it does not appear yet), they should appear in mode "Embed & Sign".
- Import VDPhotoSelfieCapture/VDPhotoSelfieCapture.h and implement VDPhotoSelfieCaptureProtocol in the class that uses it.
- Write down all the required delegated methods into the class that uses the framework. Call the methods of the SDK as needed.
SDK update¶
Once a new SDK is released the following steps have to be followed to properly update the SDK.
- Remove all updating .framework located in the project. Do not remove only the reference; remove the actual file if the deletion is done with the help of Xcode. Just in case, empty the bin too.
- Compile and/or run to force errors. If no error occurs then a cached framework is in memory. Clean cache and project.
- Add all new .xcframework and implement new interfaces if necessary.
- Compile and run.
In case of doubt, also the following can be done.
- Check the installed version by calling the
getVersion()
method.
Example of use¶
#import "VDPhotoSelfieCapture/VDPhotoSelfieCapture.h"
@interface ViewController () <VDPhotoSelfieCaptureProtocol>
// Call something like this to start the photo selfie capture
NSMutableDictionary<NSString*, id>* configuration = [NSMutableDictionary dictionary];
////////////// Veridas' recommended configuration //////////////
configuration[@"capturebackgroundcolor"] = @{@"alpha": @"0.502", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"continuebuttonbackgroundcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"selfiealivearrowcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"facedetectednotcenteredcolor"] = @{@"alpha": @"1", @"red": @"235", @"green": @"141", @"blue": @"0"};
configuration[@"facedetectedokcolor"] = @{@"alpha": @"1", @"red": @"83", @"green": @"163", @"blue": @"53"};
configuration[@"popupvalidationbackgroundcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"informativetextcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"orientationbackgroundcolor"] = @{@"alpha": @"0.502", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"selfiengaserroralerttitlecolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"repeatbuttonbackgroundcolor"] = @{@"alpha": @"1", @"red": @"255", @"green": @"255", @"blue": @"255"};
configuration[@"repeatbuttontextcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"checkselfietextcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"validationviewbackgroundcolor"] = @{@"alpha": @"1", @"red": @"255", @"green": @"255", @"blue": @"255"};
configuration[@"tickcirclecolor"] = @{@"alpha": @"1", @"red": @"220", @"green": @"239", @"blue": @"212"};
configuration[@"tickcolor"] = @{@"alpha": @"1", @"red": @"83", @"green": @"163", @"blue": @"53"};
configuration[@"selfietutorialbackgroundcolor"] = @{@"alpha": @"1", @"red": @"255", @"green": @"255", @"blue": @"255"};
configuration[@"selfietutorialdescriptioncolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"selfietutorialstepbuttonnexttextcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"selfietutorialcurrentpointcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"selfietutorialstepbuttonprevioustextcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"selfietutorialcontinuebuttonfirstgradientcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"selfietutorialcontinuebuttonsecondgradientcolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"selfietutorialsteptitlecolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"selfietutorialgeneraltitlecolor"] = @{@"alpha": @"1", @"red": @"0", @"green": @"13", @"blue": @"68"};
configuration[@"mobileovalcolor"] = @{@"alpha": @"1", @"red": @"220", @"green": @"239", @"blue": @"212"};
configuration[@"closebutton"] = @"NO";
if (![VDPhotoSelfieCapture isStarted]) {
NSDictionary* configuration = @{"closebutton": "NO"}
[VDPhotoSelfieCapture startWithDelegate:self andConfiguration: configuration];
}
....
// Delegated methods.
// Called when the selfie has been captured
- (void)VDPhotoSelfieCaptured:(NSData *)photoSelfieData andFace:(NSData *)face {
// Do with images as needed.
}
// Called when the framework has finished.
// processFinished (Boolean) Indicates if the process has finished (true) or has been interrupted (false)
- (void)VDPhotoSelfieAllFinished: (Boolean)processFinished {
// When the framework ends, proceed as needed
}
import VDPhotoSelfieCapture
class MyClass: VDPhotoSelfieCaptureProtocol {
// PROTOCOL IMPLEMENTATION.
// Called when a selfie image has been captured
func vdPhotoSelfieCaptured(_ photoSelfieData: Data!, andFace face: Data!) {
// Do with images as needed.
}
// Called when the framework has finished.
// processFinished (Boolean) Indicates if the process has finished (true) or has been interrupted (false)
func vdPhotoSelfieAllFinished(_ processFinished: Bool) {
// When the framework ends, proceed as needed
}
....
// Call something like this to start the photo selfie capture
var configuration: [String: Any] = ["closebutton": "NO", "livephoto": "NO"]
////////////// Veridas' recommended configuration //////////////
configuration["capturebackgroundcolor"] = ["alpha": "0.502", "red": "0", "green": "13", "blue": "68"]
configuration["continuebuttonbackgroundcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["selfiealivearrowcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["facedetectednotcenteredcolor"] = ["alpha": "1", "red": "235", "green": "141", "blue": "0"]
configuration["facedetectedokcolor"] = ["alpha": "1", "red": "83", "green": "163", "blue": "53"]
configuration["popupvalidationbackgroundcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["informativetextcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["orientationbackgroundcolor"] = ["alpha": "0.502", "red": "0", "green": "13", "blue": "68"]
configuration["selfiengaserroralerttitlecolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["repeatbuttonbackgroundcolor"] = ["alpha": "1", "red": "255", "green": "255", "blue": "255"]
configuration["repeatbuttontextcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["checkselfietextcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["validationviewbackgroundcolor"] = ["alpha": "1", "red": "255", "green": "255", "blue": "255"]
configuration["tickcirclecolor"] = ["alpha": "1", "red": "220", "green": "239", "blue": "212"]
configuration["tickcolor"] = ["alpha": "1", "red": "83", "green": "163", "blue": "53"]
configuration["selfietutorialbackgroundcolor"] = ["alpha": "1", "red": "255", "green": "255", "blue": "255"]
configuration["selfietutorialdescriptioncolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["selfietutorialstepbuttonnexttextcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["selfietutorialcurrentpointcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["selfietutorialstepbuttonprevioustextcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["selfietutorialcontinuebuttonfirstgradientcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["selfietutorialcontinuebuttonsecondgradientcolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["selfietutorialsteptitlecolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["selfietutorialgeneraltitlecolor"] = ["alpha": "1", "red": "0", "green": "13", "blue": "68"]
configuration["mobileovalcolor"] = ["alpha": "1", "red": "220", "green": "239", "blue": "212"]
if !VDPhotoSelfieCapture.isStarted() {
VDPhotoSelfieCapture.start(withDelegate: self, andConfiguration: configuration)
}
}
Workflow¶
The next diagram represents de current Alive workflow of the framework. Some method's names may de shortened due to legibility issues.
Third party libraries¶
- OpenCV 4.5.2 (main page. documentation). Used for image manipulation.