-
Notifications
You must be signed in to change notification settings - Fork 437
/
filter.c
53 lines (43 loc) · 1.07 KB
/
filter.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <string.h>
#include "filter_model.h"
__attribute__((always_inline))
static inline struct tensors *
tensors_create_helper (char const *const caller)
{
int e = 0;
struct tensors *t = tensors_create(&e);
if (!t) {
if (e)
fprintf(stderr, "%s: tensors_create(): %s\n", caller, strerror(e));
else
fprintf(stderr, "%s: tensors_create() failed\n", caller);
}
return t;
}
LIB_EXPORT void
filter_Inference (ModelInput const *image,
ModelOut *result)
{
struct tensors *ts = tensors_create_helper(__func__);
if (ts) {
model_infer(ts, image, result);
tensors_destroy(&ts);
}
}
LIB_EXPORT void
filter_VideoInference (ModelInput const *frames,
int num_frames,
ModelOut *results,
int *progress)
{
struct tensors *ts = tensors_create_helper(__func__);
if (ts) {
for (int i = 0; i < num_frames; i++) {
model_infer(ts, &frames[i], &results[i]);
if (progress)
(*progress)++;
}
tensors_destroy(&ts);
}
}