BlinkID C SDK version 5.16.0
Public Member Functions
MBRecognizerImage Struct Reference

MBRecognizerImage data structure. Holds image on which recognition will bw performed. More...

#include <RecognizerImage.h>

Public Member Functions

MB_API MBRecognizerErrorStatus MB_CALL recognizerImageCreateFromRawImage (MBRecognizerImage **image, MBByte const *input, uint16_t width, uint16_t height, uint16_t bytesPerRow, MBRawImageType rawType)
 Allocates and creates MBRecognizerImage object from raw image. NOTE: This function will not make copy of the given buffer, so make sure that buffer stays alive and unchanged while this MBRecognizerImage is in use. More...
 
MB_API MBRecognizerErrorStatus MB_CALL recognizerImageLoadFromFile (MBRecognizerImage **image, char const *path)
 Allocates and creates MBRecognizerImage object from given file. NOTE: Only JPG and PNG file types are supported. All other file types will fail to load. If you need to load a different file type, please load it manually and then create MBRecognizerImage using recognizerImageCreateFromRawImage. More...
 
MB_API MBRecognizerErrorStatus MB_CALL recognizerImageSetNewRawBuffer (MBRecognizerImage *image, MBByte const *input, uint16_t width, uint16_t height, uint16_t bytesPerRow, MBRawImageType rawType)
 Sets a new buffer to the given MBRecognizerImage. NOTE: This function will not make copy of the given buffer, so make sure that buffer stays alive and unchanged while this MBRecognizerImage is in use. More...
 
MB_API MBRecognizerErrorStatus MB_CALL recognizerImageCreateCopyFromImage (MBRecognizerImage **image, MBRecognizerImage const *original)
 Allocates and creates MBRecognizerImage by copying another MBRecognizerImage. This method will copy pixel data, so it may be slow. More...
 
MB_API MBRecognizerErrorStatus MB_CALL recognizerImageDelete (MBRecognizerImage **image)
 Deletes the image object and sets pointer to NULL. More...
 
MB_API MBRecognizerErrorStatus MB_CALL recognizerImageSetImageOrientation (MBRecognizerImage *image, MBImageOrientation orientation)
 Sets the orientation of the image. When created, each image has default orientation IMAGE_ORIENTATION_LANDSCAPE_RIGHT, which corresponds to 'natural' orientation of all images. However, if image was taken in different orientation, you should set correct orientation with this method to ensure best recognition quality. More...
 
MB_API MBImageOrientation MB_CALL recognizerImageGetImageOrientation (MBRecognizerImage const *image)
 Gets the orientation of the image. More...
 
MB_API MBByte const *MB_CALL recognizerImageGetRawBytes (MBRecognizerImage const *image)
 Gets buffer containing raw image bytes. More...
 
MB_API MBByte *MB_CALL recognizerImageGetMutableRawBytes (MBRecognizerImage *image)
 Gets modifiable buffer containing raw image bytes. More...
 
MB_API uint16_t MB_CALL recognizerImageGetWidth (MBRecognizerImage const *image)
 Gets width of image in number of pixels. More...
 
MB_API uint16_t MB_CALL recognizerImageGetHeight (MBRecognizerImage const *image)
 Gets height of image in number of pixels. More...
 
MB_API uint16_t MB_CALL recognizerImageGetBytesPerRow (MBRecognizerImage const *image)
 Gets bytes per row for given image. More...
 
MB_API MBRawImageType MB_CALL recognizerImageGetRawImageType (MBRecognizerImage const *image)
 Gets raw image type for given image. More...
 

Detailed Description

MBRecognizerImage data structure. Holds image on which recognition will bw performed.

Member Function Documentation

◆ recognizerImageCreateCopyFromImage()

MB_API MBRecognizerErrorStatus MB_CALL recognizerImageCreateCopyFromImage ( MBRecognizerImage **  image,
MBRecognizerImage const *  original 
)

Allocates and creates MBRecognizerImage by copying another MBRecognizerImage. This method will copy pixel data, so it may be slow.

Parameters
imagePointer to pointer referencing the created MBRecognizerImage object, set to NULL if error occured.
originalPointer to original MBRecognizerImage object that should be copied.
Returns
errorStatus Status of the operation.

◆ recognizerImageCreateFromRawImage()

MB_API MBRecognizerErrorStatus MB_CALL recognizerImageCreateFromRawImage ( MBRecognizerImage **  image,
MBByte const *  input,
uint16_t  width,
uint16_t  height,
uint16_t  bytesPerRow,
MBRawImageType  rawType 
)

Allocates and creates MBRecognizerImage object from raw image. NOTE: This function will not make copy of the given buffer, so make sure that buffer stays alive and unchanged while this MBRecognizerImage is in use.

Example:

int image_width, image_height, image_stride;
void* image_buffer;
// populate above variables (i.e. by loading image file or capturing image with camera)
MBRecognizerErrorStatus status = recognizerImageCreateFromRawImage(&img, image_buffer, image_width, image_height, image_stride, MB_RAW_IMAGE_TYPE_BGRA);
// make sure last parameter correctly describes image format, otherwise a crash will occur later while processing the image. There is no way to
// detect whether this parameter was given correctly while creating the image, so function may return MB_RECOGNIZER_ERROR_STATUS_SUCCESS even if
// this parameter is wrong.
const char* status_string = recognizerErrorToString(status);
printf("CreateFromRawImage method returned status: %s\n", status_string);
// handle error
} else {
// use MBRecognizerImage object
}
MBRecognizerErrorStatus
Enumeration of all possible error statuses.
Definition: RecognizerError.h:28
@ MB_RECOGNIZER_ERROR_STATUS_SUCCESS
Definition: RecognizerError.h:30
MB_API char const *MB_CALL recognizerErrorToString(MBRecognizerErrorStatus errorStatus)
@ MB_RAW_IMAGE_TYPE_BGRA
Definition: RecognizerImage.h:47
MBRecognizerImage data structure. Holds image on which recognition will bw performed.
MB_API MBRecognizerErrorStatus MB_CALL recognizerImageCreateFromRawImage(MBRecognizerImage **image, MBByte const *input, uint16_t width, uint16_t height, uint16_t bytesPerRow, MBRawImageType rawType)
Allocates and creates MBRecognizerImage object from raw image. NOTE: This function will not make copy...
MB_API MBRecognizerErrorStatus MB_CALL recognizerImageDelete(MBRecognizerImage **image)
Deletes the image object and sets pointer to NULL.

Raw image type is the type without any encoding. List of supported raw image types is given in enum MBRawImageType.

See also
MBRawImageType
Parameters
imagePointer to pointer referencing the created MBRecognizerImage object, set to NULL if error occured.
inputPointer to a buffer with raw image pixels.
widthWidth of the image, in pixels
heightHeight of the image, in pixels
bytesPerRowNumber of bytes contained in every row of the image
rawTypeType of the image.
See also
MBRawImageType
Returns
errorStatus Status of the operation.

◆ recognizerImageDelete()

MB_API MBRecognizerErrorStatus MB_CALL recognizerImageDelete ( MBRecognizerImage **  image)

Deletes the image object and sets pointer to NULL.

Parameters
imageDouble pointer to image object which is to be deleted.
Returns
errorStatus Status of the operation.

◆ recognizerImageGetBytesPerRow()

MB_API uint16_t MB_CALL recognizerImageGetBytesPerRow ( MBRecognizerImage const *  image)

Gets bytes per row for given image.

Parameters
imagePointer to MBRecognizerImage object of interest.
Returns
bytes per row in image

◆ recognizerImageGetHeight()

MB_API uint16_t MB_CALL recognizerImageGetHeight ( MBRecognizerImage const *  image)

Gets height of image in number of pixels.

Parameters
imagePointer to MBRecognizerImage object of interest.
Returns
height of image in pixels

◆ recognizerImageGetImageOrientation()

MB_API MBImageOrientation MB_CALL recognizerImageGetImageOrientation ( MBRecognizerImage const *  image)

Gets the orientation of the image.

Parameters
imageImage from which orientation will be obtained.
Returns
Orientation of the image.

◆ recognizerImageGetMutableRawBytes()

MB_API MBByte *MB_CALL recognizerImageGetMutableRawBytes ( MBRecognizerImage image)

Gets modifiable buffer containing raw image bytes.

Parameters
imagePointer to MBRecognizerImage object of interest.
Returns
data Modifiable buffer containing raw image bytes. You can use the obtained buffer until recognizerImageDelete is called on the MBRecognizerImage object. If you want to use the buffer later, you must copy it.

◆ recognizerImageGetRawBytes()

MB_API MBByte const *MB_CALL recognizerImageGetRawBytes ( MBRecognizerImage const *  image)

Gets buffer containing raw image bytes.

Parameters
imagePointer to MBRecognizerImage object of interest.
Returns
data Buffer containing raw image bytes. You can use the obtained buffer until recognizerImageDelete is called on the MBRecognizerImage object. If you want to use the buffer later, you must copy it.

◆ recognizerImageGetRawImageType()

MB_API MBRawImageType MB_CALL recognizerImageGetRawImageType ( MBRecognizerImage const *  image)

Gets raw image type for given image.

Parameters
imagePointer to MBRecognizerImage object of interest.
Returns
raw image type of image

◆ recognizerImageGetWidth()

MB_API uint16_t MB_CALL recognizerImageGetWidth ( MBRecognizerImage const *  image)

Gets width of image in number of pixels.

Parameters
imagePointer to MBRecognizerImage object of interest.
Returns
width of image in pixels

◆ recognizerImageLoadFromFile()

MB_API MBRecognizerErrorStatus MB_CALL recognizerImageLoadFromFile ( MBRecognizerImage **  image,
char const *  path 
)

Allocates and creates MBRecognizerImage object from given file. NOTE: Only JPG and PNG file types are supported. All other file types will fail to load. If you need to load a different file type, please load it manually and then create MBRecognizerImage using recognizerImageCreateFromRawImage.

Example:

MBRecognizerErrorStatus status = recognizerImageLoadFromFile(&img, "path/to/image.jpg");
const char* status_string = recognizerErrorToString(status);
printf("LoadFromFile method returned status: %s\n", status_string);
// handle error
} else {
// use MBRecognizerImage object
}
MB_API MBRecognizerErrorStatus MB_CALL recognizerImageLoadFromFile(MBRecognizerImage **image, char const *path)
Allocates and creates MBRecognizerImage object from given file. NOTE: Only JPG and PNG file types are...

Image metadata, such as orientation, will not be read from the image. Instead, the loaded image will always have the default orientation MB_IMAGE_ORIENTATION_NO_ROTATION.

Parameters
imagePointer to pointer referencing the created MBRecognizerImage object, set to NULL if error occured.
pathPath to file to be loaded.
Returns
errorStatus Status of the operation.

◆ recognizerImageSetImageOrientation()

MB_API MBRecognizerErrorStatus MB_CALL recognizerImageSetImageOrientation ( MBRecognizerImage image,
MBImageOrientation  orientation 
)

Sets the orientation of the image. When created, each image has default orientation IMAGE_ORIENTATION_LANDSCAPE_RIGHT, which corresponds to 'natural' orientation of all images. However, if image was taken in different orientation, you should set correct orientation with this method to ensure best recognition quality.

Parameters
imageImage to which orientation will be set.
orientationOrientation that will be set.
Returns
errorStatus Status of the operation.

◆ recognizerImageSetNewRawBuffer()

MB_API MBRecognizerErrorStatus MB_CALL recognizerImageSetNewRawBuffer ( MBRecognizerImage image,
MBByte const *  input,
uint16_t  width,
uint16_t  height,
uint16_t  bytesPerRow,
MBRawImageType  rawType 
)

Sets a new buffer to the given MBRecognizerImage. NOTE: This function will not make copy of the given buffer, so make sure that buffer stays alive and unchanged while this MBRecognizerImage is in use.

Example:

int image_width, image_height, image_stride;
void* image_buffer;
// populate above variables (i.e. by loading image file or capturing image with camera)
// create image with recognizerImageCreateFromRawImage
// now, update the image with new buffer
MBRecognizerErrorStatus status = recognizerImageSetNewRawBuffer(img, image_buffer, image_width, image_height, image_stride, MB_RAW_IMAGE_TYPE_BGRA);
// make sure last parameter correctly describes image format, otherwise a crash will occur later while processing the image. There is no way to
// detect whether this parameter was given correctly while creating the image, so function may return MB_RECOGNIZER_ERROR_STATUS_SUCCESS even if
// this parameter is wrong.
const char* status_string = recognizerErrorToString(status);
printf("CreateFromRawImage method returned status: %s\n", status_string);
// handle error
} else {
// use MBRecognizerImage object
}
MB_API MBRecognizerErrorStatus MB_CALL recognizerImageSetNewRawBuffer(MBRecognizerImage *image, MBByte const *input, uint16_t width, uint16_t height, uint16_t bytesPerRow, MBRawImageType rawType)
Sets a new buffer to the given MBRecognizerImage. NOTE: This function will not make copy of the given...

Raw image type is the type without any encoding. List of supported raw image types is given in enum MBRawImageType.

See also
MBRawImageType
Parameters
imagePointer referencing the created MBRecognizerImage object, must be non-NULL.
inputPointer to a buffer with raw image pixels.
widthWidth of the image, in pixels
heightHeight of the image, in pixels
bytesPerRowNumber of bytes contained in every row of the image
rawTypeType of the image.
See also
MBRawImageType
Returns
errorStatus Status of the operation.

The documentation for this struct was generated from the following file: