blob: a7e4f332e951d2d9bd34611345b5b2c7a3aa520f [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 /* Initialise the HAL and platform. */
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010046 hal_platform_init();
Michael Levit06fcf752022-01-12 11:53:46 +020047
48 /* Model wrapper object. */
49 arm::app::YoloFastestModel model;
50
51 /* Load the model. */
52 REQUIRE(model.Init());
53
54 /* Instantiate application context. */
55 arm::app::ApplicationContext caseContext;
56
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010057 arm::app::Profiler profiler{"object_detection"};
Michael Levit06fcf752022-01-12 11:53:46 +020058 caseContext.Set<arm::app::Profiler&>("profiler", profiler);
Michael Levit06fcf752022-01-12 11:53:46 +020059 caseContext.Set<arm::app::Model&>("model", model);
60 caseContext.Set<uint32_t>("imgIndex", 0);
Isabella Gottardi3107aa22022-01-27 16:39:37 +000061 arm::app::object_detection::DetectorPostprocessing postp;
62 caseContext.Set<arm::app::object_detection::DetectorPostprocessing&>("postprocess", postp);
Michael Levit06fcf752022-01-12 11:53:46 +020063
64 REQUIRE(arm::app::ObjectDetectionHandler(caseContext, 0, false));
Michael Levit06fcf752022-01-12 11:53:46 +020065}
66
67
68TEST_CASE("Inference run all images")
69{
Michael Levit06fcf752022-01-12 11:53:46 +020070 /* Initialise the HAL and platform. */
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010071 hal_platform_init();
Michael Levit06fcf752022-01-12 11:53:46 +020072
73 /* Model wrapper object. */
74 arm::app::YoloFastestModel model;
75
76 /* Load the model. */
77 REQUIRE(model.Init());
78
79 /* Instantiate application context. */
80 arm::app::ApplicationContext caseContext;
81
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010082 arm::app::Profiler profiler{"object_detection"};
Michael Levit06fcf752022-01-12 11:53:46 +020083 caseContext.Set<arm::app::Profiler&>("profiler", profiler);
Michael Levit06fcf752022-01-12 11:53:46 +020084 caseContext.Set<arm::app::Model&>("model", model);
85 caseContext.Set<uint32_t>("imgIndex", 0);
Isabella Gottardi3107aa22022-01-27 16:39:37 +000086 arm::app::object_detection::DetectorPostprocessing postp;
87 caseContext.Set<arm::app::object_detection::DetectorPostprocessing&>("postprocess", postp);
Michael Levit06fcf752022-01-12 11:53:46 +020088
89 REQUIRE(arm::app::ObjectDetectionHandler(caseContext, 0, true));
Michael Levit06fcf752022-01-12 11:53:46 +020090}
91
92
93TEST_CASE("List all images")
94{
Michael Levit06fcf752022-01-12 11:53:46 +020095 /* Initialise the HAL and platform. */
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010096 hal_platform_init();
Michael Levit06fcf752022-01-12 11:53:46 +020097
98 /* Model wrapper object. */
99 arm::app::YoloFastestModel model;
100
101 /* Load the model. */
102 REQUIRE(model.Init());
103
104 /* Instantiate application context. */
105 arm::app::ApplicationContext caseContext;
Michael Levit06fcf752022-01-12 11:53:46 +0200106 caseContext.Set<arm::app::Model&>("model", model);
107
108 REQUIRE(arm::app::ListFilesHandler(caseContext));
109}