blob: 2e63f3642bf17f00d3adb72fc7cdf1ffb61d2be3 [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"
Isabella Gottardi3107aa22022-01-27 16:39:37 +000018#include "DetectorPostProcessing.hpp"
Michael Levit06fcf752022-01-12 11:53:46 +020019#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{
Michael Levit06fcf752022-01-12 11:53:46 +020028 /* Model wrapper object. */
29 arm::app::YoloFastestModel model;
30
31 /* Load the model. */
32 REQUIRE(model.Init());
33
34 /* Instantiate application context. */
35 arm::app::ApplicationContext caseContext;
36
37 caseContext.Set<arm::app::Model&>("model", model);
38
39 REQUIRE(model.ShowModelInfoHandler());
40}
41
42
43TEST_CASE("Inference by index")
44{
Michael Levit06fcf752022-01-12 11:53:46 +020045 hal_platform platform;
46 data_acq_module data_acq;
47 data_psn_module data_psn;
48 platform_timer timer;
49
50 /* Initialise the HAL and platform. */
51 hal_init(&platform, &data_acq, &data_psn, &timer);
52 hal_platform_init(&platform);
53
54 /* Model wrapper object. */
55 arm::app::YoloFastestModel model;
56
57 /* Load the model. */
58 REQUIRE(model.Init());
59
60 /* Instantiate application context. */
61 arm::app::ApplicationContext caseContext;
62
63 arm::app::Profiler profiler{&platform, "object_detection"};
64 caseContext.Set<arm::app::Profiler&>("profiler", profiler);
65 caseContext.Set<hal_platform&>("platform", platform);
66 caseContext.Set<arm::app::Model&>("model", model);
67 caseContext.Set<uint32_t>("imgIndex", 0);
Isabella Gottardi3107aa22022-01-27 16:39:37 +000068 arm::app::object_detection::DetectorPostprocessing postp;
69 caseContext.Set<arm::app::object_detection::DetectorPostprocessing&>("postprocess", postp);
Michael Levit06fcf752022-01-12 11:53:46 +020070
71 REQUIRE(arm::app::ObjectDetectionHandler(caseContext, 0, false));
Michael Levit06fcf752022-01-12 11:53:46 +020072}
73
74
75TEST_CASE("Inference run all images")
76{
Michael Levit06fcf752022-01-12 11:53:46 +020077 hal_platform platform;
78 data_acq_module data_acq;
79 data_psn_module data_psn;
80 platform_timer timer;
81
82 /* Initialise the HAL and platform. */
83 hal_init(&platform, &data_acq, &data_psn, &timer);
84 hal_platform_init(&platform);
85
86 /* Model wrapper object. */
87 arm::app::YoloFastestModel model;
88
89 /* Load the model. */
90 REQUIRE(model.Init());
91
92 /* Instantiate application context. */
93 arm::app::ApplicationContext caseContext;
94
95 arm::app::Profiler profiler{&platform, "object_detection"};
96 caseContext.Set<arm::app::Profiler&>("profiler", profiler);
97 caseContext.Set<hal_platform&>("platform", platform);
98 caseContext.Set<arm::app::Model&>("model", model);
99 caseContext.Set<uint32_t>("imgIndex", 0);
Isabella Gottardi3107aa22022-01-27 16:39:37 +0000100 arm::app::object_detection::DetectorPostprocessing postp;
101 caseContext.Set<arm::app::object_detection::DetectorPostprocessing&>("postprocess", postp);
Michael Levit06fcf752022-01-12 11:53:46 +0200102
103 REQUIRE(arm::app::ObjectDetectionHandler(caseContext, 0, true));
Michael Levit06fcf752022-01-12 11:53:46 +0200104}
105
106
107TEST_CASE("List all images")
108{
Michael Levit06fcf752022-01-12 11:53:46 +0200109 hal_platform platform;
110 data_acq_module data_acq;
111 data_psn_module data_psn;
112 platform_timer timer;
113
114 /* Initialise the HAL and platform. */
115 hal_init(&platform, &data_acq, &data_psn, &timer);
116 hal_platform_init(&platform);
117
118 /* Model wrapper object. */
119 arm::app::YoloFastestModel model;
120
121 /* Load the model. */
122 REQUIRE(model.Init());
123
124 /* Instantiate application context. */
125 arm::app::ApplicationContext caseContext;
126
127 caseContext.Set<hal_platform&>("platform", platform);
128 caseContext.Set<arm::app::Model&>("model", model);
129
130 REQUIRE(arm::app::ListFilesHandler(caseContext));
131}