SDK API - Photo Feature
PLEASE NOTE: THE USAGE OF THIS FEATURE IS RESTRICTED AND ONLY AVAILABLE AS BETA THROUGH OUR EARLY ACCESS PROGRAM. PLEASE FILL OUT THE REGISTRATION FORM TO APPLY.
Take an image with MARK2 to increase your process quality.
Take Image commands, like all commands that trigger an action on MARK, will by default be queued in ProGlove Connect.
By providing a special flag in PgCommandParams
, this behaviour can be changed to replace the queue with this new command.
For more Information about the queueing behaviour click here
Taking Images with MARK
You want to be able to initiate image taking mode and receive images taken with the connected device, to do this call pgManager.takeImage(...)
, after you have initialized the pgManager.
You should provide a configuration for the image mode which is done through the PgImageConfig
class, wrapped in a PgCommand
and a
callback that handles the response. For this callback implement the IPgImageCallback
interface (code in Kotlin).
The PgImageConfig
contains one parameter called timeoutMs. This value represents the amount of milliseconds your worker will have time to take the image, once the image mode is started. Your callback, informing you about a possible timout error, might be delayed to account for processing and transmission time.
The convenience function PgImageConfig.toComamnd()
used here to wrap the PgImageConfig
optionally takes a PgCommandParams
object,
which gives additional control over how the command should be executed. For now we only support the replaceQueue
flag here,
which if set to true cancels all the commands currently in the queue and adds itself as the first element. More information can be found here
takeImageButton.setOnClickListener {
val config = PgImageConfig()
val imageCallback = object : IPgImageCallback {
override fun onImageReceived(image: PgImage) {
//sample implementation for showing the picture in an imageView
val bmp = BitmapFactory.decodeByteArray(image.bytes, 0, image.bytes.size)
//make sure you execute any UI related code on the UI Thread
runOnUiThread {
imageTaken.setImageBitmap(bmp)
}
}
override fun onImageError(errorReason: PgError) {
//implement your logic depending on the error reason returned
// make sure you execute any UI related code on the UI Thread
runOnUiThread {
// handle error code here
}
}
}
pgManager.takeImage(config.toCommand(), imageCallback)
}