Memory Management Rules
Object represented by opaque pointers in Scandit SDK internally use reference counting. To claim ownership of an object, the reference count of the object is increased and decreased again when the object is no longer needed. When the reference count drops to zero, e.g. the object has no owners, the object is deallocated (freed).
To claim ownership of an object, use one of the sc_*_retain
functions and sc_*_release
when you finished using it.
Some objects returned by functions are automatically owned by the caller and must be released after use, whereas others must be retained manually, if required. The following rules apply:
- Objects created by you (using any of the
*_new
functions) must be released after use by you. - Objects returned by functions that explicitly state they transfer ownership to you, must be released after use. An examples of such a function is sc_barcode_scanner_session_get_newly_recognized_codes().
- You must release objects on which you called
sc_*_retain
Differences to the Data Capture API (6.x) and Barcode Picker API (5.x)
If you have previously developed an application using the Scandit SDK Picker or Data Capture API on Android or iOS and are now using the Scandit SDK low-level API for scanning barcodes, there are a few differences to be aware of:
- The symbology names returned by sc_symbology_to_string() are not the same as the symbology names used by the Picker or Data Capture APIs.
- When using the Picker, the leading zero digit is removed from scanned UPCA codes. The low-level API includes the leading zero. If you wish to remove the leading zero, you can do so by enabling the
"remove_leading_zero"
extension for the UPCA symbology.
Image Coordinate System
All (relative) coordinates used in the barcode scanner SDK are defined in image coordinates of the frame in memory. The origin, coordinate (0,0), is in the upper left corner. The x-direction (width) points to the right and the y-direction (height) points downwards.
Be aware that the camera sensors of most devices capture images in landscape mode and the display on screen depends on the device orientation and does not necessarily correspond to the layout of the camera image in memory. Different screen coordinate systems and use-cases require mirroring and/or rotation to obtain the correct location areas or code directions in image space. The inverse transform has to be applied if the location of a recognized code should be displayed in screen space.