blob: 0a0486e92322deeabb6c15bee30780090f01997c [file] [log] [blame]
Michael Levit06fcf752022-01-12 11:53:46 +02001/*
2 * Copyright (c) 2022 Arm Limited. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#include "DetectionResult.hpp"
18//include "Detector.hpp"
19#include "hal.h"
20#include "YoloFastestModel.hpp"
21#include "UseCaseHandler.hpp"
22#include "UseCaseCommonUtils.hpp"
23
24#include <catch.hpp>
25
26TEST_CASE("Model info")
27{
28printf("Entering Model info \n");
29 /* Model wrapper object. */
30 arm::app::YoloFastestModel model;
31
32 /* Load the model. */
33 REQUIRE(model.Init());
34
35 /* Instantiate application context. */
36 arm::app::ApplicationContext caseContext;
37
38 caseContext.Set<arm::app::Model&>("model", model);
39
40 REQUIRE(model.ShowModelInfoHandler());
41}
42
43
44TEST_CASE("Inference by index")
45{
46printf("Entering Inference by index \n");
47 hal_platform platform;
48 data_acq_module data_acq;
49 data_psn_module data_psn;
50 platform_timer timer;
51
52 /* Initialise the HAL and platform. */
53 hal_init(&platform, &data_acq, &data_psn, &timer);
54 hal_platform_init(&platform);
55
56 /* Model wrapper object. */
57 arm::app::YoloFastestModel model;
58
59 /* Load the model. */
60 REQUIRE(model.Init());
61
62 /* Instantiate application context. */
63 arm::app::ApplicationContext caseContext;
64
65 arm::app::Profiler profiler{&platform, "object_detection"};
66 caseContext.Set<arm::app::Profiler&>("profiler", profiler);
67 caseContext.Set<hal_platform&>("platform", platform);
68 caseContext.Set<arm::app::Model&>("model", model);
69 caseContext.Set<uint32_t>("imgIndex", 0);
70
71 REQUIRE(arm::app::ObjectDetectionHandler(caseContext, 0, false));
72
73 auto results = caseContext.Get<std::vector<arm::app::DetectionResult>>("results");
74
75}
76
77
78TEST_CASE("Inference run all images")
79{
80 printf("Entering Inference run all images \n");
81 hal_platform platform;
82 data_acq_module data_acq;
83 data_psn_module data_psn;
84 platform_timer timer;
85
86 /* Initialise the HAL and platform. */
87 hal_init(&platform, &data_acq, &data_psn, &timer);
88 hal_platform_init(&platform);
89
90 /* Model wrapper object. */
91 arm::app::YoloFastestModel model;
92
93 /* Load the model. */
94 REQUIRE(model.Init());
95
96 /* Instantiate application context. */
97 arm::app::ApplicationContext caseContext;
98
99 arm::app::Profiler profiler{&platform, "object_detection"};
100 caseContext.Set<arm::app::Profiler&>("profiler", profiler);
101 caseContext.Set<hal_platform&>("platform", platform);
102 caseContext.Set<arm::app::Model&>("model", model);
103 caseContext.Set<uint32_t>("imgIndex", 0);
104
105 REQUIRE(arm::app::ObjectDetectionHandler(caseContext, 0, true));
106
107}
108
109
110TEST_CASE("List all images")
111{
112printf("Entering List all images \n");
113 hal_platform platform;
114 data_acq_module data_acq;
115 data_psn_module data_psn;
116 platform_timer timer;
117
118 /* Initialise the HAL and platform. */
119 hal_init(&platform, &data_acq, &data_psn, &timer);
120 hal_platform_init(&platform);
121
122 /* Model wrapper object. */
123 arm::app::YoloFastestModel model;
124
125 /* Load the model. */
126 REQUIRE(model.Init());
127
128 /* Instantiate application context. */
129 arm::app::ApplicationContext caseContext;
130
131 caseContext.Set<hal_platform&>("platform", platform);
132 caseContext.Set<arm::app::Model&>("model", model);
133
134 REQUIRE(arm::app::ListFilesHandler(caseContext));
135}