Implementation
List<SearchResult> singleSearch(Template template, TemplateIndex templatesIndex, int k,
{SearchAccelerationType acceleration = SearchAccelerationType.SEARCH_ACCELERATION_1}) {
final _search = _dll_handle.lookupFunction<_Recognizer_search_v2_c, _Recognizer_search_v2_dart>(_c_namespace + 'Recognizer_search_v2');
final exception = _getException();
Pointer<Pointer<Void>> templatesImpl = malloc.allocate(sizeOf<Pointer<Pointer<Void>>>());
templatesImpl[0] = template._impl;
Pointer<Int64> result_i = malloc.allocate(k * sizeOf<Int64>());
Pointer<Float> result_distance = malloc.allocate(k * sizeOf<Float>());
Pointer<Float> result_far = malloc.allocate(k * sizeOf<Float>());
Pointer<Float> result_frr = malloc.allocate(k * sizeOf<Float>());
Pointer<Float> result_score = malloc.allocate(k * sizeOf<Float>());
_search(_impl, acceleration.index, 1, templatesImpl, templatesIndex._impl, k, result_i, result_distance, result_far, result_frr, result_score, exception);
checkException(exception, _dll_handle);
List<SearchResult> result = [];
for (var i = 0; i < k; i++) {
result.add(SearchResult(result_i[i], MatchResult(result_distance[i], result_far[i], result_frr[i], result_score[i])));
}
malloc.free(result_distance);
malloc.free(result_far);
malloc.free(result_frr);
malloc.free(result_score);
malloc.free(templatesImpl);
return result;
}