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 <glib.h>
#include "software-roi.h"
static const guchar test_frame[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8,
0, 1, 2, 3, 4, 5, 6, 7, 8,
0, 1, 2, 3, 4, 5, 6, 7, 8,
0, 1, 2, 3, 4, 5, 6, 7, 8,
0, 1, 2, 3, 4, 5, 6, 7, 8,
};
static const guint test_frame_width = 9;
static guchar test_roi_2x1_5x3[] = {
2, 3, 4, 5, 6,
2, 3, 4, 5, 6,
2, 3, 4, 5, 6,
};
void typical_roi_test(void)
{
guint roiX = 2;
guint roiY = 1;
guint roiWidth = 5;
guint roiHeight = 3;
guint roiSize = roiWidth * roiHeight;
guchar roiFrame[roiSize];
apply_software_roi(test_frame, test_frame_width, roiFrame, roiX, roiY, roiWidth, roiHeight);
for (guint i = 0; i < roiSize; i++) {
g_assert_cmpint(test_roi_2x1_5x3[i], ==, roiFrame[i]);
}
}
void nrows_only_roi_test(void)
{
guint roiX = 0;
guint roiY = 0;
guint roiWidth = test_frame_width;
guint roiHeight = 3;
guint roiSize = roiWidth * roiHeight;
guchar roiFrame[roiSize];
apply_software_roi(test_frame, test_frame_width, roiFrame, roiX, roiY, roiWidth, roiHeight);
for (guint i = 0; i < roiSize; i++) {
g_assert_cmpint(test_frame[i], ==, roiFrame[i]);
}
}
int main(int argc, char** argv)
{
g_test_init(&argc, &argv, NULL);
g_test_add_func("/software-roi/apply-typical-roi", typical_roi_test);
g_test_add_func("/software-roi/apply-roi-nrows-only", nrows_only_roi_test);
return g_test_run();
}
|