blob: 023b893cf1c08770f9f4719126b43192e17fe768 [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);
61
62 REQUIRE(arm::app::ObjectDetectionHandler(caseContext, 0, false));
Michael Levit06fcf752022-01-12 11:53:46 +020063}
64
65
66TEST_CASE("Inference run all images")
67{
Michael Levit06fcf752022-01-12 11:53:46 +020068 /* Initialise the HAL and platform. */
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010069 hal_platform_init();
Michael Levit06fcf752022-01-12 11:53:46 +020070
71 /* Model wrapper object. */
72 arm::app::YoloFastestModel model;
73
74 /* Load the model. */
75 REQUIRE(model.Init());
76
77 /* Instantiate application context. */
78 arm::app::ApplicationContext caseContext;
79
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010080 arm::app::Profiler profiler{"object_detection"};
Michael Levit06fcf752022-01-12 11:53:46 +020081 caseContext.Set<arm::app::Profiler&>("profiler", profiler);
Michael Levit06fcf752022-01-12 11:53:46 +020082 caseContext.Set<arm::app::Model&>("model", model);
83 caseContext.Set<uint32_t>("imgIndex", 0);
84
85 REQUIRE(arm::app::ObjectDetectionHandler(caseContext, 0, true));
Michael Levit06fcf752022-01-12 11:53:46 +020086}
87
88
89TEST_CASE("List all images")
90{
Michael Levit06fcf752022-01-12 11:53:46 +020091 /* Initialise the HAL and platform. */
Kshitij Sisodia4cc40212022-04-08 09:54:53 +010092 hal_platform_init();
Michael Levit06fcf752022-01-12 11:53:46 +020093
94 /* Model wrapper object. */
95 arm::app::YoloFastestModel model;
96
97 /* Load the model. */
98 REQUIRE(model.Init());
99
100 /* Instantiate application context. */
101 arm::app::ApplicationContext caseContext;
Michael Levit06fcf752022-01-12 11:53:46 +0200102 caseContext.Set<arm::app::Model&>("model", model);
103
104 REQUIRE(arm::app::ListFilesHandler(caseContext));
105}