TABLE OF CONTENTS


GENERAL PRODUCT DOCUMENTATION


CURRENT VERSION

2021.03 – released March 2021


SYSTEM REQUIREMENTS AND PRE-REQUISITES

  • Apple iOS version 9.x or later


PERMISSIONS

Access to camera or photos library (https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_ios)


PREPARATION FOR USAGE

  • Add .framework file to project
  • Add .framework file to "Linked Frameworks and libraries" to project target


USING THE LIBRARY

To start using the library, add import to the top of your header file (.h) or Swift source file (.swift)


Objective-C

import <ConPDS/ConPDS.h>

Swift

import ConPDS


Note: Framework contains both iOS devices (armv7, arm64) and iOS simulator (i386, x86_64) architectures.
To deploy an app to a real device or upload the app to AppStore; you need to trim unsupported architectures for the current target. To do this, go in XCode -> Project -> Build Phases add at last Run Script phase.


Insert following script:

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done

echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"

echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done


RECOGNIZE TO JSON

  • Create an instance of class RecognitionWrapper
  • Call method ‘recognizeToJSON’ or ‘recognizeToJSONFromPictureBuffer’
  • The method returns a pointer to the instance of NSString. It is 'nil' if recognizing failed. If recognition is successful, it contains JSON with the objects documented in the section "OCR ENGINE OUTPUT."


LICENSING

  • Use static instance of class License
  • Use method ‘getPublicKeyFromServer:completion’ to get server public key. Completion contains public key (optional) and error (optional)
  • Use method ‘sendLicenseRequest:serverPublicKey:apiKey:licenseApiKey:completion’ to get information about license. Completion contains instance of class LicenseInfo(optional) and error (optional)
  • Or simply use method 'getLicenseInfo(apiKey:licenseApiKey:completion' to get information about license. Completion contains instance of class LicenseInfo(optional) and error (optional)

License checking errors

  • invalidServerPublicKey: Invalid server public key
  • invalidJSONResponse: Invalid JSON response
  • invalidResponse: Invalid response from server
  • invalidURL: Invalid server URL
  • invalidDevicId: Error while getting device ID
  • timeOut: Request timeout.
  • invalidAPIKey: Invalid API key


EXAMPLE OF USAGE

let recognizer = RecognitionWrapper()

// Recognize to JSON from Image
let json = try? recognizer.recognize(toJSON: image)

//Recognize from image buffer to JSON
if let imageData = UIImagePNGRepresentation(image) {
let json = try? recognizer.recognizeToJSON(fromPictureBuffer: imageData)
}