Deprecation warning
Please note that this is outdated documentation for an older release of the Scandit Barcode Scanner SDK.
We are deprecating the 5.x API on all platforms (except Linux). Release 5.19 in April 2021 will be our final. Applications running 5.x will continue to work, and we will continue to release critical bug fixes and security patches only, for one year. We encourage you to migrate to 6.x and take advantage of our latest / advanced features and improved performance.
You'll find the updated documentation at: Data Capture SDK Documentation for Android
Detailed Description
Opaque recognition context data structure.
The recognition context manages scanner objects of different types and takes care of scheduling the recognition process. By default, the recognition context does not have any scanners. To recognize a particular set of objects, the scanner object must be created. At the moment, the only available scanner is the ScBarcodeScanner which recognizes 1d and 2d codes in images.
To create a new recognition context a platform-specific function must be used. These functions take care of license-management read the appropriate system properties to optimize the recognition process for the device.
Member Function Documentation
ScRecognitionContext * sc_recognition_context_new | ( | const char * | license_key, |
const char * | writable_data_path, | ||
JNIEnv * | env, | ||
jobject | activity, | ||
const char * | device_name | ||
) |
Create a new recognition context (Android only).
- Parameters
-
license_key Your license key, can't be NULL. writable_data_path Path to a writable folder, can't be NULL. env Pointer to the JNIEnv* object instance, can't be NULL. activity Pointer to the activity object the recognition context is created in. device_name Optional descriptive device name. Can be any string to track individual physical devices in Scanalytics. This parameter can be NULL to disable tracking.
For performance reasons it is recommended that only one context per application is used. If multiple contexts are created, make sure that context with different device_model_name do not share the same writable_data_path.
- Returns
- The newly created recognition context. After use, the context must be released by calling sc_recognition_context_release().
- Since
- 4.6.0
ScRecognitionContext * sc_recognition_context_new | ( | const char * | license_key, |
const char * | device_name | ||
) |
Create a new recognition context (iOS only).
- Parameters
-
license_key Your license key, can't be NULL. device_name Optional descriptive device name. Can be any string to track individual physical devices in Scanalytics. This parameter can be NULL to disable tracking.
For performance reasons it is recommended that only one context per application is used. If multiple contexts are created, make sure that context with different device_model_name do not share the same writable_data_path.
- Returns
- The newly created recognition context. After use, the context must be released by calling sc_recognition_context_release().
- Since
- 4.6.0
ScRecognitionContext * sc_recognition_context_new | ( | const char * | license_key, |
const char * | writable_data_path, | ||
const char * | device_name | ||
) |
Recognition context constructor.
- Parameters
-
license_key your license key, can't be NULL writable_data_path path to a writable folder, can't be NULL device_name a descriptive name or NULL
Note: This constructor is not available on Android.
The device_model_name parameter is used to optimize the algorithms for a certain hardware. On iOS and Windows the official device ids should be used. E.g. 'iPhone5,1'.
The device_name can be any string to track individual physical devices in Scanalytics. This parameter can be NULL to disable tracking.
For performance reasons it is recommended that only one context per application is used. If multiple contexts are created, make sure that context with different device_model_name do not share the same writable_data_path. Contexts with the same device_model_name can share a writable_data_path.
- Returns
- The newly created recognition context. After use, the context must be released by calling sc_recognition_context_release().
- Since
- 4.6.0
void sc_recognition_context_retain | ( | ScRecognitionContext * | context | ) |
Increase reference count of recognition context by one.
- Parameters
-
context A valid context. Must not be null
- Since
- 4.6.0
void sc_recognition_context_release | ( | ScRecognitionContext * | context | ) |
Decrease reference count of recognition context by one.
When the reference count drops to zero, the recognition context is deallocated.
- Parameters
-
context A valid context. May be null
- Since
- 4.6.0
void sc_recognition_context_start_new_frame_sequence | ( | ScRecognitionContext * | context | ) |
Start processing a new batch of continuous frames.
Call this function to inform the recognition context that a new sequence of frames starts. The recognition context can assume that frames passed to sc_recognition_context_process_frame() have temporal consistency and can use it to optimize the recognition processs. To indicate discontinuities between frames, e.g. when resuming the camera after a pause, use sc_recognition_context_end_frame_sequence() followed by sc_recognition_context_start_new_frame_sequence().
This function must be called once before sc_recognition_context_process_frame().
The following example shows how to process an individual image:
- Parameters
-
context A valid context. Must not be null.
- Since
- 4.6.0
ScProcessFrameResult sc_recognition_context_process_frame | ( | ScRecognitionContext * | context, |
const ScImageDescription * | image_description, | ||
const uint8_t * | image_data | ||
) |
Process image frame with this recognition context.
The image is processed by the scanners associated with this context. The results, for example the recognized barcodes, can be accessed directly on the scanner objects.
Although you can pass in images of any size, and use any of the image layouts defined in ScImageLayout, the recognition context and the associated scanners have been optimized for images that are approximately 1280x720 pixels in size and have a continuous gray-channel. These pixel formats include SC_IMAGE_LAYOUT_GRAY_8U, SC_IMAGE_LAYOUT_YPCBCR_8U, and SC_IMAGE_LAYOUT_YPCRCB_8U.
- Parameters
-
context A valid context. Must not be null. image_description Input image description pointer. Must not be null. image_data Input image data pointer. Must not be null.
- Returns
- A structure holding a unique identifier for the processed frame and a process frame status code. The value of status code is:
- SC_RECOGNITION_CONTEXT_STATUS_SUCCESS when the frame was processed without error.
- SC_RECOGNITION_CONTEXT_STATUS_INCONSISTENT_IMAGE_DATA when not all required properties for the image descriptions' layout are provided.
- SC_RECOGNITION_CONTEXT_STATUS_FRAME_SEQUENCE_NOT_STARTED when sc_recognition_context_process_frame() is called without a prior call to sc_recognition_context_start_new_frame_sequence().
- SC_RECOGNITION_CONTEXT_STATUS_INTERNAL_ERROR when the recognition context encountered an internal error.
- See also
- sc_barcode_scanner_get_session
- Since
- 4.6.0
void sc_recognition_context_end_frame_sequence | ( | ScRecognitionContext * | context | ) |
Signal that a batch of continuous frames ended.
Use this function to indicate the end of a group of continuous frames. This function will automatically be called when the recognition context is deallocated.
- Parameters
-
context A valid context. Must not be null.
- Since
- 4.6.0
void sc_recognition_context_set_geographical_location | ( | ScRecognitionContext * | context, |
float | latitude, | ||
float | longitude | ||
) |
Set the geographical location.
Set the location at which the device currently is according to its location services. This is optional information, which, when provided, is transmitted to Scanalytics.
- Parameters
-
context A valid context. Must not be null latitude the latitude (north) in WGS84 coordinates. longitude the longitude (east) in WGS84 coordinates.
The coordinate for Zurich, Switzerland would be 47.366667, 8.55.
- Since
- 4.6.0
ScContextStatusFlag sc_recognition_context_process_image | ( | ScRecognitionContext * | context, |
UIImage * | image | ||
) |
Process image frame with this recognition context.
The image is processed by the scanners associated with this context. The results, for example the recognized barcodes, can be accessed directly on the scanner objects.
Make sure to use sc_barcode_scanner_session_get_all_recognized_codes() when scanning barcodes, since the image may be processed multiple times and only the results of the last are available in sc_barcode_scanner_session_get_newly_recognized_codes().
- Parameters
-
context A valid context. Must not be null. image Input image. Must not be null.
- Returns
- the status of the recognition context.
- See also
- sc_barcode_scanner_get_session
- Since
- 4.14.0
The documentation for this struct was generated from the following file: