gr_recognition_async_process
Syntax:
gr_recognition_async_process(result, [time_to_spend ]);
Argument name | Type | Description |
---|---|---|
result |
Result |
The recognition result object to process |
time_to_spend |
real |
The minimum number of milliseconds to spend in the async recognition process |
Returns: (boolean
) True if the recognition has ended. If you pass undefined or an invalid "result"
Description:
Process the recognition object asynchronous.
If the recognition is in progress, the funtion returns false. When the recognition is ready, the function returns true.
Then, you can use gr_recognition_get_name
and gr_recognition_get_accuracy
functions to get the results of the recognition.
The second argument, specifies how many milliseconds should be spent computing the result. If you don't pass this argument, it is
automatically calculated based on the room_speed
.
Example:
/// Global mouse up event
/// Pass true to activate the async mode
recognition = gr_record_recognize(record, true);
/// Step event
if (gr_recogtition_async_is_ready(recognition)) {
var ready = gr_recognition_async_process(recognition);
if (ready) {
var name = gr_recognition_get_name(recognition, 0);
recognition = undefined; // reset the result
show_message("You have drawn a " + name );
}
}
/// Draw event
var ready = gr_recognition_async_is_ready(recognition);
var total = gr_recognition_async_total(recognition);
var number = gr_recognition_async_total(number);
var progress = floor(number / total * 100);
draw_text(x, y, "Recognition is " + (ready ? "ready" : "in progress"));
draw_text(x, y, "Progress: " + string(progress) + "%");