Barcode Xpress Mobile for iOS
 All Classes Functions Variables Properties Pages
BXRuntime Class Reference

Defines a class that handles the interactions between camera hardware, BXInterface (called by user programs), and the iOS wrapper around the native recognition library Barcode Xpress. More...

#import <BXRuntime.h>

Inheritance diagram for BXRuntime:

Instance Methods

(id) - init
 Initializes the BXRuntime. More...
 
(id) - initWithLicense:
 Initializes the BXRuntime with a license (required). More...
 
(void) - StartCaptureSession
 Acquires the video camera, registers the resolution and format of video frame we want to capture.
 
(void) - StopCaptureSession
 Halts the acquisition of new video frames, release the queue to which they are sent, and release the video hardware.
 
(void) - StartRecognition
 Initializes the video camera interface, and starts the process of gathering images from the video camera and sending them to the Barcode Xpress library for recognition.
 
(void) - StopRecognition
 Stops the process of gathering images from the video camera and sending them to the Barcode Xpress library for recognition. More...
 
(void) - PauseRecognition
 Pauses recognition by no longer sending images to the Barcode Xpress recognition library. More...
 
(void) - ResumeRecognition
 Resumes sending images to the Barcode Xpress recognition library. More...
 
(void) - SetCameraCallback::
 Sets the callback which will be executed each time an image is captured from the video camera. More...
 
(void) - SetRecognitionCallback::
 Sets the callback which will be executed each time the Barcode Xpress recognition library has found a barcode in an image, or has encountered an error. More...
 
(void) - SetProcessingCallback::
 Sets the callback which will be executed each time a thread begins to process an image captured from the video camera. More...
 
(BXiOS_Status) - RecognizeImage:result:
 Looks for a single barcode in a UIImage and decodes it. More...
 
(BXiOS_Status) - RecognizeImage:width:height:stride:result:
 Looks for a single barcode in an image and, if found, returns the decoded value. More...
 
(BXiOS_Status) - RecognizeImage:results:maxBarcodes:
 Looks for multiple barcodes in a UIImage and decodes them. More...
 
(BXiOS_Status) - RecognizeImage:width:height:stride:results:maxBarcodes:
 Looks for multiple barcodes in an image and, if found, returns the decoded values. More...
 
(const char *) - ReportVersion
 Reports the version of the recognition library. More...
 
(long) - SetBarcodeTypes:
 Sets the barcode types that can be recognized in an image. More...
 
(AVCaptureSession *) - GetCaptureSession
 Returns a reference to the video capture session. More...
 

Public Attributes

long m_numProcessedFrames
 The number of frames processed since the object was instantiated, or the most recent barcode recognition, whichever is most recent.
 

Properties

AVCaptureSession * m_videoCaptureSession
 Gets and sets the hardware manager for the camera interface.
 
long m_barcodeTypes
 Gets and sets the types of barcodes that Barcode Xpress should search for and decode.
 
assign long m_numProcessedFrames
 Gets and sets the number of frames processed since the object was instantiated, or the most recent barcode recognition, whichever is most recent.
 
id m_cameraReceiver
 Gets and sets the object that will receive messages when a video frame is captured.
 
id m_recognitionReceiver
 Gets and sets the object that will receive messages when a barcode has been found, or when the recognition method encounters an error.
 
id m_processingReceiver
 Gets and sets the object that will receive messages when a thread begins the process of searching an image for a barcode.
 
SEL m_cameraCallback
 Gets and sets the method that will be called to receive messages when a video frame has been captured.
 
SEL m_recognitionCallback
 Gets and sets the method that will be called to receive messages when a barcode has been found, or when the recognition method encounters an error.
 
SEL m_processingCallback
 Gets and sets the method that will be called to receive messages when a thread begins the process of searching an image for a barcode.
 
BOOL m_isPaused
 Gets and sets a boolean indicating the running state of the app. More...
 
BOOL m_licenseAlertIsActive
 Gets and sets a boolean indicating the licensing state of the recognition library. More...
 
BOOL m_useBlurDetection
 Gets and sets a boolean indicating if the recognition library should check if an image is blurry before searching for a barcode. More...
 
CGSize cameraResolution
 Gets and sets the camera resolution that is being used. More...
 
BOOL m_terminateBackgroundImageSource
 Gets and sets a boolean indicating whether to terminate the background method that supplies image data. More...
 

Detailed Description

Defines a class that handles the interactions between camera hardware, BXInterface (called by user programs), and the iOS wrapper around the native recognition library Barcode Xpress.

Method Documentation

- (AVCaptureSession *) GetCaptureSession

Returns a reference to the video capture session.

Returns
A reference to the video capture session, or nil if the session has not yet been initiated by calling StartRecognition.
- (id) init

Initializes the BXRuntime.

Calls initWithLicense:

Returns
An instance of this class.

Calls BXRuntime::initWithLicense() .

Returns
An instance of this class.
- (id) initWithLicense: (BXLicense*)  inLicense

Initializes the BXRuntime with a license (required).

Parameters
inLicenseA BXLicense created with information from a valid Accusoft license. The demonstration SDK does not require this information, but will only run for a short amount of time.
Returns
An instance of this class.
- (void) PauseRecognition

Pauses recognition by no longer sending images to the Barcode Xpress recognition library.

The camera interface is not released.

- (BXiOS_Status) RecognizeImage: (UIImage*)  image
result: (BXResult **)  result 

Looks for a single barcode in a UIImage and decodes it.

This is not as efficient as using the RecognizeImage method which takes in byte data as parameters, since the byte data must first be extracted from the UIImage before passing it to the Barcode Xpress recognition library. The types of barcodes that can be decoded will have been set earlier with a call to SetBarcodeTypes.

Parameters
imageThe image to search.
resultThe address of a pointer to a BXResult object. The pointer will be changed to point to an autoreleased BXResult object which contains the result of the recognition for the image if a barcode is found.
Returns
The status value returned by the Barcode Xpress library for recognition of the image. Anything other than StatusOK means the value of the result parameter will be unchanged. Anything other than StatusOK or StatusNoBarcodesFound is an error condition.
- (BXiOS_Status) RecognizeImage: (UIImage*)  image
results: (NSMutableArray *)  results
maxBarcodes: (int)  maxBarcodes 

Looks for multiple barcodes in a UIImage and decodes them.

This is not as efficient as using the RecognizeImage method which takes in byte data as parameters, since the byte data must first be extracted from the UIImage before passing it to the Barcode Xpress recognition library. The types of barcodes that can be decoded will have been set earlier with a call to SetBarcodeTypes.

Parameters
imageThe image to search.
resultsThe barcodes that are found in the image. This will always be a size of at least one, even when no barcodes are found. If no barcodes are found the return value will be something other than StatusOK and the first item in the array will give a description of the result.
maxBarcodesThe maximum number of barcodes to search for.
Returns
The status value returned by the Barcode Xpress library for recognition of the image. Anything other than StatusOK means the value of the result parameter will be unchanged. Anything other than StatusOK or StatusNoBarcodesFound is an error condition.
- (BXiOS_Status) RecognizeImage: (void*)  image
width: (size_t)  width
height: (size_t)  height
stride: (size_t)  stride
result: (BXResult **)  result 

Looks for a single barcode in an image and, if found, returns the decoded value.

The types of barcodes that can be decoded will have been set earlier with a call to SetBarcodeTypes.

Parameters
imageThe image to search, in grayscale format with 8 bits per pixel.
widthThe image width in pixels (not including any padding).
heightThe image height in pixels.
strideThe number of bytes per row in the image, including any padding.
resultThe address of a pointer to a BXResult object. The pointer will be changed to point to an autoreleased BXResult object which contains the result of the recognition for the image if a barcode is found.
Returns
The status value returned by the Barcode Xpress library for recognition of the image. Anything other than StatusOK means the value of the result parameter will be unchanged. Anything other than StatusOK or StatusNoBarcodesFound is an error condition.
- (BXiOS_Status) RecognizeImage: (void*)  image
width: (size_t)  width
height: (size_t)  height
stride: (size_t)  stride
results: (NSMutableArray*)  results
maxBarcodes: (int)  maxBarcodes 

Looks for multiple barcodes in an image and, if found, returns the decoded values.

The types of barcodes that can be decoded will have been set earlier with a call to SetBarcodeTypes.

Parameters
imageThe image to search, in grayscale format with 8 bits per pixel.
widthThe image width in pixels (not including any padding).
heightThe image height in pixels.
bppThe pixel depth, in bits per pixel.
strideThe number of bytes per row in the image, including any padding.
resultsThe barcodes that are found in the image. This will always be a size of at least one, even when no barcodes are found. If no barcodes are found the return value will be something other than StatusOK and the first item in the array will give a description of the result.
maxBarcodesThe maximum number of barcodes to search for.
Returns
The status value returned by the Barcode Xpress library for recognition of the image. Anything other than StatusOK means the value of the result parameter will be unchanged. Anything other than StatusOK or StatusNoBarcodesFound is an error condition.
- (const char *) ReportVersion

Reports the version of the recognition library.

Returns
Pointer to a character string with the version in it, similar to "1.2.3"
- (void) ResumeRecognition

Resumes sending images to the Barcode Xpress recognition library.

See - PauseRecognition.

- (long) SetBarcodeTypes: (long)  types

Sets the barcode types that can be recognized in an image.

Parameters
typesThe set of types constructed via bitwise OR from constants defined in BarcodeConstants.h
Returns
Zero unless the set contains invalid/unlicensed barcode types, in which case the set of disallowed types is returned.
- (void) (id)  receiver
: (SEL)  callback 

Sets the callback which will be executed each time an image is captured from the video camera.

The callback method returns void and takes a single parameter, which is the ID of a BXThreadData object. The BXThreadData object contains raw YUV420p (planar YUV) data copied from the video pixel buffer, as well as information about the image, such as width and height.

Parameters
receiverID of the object with the callback method to be invoked.
callbackSelector of the callback method.
- (void) (id)  receiver
: (SEL)  callback 

Sets the callback which will be executed each time a thread begins to process an image captured from the video camera.

The callback method returns void and takes a single parameter, which is the ID of a BXThreadData object. The BXThreadData object contains raw YUV420p (planar YUV) data copied from the video pixel buffer, as well as information about the image, such as width and height.

Parameters
receiverID of the object with the callback method to be invoked.
callbackSelector of the callback method.
- (void) (id)  receiver
: (SEL)  callback 

Sets the callback which will be executed each time the Barcode Xpress recognition library has found a barcode in an image, or has encountered an error.

The callback is not executed when no errors are encountered AND no barcodes were found in the image.

The callback method returns void and takes a single parameter, which is the ID of an NSDictionary object. The NSDictionary will contain two keys, "image" and "result". "image" is a UIImage*, and "result" is a BXResult*.

Parameters
receiverID of the object with the callback method to be invoked.
callbackSelector of the callback method.
- (void) StopRecognition

Stops the process of gathering images from the video camera and sending them to the Barcode Xpress library for recognition.

Releases the video camera interface.

Property Documentation

- (CGSize) cameraResolution
readwritenonatomicassign

Gets and sets the camera resolution that is being used.

This may differ from the actual camera max or min resolution.

- (BOOL) m_isPaused
readwritenonatomicassign

Gets and sets a boolean indicating the running state of the app.

Set TRUE when recognition should be paused. In that state, video frames are captured, but immediately released before sending them to the threads that would use Barcode Xpress to decode them.

- (BOOL) m_licenseAlertIsActive
readwritenonatomicassign

Gets and sets a boolean indicating the licensing state of the recognition library.

Set YES when an alert has been set because recognition was attempted with an invalid license.

- (BOOL) m_terminateBackgroundImageSource
readwritenonatomicassign

Gets and sets a boolean indicating whether to terminate the background method that supplies image data.

Set TRUE if the thread generated video frames from an alternate source (not the video camera) should terminate. The background thread is started only if code is uncommented in StartRecognition, and is intended for use while in the simulator (which doesn't have a camera to supply imagery).

- (BOOL) m_useBlurDetection
readwritenonatomicassign

Gets and sets a boolean indicating if the recognition library should check if an image is blurry before searching for a barcode.

Set TRUE when the iOS wrapper for Barcode Xpress should detect and filter out blurred images before sending to Barcode Xpress for recognition.