summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2022-04-06 13:03:20 +0100
committerKshitij Sisodia <kshitij.sisodia@arm.com>2022-04-06 16:03:23 +0100
commit68fdd119f38c37ab28066474086b0e352d991baf (patch)
treecedb897ff9128f7d07e54c5c53ff8eb6be6b2bb1 /source
parentda2ec067da418d3d80b2829b111df25bd901eb5c (diff)
downloadml-embedded-evaluation-kit-68fdd119f38c37ab28066474086b0e352d991baf.tar.gz
MLECO-3096: Removing data_acq and data_psn
Further to the HAL refactoring done in previous commits, this CR simpifies HAL by removing data_acq and data_psn "modules". The associated function pointers have been removed. Change-Id: I04c194c08dfe0aff98ce4e0f0f056bac254c137d Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
Diffstat (limited to 'source')
-rw-r--r--source/application/main/Main.cc4
-rw-r--r--source/application/main/UseCaseCommonUtils.cc24
-rw-r--r--source/application/main/include/UseCaseCommonUtils.hpp7
-rw-r--r--source/hal/CMakeLists.txt2
-rw-r--r--source/hal/include/data_acq.h52
-rw-r--r--source/hal/include/data_psn.h72
-rw-r--r--source/hal/include/hal.h29
-rw-r--r--source/hal/include/hal_lcd.h49
-rw-r--r--source/hal/source/data_acq.c61
-rw-r--r--source/hal/source/data_psn.c46
-rw-r--r--source/hal/source/hal.c44
-rw-r--r--source/use_case/ad/src/MainLoop.cc4
-rw-r--r--source/use_case/ad/src/UseCaseHandler.cc18
-rw-r--r--source/use_case/asr/src/MainLoop.cc4
-rw-r--r--source/use_case/asr/src/UseCaseHandler.cc23
-rw-r--r--source/use_case/img_class/src/MainLoop.cc4
-rw-r--r--source/use_case/img_class/src/UseCaseHandler.cc11
-rw-r--r--source/use_case/inference_runner/src/UseCaseHandler.cc8
-rw-r--r--source/use_case/kws/src/MainLoop.cc4
-rw-r--r--source/use_case/kws/src/UseCaseHandler.cc124
-rw-r--r--source/use_case/kws_asr/src/MainLoop.cc4
-rw-r--r--source/use_case/kws_asr/src/UseCaseHandler.cc37
-rw-r--r--source/use_case/noise_reduction/src/MainLoop.cc4
-rw-r--r--source/use_case/noise_reduction/src/UseCaseHandler.cc12
-rw-r--r--source/use_case/object_detection/src/MainLoop.cc4
-rw-r--r--source/use_case/object_detection/src/UseCaseHandler.cc45
-rw-r--r--source/use_case/vww/src/MainLoop.cc4
-rw-r--r--source/use_case/vww/src/UseCaseHandler.cc11
28 files changed, 236 insertions, 475 deletions
diff --git a/source/application/main/Main.cc b/source/application/main/Main.cc
index 8ed9c5a..e27d5b5 100644
--- a/source/application/main/Main.cc
+++ b/source/application/main/Main.cc
@@ -42,12 +42,10 @@ static void print_application_intro()
int main ()
{
hal_platform platform;
- data_acq_module dataAcq;
- data_psn_module dataPsn;
platform_timer timer;
/* Initialise the HAL and platform. */
- hal_init(&platform, &dataAcq, &dataPsn, &timer);
+ hal_init(&platform, &timer);
if (0 == hal_platform_init(&platform)) {
/* Application information, UART should have been initialised. */
diff --git a/source/application/main/UseCaseCommonUtils.cc b/source/application/main/UseCaseCommonUtils.cc
index d439446..340a767 100644
--- a/source/application/main/UseCaseCommonUtils.cc
+++ b/source/application/main/UseCaseCommonUtils.cc
@@ -36,12 +36,7 @@ void DisplayCommonMenu()
fflush(stdout);
}
-
-
-
-bool PresentInferenceResult(
- hal_platform &platform,
- const std::vector<arm::app::ClassificationResult> &results)
+bool PresentInferenceResult(const std::vector<arm::app::ClassificationResult> &results)
{
constexpr uint32_t dataPsnTxtStartX1 = 150;
constexpr uint32_t dataPsnTxtStartY1 = 30;
@@ -51,7 +46,7 @@ bool PresentInferenceResult(
constexpr uint32_t dataPsnTxtYIncr = 16; /* Row index increment. */
- platform.data_psn->set_text_color(COLOR_GREEN);
+ hal_lcd_set_text_color(COLOR_GREEN);
/* Display each result. */
uint32_t rowIdx1 = dataPsnTxtStartY1 + 2 * dataPsnTxtYIncr;
@@ -66,13 +61,13 @@ bool PresentInferenceResult(
std::to_string(results[i].m_labelIdx) +
" (" + std::to_string(results[i].m_normalisedVal) + ")";
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
resultStr.c_str(), resultStr.size(),
dataPsnTxtStartX1, rowIdx1, false);
rowIdx1 += dataPsnTxtYIncr;
resultStr = std::to_string(i + 1) + ") " + results[i].m_label;
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
resultStr.c_str(), resultStr.size(),
dataPsnTxtStartX2, rowIdx2, 0);
rowIdx2 += dataPsnTxtYIncr;
@@ -134,12 +129,12 @@ bool RunInference(arm::app::Model& model, Profiler& profiler)
return runInf;
}
-int ReadUserInputAsInt(hal_platform& platform)
+int ReadUserInputAsInt()
{
char chInput[128];
memset(chInput, 0, sizeof(chInput));
- platform.data_acq->get_input(chInput, sizeof(chInput));
+ hal_get_user_input(chInput, sizeof(chInput));
return atoi(chInput);
}
@@ -181,7 +176,6 @@ void DumpTensor(const TfLiteTensor* tensor, const size_t lineBreakForNumElements
bool ListFilesHandler(ApplicationContext& ctx)
{
auto& model = ctx.Get<Model&>("model");
- auto& platform = ctx.Get<hal_platform&>("platform");
constexpr uint32_t dataPsnTxtStartX = 20;
constexpr uint32_t dataPsnTxtStartY = 40;
@@ -192,12 +186,12 @@ bool ListFilesHandler(ApplicationContext& ctx)
}
/* Clear the LCD */
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
/* Show the total number of embedded files. */
std::string strNumFiles = std::string{"Total Number of Files: "} +
std::to_string(NUMBER_OF_FILES);
- platform.data_psn->present_data_text(strNumFiles.c_str(),
+ hal_lcd_display_text(strNumFiles.c_str(),
strNumFiles.size(),
dataPsnTxtStartX,
dataPsnTxtStartY,
@@ -210,7 +204,7 @@ bool ListFilesHandler(ApplicationContext& ctx)
for (uint32_t i = 0; i < NUMBER_OF_FILES; ++i, yVal += dataPsnTxtYIncr) {
std::string currentFilename{get_filename(i)};
- platform.data_psn->present_data_text(currentFilename.c_str(),
+ hal_lcd_display_text(currentFilename.c_str(),
currentFilename.size(),
dataPsnTxtStartX, yVal, false);
diff --git a/source/application/main/include/UseCaseCommonUtils.hpp b/source/application/main/include/UseCaseCommonUtils.hpp
index 7f5dde6..9b6d550 100644
--- a/source/application/main/include/UseCaseCommonUtils.hpp
+++ b/source/application/main/include/UseCaseCommonUtils.hpp
@@ -31,12 +31,10 @@ void DisplayCommonMenu();
/**
* @brief Presents inference results using the data presentation
* object.
- * @param[in] platform Reference to the hal platform object.
* @param[in] results Vector of classification results to be displayed.
* @return true if successful, false otherwise.
**/
-bool PresentInferenceResult(hal_platform& platform,
- const std::vector<arm::app::ClassificationResult>& results);
+bool PresentInferenceResult(const std::vector<arm::app::ClassificationResult>& results);
/**
@@ -82,10 +80,9 @@ namespace app {
/**
* @brief Read input and return as an integer.
- * @param[in] platform Reference to the hal platform object.
* @return Integer value corresponding to the user input.
**/
- int ReadUserInputAsInt(hal_platform& platform);
+ int ReadUserInputAsInt();
#if VERIFY_TEST_OUTPUT
/**
diff --git a/source/hal/CMakeLists.txt b/source/hal/CMakeLists.txt
index 10016c2..37bf267 100644
--- a/source/hal/CMakeLists.txt
+++ b/source/hal/CMakeLists.txt
@@ -39,8 +39,6 @@ target_include_directories(${HAL_TARGET}
target_sources(${HAL_TARGET}
PRIVATE
source/hal.c
- source/data_psn.c
- source/data_acq.c
source/hal_timer.c)
if (DEFINED VERIFY_TEST_OUTPUT)
diff --git a/source/hal/include/data_acq.h b/source/hal/include/data_acq.h
deleted file mode 100644
index 965fbe5..0000000
--- a/source/hal/include/data_acq.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2021 Arm Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef DATA_ACQ_H
-#define DATA_ACQ_H
-
-/**
- * This file is the top level abstraction for the data acquisition module.
- **/
-#include <stdint.h>
-
-/* Structure to encompass the data acquisition module and it's methods. */
-typedef struct data_acquisition_module {
- int inited; /**< initialised or not. */
- char system_name[8]; /**< name(s) of the channel in use. */
- int (* system_init)(void); /**< channel initialisation function. */
-
- /* Function to go and check if there are any events that require handling. */
- int (* get_input)(char *user_input, int size);
-} data_acq_module;
-
-/**
- * @brief Initialise the data acquisition channel: goes and
- * sets the required channel up for usage.
- * @param[in,out] module Pointer to a pre-allocated data
- * acquisition structure object.
- * @return 0 if successful, error code otherwise.
- **/
-int data_acq_channel_init(data_acq_module *module);
-
-/**
- * @brief Releases the data acquisition channel.
- * @param[in,out] module Pointer to a pre-allocated data
- * acquisition structure object.
- * @return 0 if successful, error code otherwise.
- **/
-int data_acq_channel_release(data_acq_module *module);
-
-#endif /* DATA_ACQ_H */
diff --git a/source/hal/include/data_psn.h b/source/hal/include/data_psn.h
deleted file mode 100644
index 05d7649..0000000
--- a/source/hal/include/data_psn.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2021-2022 Arm Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef DATA_PSN_H
-#define DATA_PSN_H
-
-/**
- * This file is the top level abstraction for the data presentation module
- **/
-#include <stdint.h>
-#include <stddef.h>
-#include <stdbool.h>
-
-/* Structure to encompass the data presentation module and it's methods */
-typedef struct data_presentation_module {
- int inited; /**< initialised or not */
- char system_name[8]; /**< name of the system in use */
- int (* system_init)(void); /**< pointer to init function */
-
- /** Pointer to the image presentation function */
- int (* present_data_image)(const uint8_t *data, const uint32_t width,
- const uint32_t height, const uint32_t channels,
- const uint32_t pos_x, const uint32_t pos_y,
- const uint32_t downsample_factor);
-
- /* Pointer to text presentation function */
- int (* present_data_text)(const char *str, const size_t str_sz,
- const uint32_t pos_x, const uint32_t pos_y,
- const bool allow_multiple_lines);
-
- /* Pointer to box presentation function */
- int (* present_box)(const uint32_t pos_x, const uint32_t pos_y,
- const uint32_t width, const uint32_t height, const uint16_t color);
-
- /* Pointer to clear presentation function */
- int (* clear)(const uint16_t color);
-
- /* Pointer to set text color presentation function */
- int (* set_text_color)(const uint16_t color);
-} data_psn_module;
-
-
-/**
- * @brief Initialises the data presentation system.
- * @param[in,out] module Pointer to a pre-allocated data
- * presentation structure object.
- * @return 0 if successful, error code otherwise.
- **/
-int data_psn_system_init(data_psn_module *module);
-
-/**
- * @brief Releases the data presentation system.
- * @param[in,out] module Pointer to a pre-allocated data
- * presentation structure object.
- * @return 0 if successful, error code otherwise.
- **/
-int data_psn_system_release(data_psn_module *module);
-
-#endif /* DATA_PSN_H */
diff --git a/source/hal/include/hal.h b/source/hal/include/hal.h
index 6335e6d..25ea1e2 100644
--- a/source/hal/include/hal.h
+++ b/source/hal/include/hal.h
@@ -28,20 +28,18 @@
extern "C" {
#endif
-#include "platform_drivers.h" /* Platform drivers */
-#include "data_acq.h" /* Data acquisition abstraction */
-#include "data_psn.h" /* Data presentation abstraction */
-#include "timer.h" /* Timer/profiler API */
+#include "platform_drivers.h" /* Platform drivers */
+#include "timer.h" /* Timer/profiler API */
+#include "hal_lcd.h" /* LCD functions */
#include <inttypes.h>
+#include <stdbool.h>
/* Structure to define a platform context to be used by the application */
typedef struct hal_platform_context {
int inited; /**< initialised */
char plat_name[64]; /**< name of this platform */
- data_acq_module * data_acq; /**< data acquisition module pointer */
- data_psn_module * data_psn; /**< data presentation module pointer */
- platform_timer * timer; /**< timer */
+ platform_timer* timer; /**< timer */
int (* platform_init)(); /**< pointer to platform initialisation function */
void (* platform_release)(); /**< pointer to platform release function */
} hal_platform;
@@ -50,13 +48,10 @@ typedef struct hal_platform_context {
* @brief Initialise the HAL structure based on compile time config. This
* should be called before any other function in this API.
* @param[in,out] platform Pointer to a pre-allocated platform struct.
- * @param[in,out] data_acq Pointer to a pre-allocated data acquisition module.
- * @param[in,out] data_psn Pointer to a pre-allocated data presentation module.
* @param[in,out] timer Pointer to a pre-allocated timer module.
* @return 0 if successful, error code otherwise.
**/
-int hal_init(hal_platform *platform, data_acq_module *data_acq,
- data_psn_module *data_psn, platform_timer *timer);
+int hal_init(hal_platform* platform, platform_timer* timer);
/**
@@ -66,7 +61,7 @@ int hal_init(hal_platform *platform, data_acq_module *data_acq,
* platform structure.
* @return 0 if successful, error code otherwise.
**/
-int hal_platform_init(hal_platform *platform);
+int hal_platform_init(hal_platform* platform);
/**
@@ -74,7 +69,15 @@ int hal_platform_init(hal_platform *platform);
* @param[in] platform pointer to a pre-allocated and initialised
* platform structure.
**/
-void hal_platform_release(hal_platform *platform);
+void hal_platform_release(hal_platform* platform);
+
+/**
+ * @brief Gets user input from the stdin interface.
+ * @param[out] user_input Pointer to a buffer where the input will be stored.
+ * @param[in] size Buffer size in bytes.
+ * @return True if successful, false otherwise.
+ */
+bool hal_get_user_input(char* user_input, int size);
#ifdef __cplusplus
}
diff --git a/source/hal/include/hal_lcd.h b/source/hal/include/hal_lcd.h
new file mode 100644
index 0000000..0a484c5
--- /dev/null
+++ b/source/hal/include/hal_lcd.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2021-2022 Arm Limited. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef HAL_LCD_H
+#define HAL_LCD_H
+/**
+ * This file is the top level abstraction for the LCD related functions
+ **/
+
+#include "lcd_img.h"
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdbool.h>
+
+/**
+ * See lcd_img.h for function docstrings.
+ * In the following macro definitions:
+ * d = data (pointer)
+ * w = width
+ * h = height
+ * c = channels
+ * x = x position
+ * y = y position
+ * s = down-sample factor (images)
+ * m = allow multiple lines (text)
+ * cl = colour
+ */
+#define hal_lcd_init() lcd_init()
+#define hal_lcd_display_image(d,w,h,c,x,y,s) lcd_display_image(d,w,h,c,x,y,s)
+#define hal_lcd_display_text(s,l,x,y,m) lcd_display_text(s,l,x,y,m)
+#define hal_lcd_display_box(x,y,w,h,cl) lcd_display_box(x,y,w,h,cl)
+#define hal_lcd_clear(cl) lcd_clear(cl)
+#define hal_lcd_set_text_color(cl) lcd_set_text_color(cl)
+
+#endif /* HAL_LCD_H */
diff --git a/source/hal/source/data_acq.c b/source/hal/source/data_acq.c
deleted file mode 100644
index ec6c725..0000000
--- a/source/hal/source/data_acq.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2022 Arm Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "data_acq.h"
-
-#include "log_macros.h"
-#include "platform_drivers.h"
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-/**
- * @brief Get the user input from USART.
- * @param[out] user_input String read from the UART block.
- * @param[in] size String read length.
- * @return 0 if successful, error code otherwise.
- **/
-static int get_uart_user_input(char* user_input, int size)
-{
- if (1 != GetLine(user_input, size - 1)) {
- return 1;
- }
- return 0;
-}
-
-int data_acq_channel_init(data_acq_module* module)
-{
- assert(module);
-
- /* UART should have been initialised with low level initialisation
- * routines. */
- module->system_init = NULL;
-
- strncpy(module->system_name, "UART", sizeof(module->system_name));
- module->get_input = get_uart_user_input;
- module->inited = 1;
-
- return !(module->inited);
-}
-
-int data_acq_channel_release(data_acq_module* module)
-{
- assert(module);
- module->inited = 0;
- module->get_input = NULL;
- return 0;
-}
diff --git a/source/hal/source/data_psn.c b/source/hal/source/data_psn.c
deleted file mode 100644
index de088d7..0000000
--- a/source/hal/source/data_psn.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2022 Arm Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "data_psn.h"
-
-#include "lcd_img.h"
-#include "platform_drivers.h"
-
-#include <assert.h>
-#include <string.h>
-
-int data_psn_system_init(data_psn_module* module)
-{
- assert(module);
-
- /* LCD output supported. */
- module->system_init = lcd_init;
- module->present_data_image = lcd_display_image;
- module->present_data_text = lcd_display_text;
- module->present_box = lcd_display_box;
- module->set_text_color = lcd_set_text_color;
- module->clear = lcd_clear;
- strncpy(module->system_name, "lcd", sizeof(module->system_name));
- module->inited = !module->system_init();
- return !module->inited;
-}
-
-int data_psn_system_release(data_psn_module* module)
-{
- assert(module);
- module->inited = 0;
- return 0;
-}
diff --git a/source/hal/source/hal.c b/source/hal/source/hal.c
index 2715a17..d6028e7 100644
--- a/source/hal/source/hal.c
+++ b/source/hal/source/hal.c
@@ -23,13 +23,8 @@
#include <assert.h>
#include <string.h>
-int hal_init(hal_platform* platform, data_acq_module* data_acq,
- data_psn_module* data_psn, platform_timer* timer)
+int hal_init(hal_platform* platform, platform_timer* timer)
{
- assert(platform && data_acq && data_psn);
-
- platform->data_acq = data_acq;
- platform->data_psn = data_psn;
platform->timer = timer;
platform->platform_init = platform_init;
platform->platform_release = platform_release;
@@ -59,46 +54,33 @@ int hal_platform_init(hal_platform* platform)
return state;
}
- /* Initialise the data acquisition module */
- if (0 != (state = data_acq_channel_init(platform->data_acq))) {
- if (!platform->data_acq->inited) {
- printf_err("Failed to initialise data acq module: %s\n",
- platform->data_acq->system_name);
- }
- hal_platform_release(platform);
+ /* Initialise LCD */
+ if (0 != (state = hal_lcd_init())) {
+ printf_err("hal_lcd_init failed\n");
return state;
}
- /* Initialise the presentation module */
- if (0 != (state = data_psn_system_init(platform->data_psn))) {
- printf_err("Failed to initialise data psn module: %s\n",
- platform->data_psn->system_name);
- data_acq_channel_release(platform->data_acq);
- hal_platform_release(platform);
- return state;
- }
-
- /* Followed by the timer module */
+ /* Initialise the timer module */
init_timer(platform->timer);
info("%s platform initialised\n", platform->plat_name);
- debug("Using %s module for data acquisition\n",
- platform->data_acq->system_name);
- debug("Using %s module for data presentation\n",
- platform->data_psn->system_name);
-
platform->inited = !state;
-
return state;
}
void hal_platform_release(hal_platform *platform)
{
assert(platform && platform->platform_release);
- data_acq_channel_release(platform->data_acq);
- data_psn_system_release(platform->data_psn);
hal_platform_clear(platform);
info("Releasing platform %s\n", platform->plat_name);
platform->platform_release();
}
+
+bool hal_get_user_input(char* user_input, int size)
+{
+ if (1 != GetLine(user_input, size - 1)) {
+ return true;
+ }
+ return false;
+}
diff --git a/source/use_case/ad/src/MainLoop.cc b/source/use_case/ad/src/MainLoop.cc
index 5a289bf..e858320 100644
--- a/source/use_case/ad/src/MainLoop.cc
+++ b/source/use_case/ad/src/MainLoop.cc
@@ -78,7 +78,7 @@ void main_loop(hal_platform& platform)
int menuOption = MENU_OPT_RUN_INF_NEXT;
if (bUseMenu) {
DisplayMenu();
- menuOption = arm::app::ReadUserInputAsInt(platform);
+ menuOption = arm::app::ReadUserInputAsInt();
printf("\n");
}
switch (menuOption) {
@@ -93,7 +93,7 @@ void main_loop(hal_platform& platform)
NUMBER_OF_FILES-1);
fflush(stdout);
auto audioIndex = static_cast<uint32_t>(
- arm::app::ReadUserInputAsInt(platform));
+ arm::app::ReadUserInputAsInt());
executionSuccessful = ClassifyVibrationHandler(caseContext,
audioIndex,
false);
diff --git a/source/use_case/ad/src/UseCaseHandler.cc b/source/use_case/ad/src/UseCaseHandler.cc
index 853ab08..5585f36 100644
--- a/source/use_case/ad/src/UseCaseHandler.cc
+++ b/source/use_case/ad/src/UseCaseHandler.cc
@@ -33,12 +33,11 @@ namespace app {
/**
* @brief Presents inference results using the data presentation
* object.
- * @param[in] platform reference to the hal platform object
* @param[in] result average sum of classification results
* @param[in] threshold if larger than this value we have an anomaly
* @return true if successful, false otherwise
**/
- static bool PresentInferenceResult(hal_platform& platform, float result, float threshold);
+ static bool PresentInferenceResult(float result, float threshold);
/**
* @brief Returns a function to perform feature calculation and populates input tensor data with
@@ -64,7 +63,6 @@ namespace app {
/* Vibration classification handler */
bool ClassifyVibrationHandler(ApplicationContext& ctx, uint32_t clipIndex, bool runAll)
{
- auto& platform = ctx.Get<hal_platform&>("platform");
auto& profiler = ctx.Get<Profiler&>("profiler");
constexpr uint32_t dataPsnTxtInfStartX = 20;
@@ -114,7 +112,7 @@ namespace app {
auto audioDataStride = nMelSpecVectorsInAudioStride * frameStride;
do {
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
auto currentIndex = ctx.Get<uint32_t>("clipIndex");
@@ -153,7 +151,7 @@ namespace app {
/* Display message on the LCD - inference running. */
std::string str_inf{"Running inference... "};
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
info("Running inference on audio clip %" PRIu32 " => %s\n", currentIndex, get_filename(currentIndex));
@@ -202,12 +200,12 @@ namespace app {
/* Erase. */
str_inf = std::string(str_inf.size(), ' ');
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
ctx.Set<float>("result", result);
- if (!PresentInferenceResult(platform, result, scoreThreshold)) {
+ if (!PresentInferenceResult(result, scoreThreshold)) {
return false;
}
@@ -221,13 +219,13 @@ namespace app {
}
- static bool PresentInferenceResult(hal_platform& platform, float result, float threshold)
+ static bool PresentInferenceResult(float result, float threshold)
{
constexpr uint32_t dataPsnTxtStartX1 = 20;
constexpr uint32_t dataPsnTxtStartY1 = 30;
constexpr uint32_t dataPsnTxtYIncr = 16; /* Row index increment */
- platform.data_psn->set_text_color(COLOR_GREEN);
+ hal_lcd_set_text_color(COLOR_GREEN);
/* Display each result */
uint32_t rowIdx1 = dataPsnTxtStartY1 + 2 * dataPsnTxtYIncr;
@@ -242,7 +240,7 @@ namespace app {
anomalyResult += std::string("Everything fine, no anomaly detected!");
}
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
anomalyScore.c_str(), anomalyScore.size(),
dataPsnTxtStartX1, rowIdx1, false);
diff --git a/source/use_case/asr/src/MainLoop.cc b/source/use_case/asr/src/MainLoop.cc
index 40624f3..058211a 100644
--- a/source/use_case/asr/src/MainLoop.cc
+++ b/source/use_case/asr/src/MainLoop.cc
@@ -121,7 +121,7 @@ void main_loop(hal_platform& platform)
int menuOption = MENU_OPT_RUN_INF_NEXT;
if (bUseMenu) {
DisplayMenu();
- menuOption = arm::app::ReadUserInputAsInt(platform);
+ menuOption = arm::app::ReadUserInputAsInt();
printf("\n");
}
switch (menuOption) {
@@ -136,7 +136,7 @@ void main_loop(hal_platform& platform)
NUMBER_OF_FILES-1);
fflush(stdout);
auto clipIndex = static_cast<uint32_t>(
- arm::app::ReadUserInputAsInt(platform));
+ arm::app::ReadUserInputAsInt());
executionSuccessful = ClassifyAudioHandler(caseContext,
clipIndex,
false);
diff --git a/source/use_case/asr/src/UseCaseHandler.cc b/source/use_case/asr/src/UseCaseHandler.cc
index 7bce2c6..420f725 100644
--- a/source/use_case/asr/src/UseCaseHandler.cc
+++ b/source/use_case/asr/src/UseCaseHandler.cc
@@ -36,13 +36,10 @@ namespace app {
/**
* @brief Presents inference results using the data presentation
* object.
- * @param[in] platform Reference to the hal platform object.
* @param[in] results Vector of classification results to be displayed.
* @return true if successful, false otherwise.
**/
- static bool PresentInferenceResult(
- hal_platform& platform,
- const std::vector<arm::app::asr::AsrResult>& results);
+ static bool PresentInferenceResult(const std::vector<arm::app::asr::AsrResult>& results);
/* Audio inference classification handler. */
bool ClassifyAudioHandler(ApplicationContext& ctx, uint32_t clipIndex, bool runAll)
@@ -50,8 +47,7 @@ namespace app {
constexpr uint32_t dataPsnTxtInfStartX = 20;
constexpr uint32_t dataPsnTxtInfStartY = 40;
- auto& platform = ctx.Get<hal_platform&>("platform");
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
auto& profiler = ctx.Get<Profiler&>("profiler");
@@ -103,7 +99,7 @@ namespace app {
/* Loop to process audio clips. */
do {
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
/* Get current audio clip index. */
auto currentIndex = ctx.Get<uint32_t>("clipIndex");
@@ -136,7 +132,7 @@ namespace app {
/* Display message on the LCD - inference running. */
std::string str_inf{"Running inference... "};
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
@@ -192,13 +188,13 @@ namespace app {
/* Erase. */
str_inf = std::string(str_inf.size(), ' ');
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
ctx.Set<std::vector<arm::app::asr::AsrResult>>("results", results);
- if (!PresentInferenceResult(platform, results)) {
+ if (!PresentInferenceResult(results)) {
return false;
}
@@ -212,14 +208,13 @@ namespace app {
}
- static bool PresentInferenceResult(hal_platform& platform,
- const std::vector<arm::app::asr::AsrResult>& results)
+ static bool PresentInferenceResult(const std::vector<arm::app::asr::AsrResult>& results)
{
constexpr uint32_t dataPsnTxtStartX1 = 20;
constexpr uint32_t dataPsnTxtStartY1 = 60;
constexpr bool allow_multiple_lines = true;
- platform.data_psn->set_text_color(COLOR_GREEN);
+ hal_lcd_set_text_color(COLOR_GREEN);
info("Final results:\n");
info("Total number of inferences: %zu\n", results.size());
@@ -243,7 +238,7 @@ namespace app {
/* Get the decoded result for the combined result. */
std::string finalResultStr = audio::asr::DecodeOutput(combinedResults);
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
finalResultStr.c_str(), finalResultStr.size(),
dataPsnTxtStartX1, dataPsnTxtStartY1,
allow_multiple_lines);
diff --git a/source/use_case/img_class/src/MainLoop.cc b/source/use_case/img_class/src/MainLoop.cc
index 05322d1..7b67a19 100644
--- a/source/use_case/img_class/src/MainLoop.cc
+++ b/source/use_case/img_class/src/MainLoop.cc
@@ -60,7 +60,7 @@ void main_loop(hal_platform& platform)
int menuOption = common::MENU_OPT_RUN_INF_NEXT;
if (bUseMenu) {
DisplayCommonMenu();
- menuOption = arm::app::ReadUserInputAsInt(platform);
+ menuOption = arm::app::ReadUserInputAsInt();
printf("\n");
}
switch (menuOption) {
@@ -70,7 +70,7 @@ void main_loop(hal_platform& platform)
case common::MENU_OPT_RUN_INF_CHOSEN: {
printf(" Enter the image index [0, %d]: ", NUMBER_OF_FILES-1);
fflush(stdout);
- auto imgIndex = static_cast<uint32_t>(arm::app::ReadUserInputAsInt(platform));
+ auto imgIndex = static_cast<uint32_t>(arm::app::ReadUserInputAsInt());
executionSuccessful = ClassifyImageHandler(caseContext, imgIndex, false);
break;
}
diff --git a/source/use_case/img_class/src/UseCaseHandler.cc b/source/use_case/img_class/src/UseCaseHandler.cc
index 1f1d78b..9061282 100644
--- a/source/use_case/img_class/src/UseCaseHandler.cc
+++ b/source/use_case/img_class/src/UseCaseHandler.cc
@@ -44,7 +44,6 @@ namespace app {
/* Image inference classification handler. */
bool ClassifyImageHandler(ApplicationContext& ctx, uint32_t imgIndex, bool runAll)
{
- auto& platform = ctx.Get<hal_platform&>("platform");
auto& profiler = ctx.Get<Profiler&>("profiler");
constexpr uint32_t dataPsnImgDownscaleFactor = 2;
@@ -89,7 +88,7 @@ namespace app {
std::vector<ClassificationResult> results;
do {
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
/* Strings for presentation/logging. */
std::string str_inf{"Running inference... "};
@@ -98,7 +97,7 @@ namespace app {
LoadImageIntoTensor(ctx.Get<uint32_t>("imgIndex"), inputTensor);
/* Display this image on the LCD. */
- platform.data_psn->present_data_image(
+ hal_lcd_display_image(
static_cast<uint8_t *>(inputTensor->data.data),
nCols, nRows, nChannels,
dataPsnImgStartX, dataPsnImgStartY, dataPsnImgDownscaleFactor);
@@ -109,7 +108,7 @@ namespace app {
}
/* Display message on the LCD - inference running. */
- platform.data_psn->present_data_text(str_inf.c_str(), str_inf.size(),
+ hal_lcd_display_text(str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
/* Run inference over this image. */
@@ -122,7 +121,7 @@ namespace app {
/* Erase. */
str_inf = std::string(str_inf.size(), ' ');
- platform.data_psn->present_data_text(str_inf.c_str(), str_inf.size(),
+ hal_lcd_display_text(str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
auto& classifier = ctx.Get<ImgClassClassifier&>("classifier");
@@ -137,7 +136,7 @@ namespace app {
arm::app::DumpTensor(outputTensor);
#endif /* VERIFY_TEST_OUTPUT */
- if (!PresentInferenceResult(platform, results)) {
+ if (!PresentInferenceResult(results)) {
return false;
}
diff --git a/source/use_case/inference_runner/src/UseCaseHandler.cc b/source/use_case/inference_runner/src/UseCaseHandler.cc
index 1125830..2f4b7c8 100644
--- a/source/use_case/inference_runner/src/UseCaseHandler.cc
+++ b/source/use_case/inference_runner/src/UseCaseHandler.cc
@@ -116,7 +116,6 @@ static void DumpOutputs(const Model& model, const char* message)
bool RunInferenceHandler(ApplicationContext& ctx)
{
- auto& platform = ctx.Get<hal_platform&>("platform");
auto& profiler = ctx.Get<Profiler&>("profiler");
auto& model = ctx.Get<Model&>("model");
@@ -143,9 +142,8 @@ bool RunInferenceHandler(ApplicationContext& ctx)
std::string str_inf{"Running inference... "};
/* Display message on the LCD - inference running. */
- platform.data_psn->present_data_text(
- str_inf.c_str(), str_inf.size(),
- dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
+ hal_lcd_display_text(str_inf.c_str(), str_inf.size(),
+ dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
if (!RunInference(model, profiler)) {
return false;
@@ -153,7 +151,7 @@ bool RunInferenceHandler(ApplicationContext& ctx)
/* Erase. */
str_inf = std::string(str_inf.size(), ' ');
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
diff --git a/source/use_case/kws/src/MainLoop.cc b/source/use_case/kws/src/MainLoop.cc
index 044c957..76dff8c 100644
--- a/source/use_case/kws/src/MainLoop.cc
+++ b/source/use_case/kws/src/MainLoop.cc
@@ -87,7 +87,7 @@ void main_loop(hal_platform& platform)
int menuOption = MENU_OPT_RUN_INF_NEXT;
if (bUseMenu) {
DisplayMenu();
- menuOption = arm::app::ReadUserInputAsInt(platform);
+ menuOption = arm::app::ReadUserInputAsInt();
printf("\n");
}
switch (menuOption) {
@@ -97,7 +97,7 @@ void main_loop(hal_platform& platform)
case MENU_OPT_RUN_INF_CHOSEN: {
printf(" Enter the audio clip index [0, %d]: ", NUMBER_OF_FILES-1);
fflush(stdout);
- auto clipIndex = static_cast<uint32_t>(arm::app::ReadUserInputAsInt(platform));
+ auto clipIndex = static_cast<uint32_t>(arm::app::ReadUserInputAsInt());
executionSuccessful = ClassifyAudioHandler(caseContext, clipIndex, false);
break;
}
diff --git a/source/use_case/kws/src/UseCaseHandler.cc b/source/use_case/kws/src/UseCaseHandler.cc
index 8dd7724..e04cefc 100644
--- a/source/use_case/kws/src/UseCaseHandler.cc
+++ b/source/use_case/kws/src/UseCaseHandler.cc
@@ -35,16 +35,14 @@ using KwsClassifier = arm::app::Classifier;
namespace arm {
namespace app {
-
+
/**
* @brief Presents inference results using the data presentation
* object.
- * @param[in] platform Reference to the hal platform object.
* @param[in] results Vector of classification results to be displayed.
* @return true if successful, false otherwise.
**/
- static bool PresentInferenceResult(hal_platform& platform,
- const std::vector<arm::app::kws::KwsResult>& results);
+ static bool PresentInferenceResult(const std::vector<arm::app::kws::KwsResult>& results);
/**
* @brief Returns a function to perform feature calculation and populates input tensor data with
@@ -68,7 +66,6 @@ namespace app {
/* Audio inference handler. */
bool ClassifyAudioHandler(ApplicationContext& ctx, uint32_t clipIndex, bool runAll)
{
- auto& platform = ctx.Get<hal_platform&>("platform");
auto& profiler = ctx.Get<Profiler&>("profiler");
constexpr uint32_t dataPsnTxtInfStartX = 20;
@@ -137,7 +134,7 @@ namespace app {
const float secondsPerSample = 1.0/audio::MicroNetKwsMFCC::ms_defaultSamplingFreq;
do {
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
auto currentIndex = ctx.Get<uint32_t>("clipIndex");
@@ -171,7 +168,7 @@ namespace app {
/* Display message on the LCD - inference running. */
std::string str_inf{"Running inference... "};
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
info("Running inference on audio clip %" PRIu32 " => %s\n", currentIndex,
@@ -223,13 +220,13 @@ namespace app {
/* Erase. */
str_inf = std::string(str_inf.size(), ' ');
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
ctx.Set<std::vector<arm::app::kws::KwsResult>>("results", results);
- if (!PresentInferenceResult(platform, results)) {
+ if (!PresentInferenceResult(results)) {
return false;
}
@@ -242,61 +239,6 @@ namespace app {
return true;
}
- static bool PresentInferenceResult(hal_platform& platform,
- const std::vector<arm::app::kws::KwsResult>& results)
- {
- constexpr uint32_t dataPsnTxtStartX1 = 20;
- constexpr uint32_t dataPsnTxtStartY1 = 30;
- constexpr uint32_t dataPsnTxtYIncr = 16; /* Row index increment. */
-
- platform.data_psn->set_text_color(COLOR_GREEN);
- info("Final results:\n");
- info("Total number of inferences: %zu\n", results.size());
-
- /* Display each result */
- uint32_t rowIdx1 = dataPsnTxtStartY1 + 2 * dataPsnTxtYIncr;
-
- for (uint32_t i = 0; i < results.size(); ++i) {
-
- std::string topKeyword{"<none>"};
- float score = 0.f;
- if (!results[i].m_resultVec.empty()) {
- topKeyword = results[i].m_resultVec[0].m_label;
- score = results[i].m_resultVec[0].m_normalisedVal;
- }
-
- std::string resultStr =
- std::string{"@"} + std::to_string(results[i].m_timeStamp) +
- std::string{"s: "} + topKeyword + std::string{" ("} +
- std::to_string(static_cast<int>(score * 100)) + std::string{"%)"};
-
- platform.data_psn->present_data_text(
- resultStr.c_str(), resultStr.size(),
- dataPsnTxtStartX1, rowIdx1, false);
- rowIdx1 += dataPsnTxtYIncr;
-
- if (results[i].m_resultVec.empty()) {
- info("For timestamp: %f (inference #: %" PRIu32
- "); label: %s; threshold: %f\n",
- results[i].m_timeStamp, results[i].m_inferenceNumber,
- topKeyword.c_str(),
- results[i].m_threshold);
- } else {
- for (uint32_t j = 0; j < results[i].m_resultVec.size(); ++j) {
- info("For timestamp: %f (inference #: %" PRIu32
- "); label: %s, score: %f; threshold: %f\n",
- results[i].m_timeStamp,
- results[i].m_inferenceNumber,
- results[i].m_resultVec[j].m_label.c_str(),
- results[i].m_resultVec[j].m_normalisedVal,
- results[i].m_threshold);
- }
- }
- }
-
- return true;
- }
-
/**
* @brief Generic feature calculator factory.
*
@@ -344,6 +286,60 @@ namespace app {
};
}
+ static bool PresentInferenceResult(const std::vector<arm::app::kws::KwsResult>& results)
+ {
+ constexpr uint32_t dataPsnTxtStartX1 = 20;
+ constexpr uint32_t dataPsnTxtStartY1 = 30;
+ constexpr uint32_t dataPsnTxtYIncr = 16; /* Row index increment. */
+
+ hal_lcd_set_text_color(COLOR_GREEN);
+ info("Final results:\n");
+ info("Total number of inferences: %zu\n", results.size());
+
+ /* Display each result */
+ uint32_t rowIdx1 = dataPsnTxtStartY1 + 2 * dataPsnTxtYIncr;
+
+ for (uint32_t i = 0; i < results.size(); ++i) {
+
+ std::string topKeyword{"<none>"};
+ float score = 0.f;
+ if (!results[i].m_resultVec.empty()) {
+ topKeyword = results[i].m_resultVec[0].m_label;
+ score = results[i].m_resultVec[0].m_normalisedVal;
+ }
+
+ std::string resultStr =
+ std::string{"@"} + std::to_string(results[i].m_timeStamp) +
+ std::string{"s: "} + topKeyword + std::string{" ("} +
+ std::to_string(static_cast<int>(score * 100)) + std::string{"%)"};
+
+ hal_lcd_display_text(
+ resultStr.c_str(), resultStr.size(),
+ dataPsnTxtStartX1, rowIdx1, false);
+ rowIdx1 += dataPsnTxtYIncr;
+
+ if (results[i].m_resultVec.empty()) {
+ info("For timestamp: %f (inference #: %" PRIu32
+ "); label: %s; threshold: %f\n",
+ results[i].m_timeStamp, results[i].m_inferenceNumber,
+ topKeyword.c_str(),
+ results[i].m_threshold);
+ } else {
+ for (uint32_t j = 0; j < results[i].m_resultVec.size(); ++j) {
+ info("For timestamp: %f (inference #: %" PRIu32
+ "); label: %s, score: %f; threshold: %f\n",
+ results[i].m_timeStamp,
+ results[i].m_inferenceNumber,
+ results[i].m_resultVec[j].m_label.c_str(),
+ results[i].m_resultVec[j].m_normalisedVal,
+ results[i].m_threshold);
+ }
+ }
+ }
+
+ return true;
+ }
+
template std::function<void (std::vector<int16_t>&, size_t , bool, size_t)>
FeatureCalc<int8_t>(TfLiteTensor* inputTensor,
size_t cacheSize,
diff --git a/source/use_case/kws_asr/src/MainLoop.cc b/source/use_case/kws_asr/src/MainLoop.cc
index a2beab3..096c966 100644
--- a/source/use_case/kws_asr/src/MainLoop.cc
+++ b/source/use_case/kws_asr/src/MainLoop.cc
@@ -156,7 +156,7 @@ void main_loop(hal_platform& platform)
int menuOption = MENU_OPT_RUN_INF_NEXT;
if (bUseMenu) {
DisplayMenu();
- menuOption = arm::app::ReadUserInputAsInt(platform);
+ menuOption = arm::app::ReadUserInputAsInt();
printf("\n");
}
switch (menuOption) {
@@ -171,7 +171,7 @@ void main_loop(hal_platform& platform)
NUMBER_OF_FILES-1);
fflush(stdout);
auto clipIndex = static_cast<uint32_t>(
- arm::app::ReadUserInputAsInt(platform));
+ arm::app::ReadUserInputAsInt());
executionSuccessful = ClassifyAudioHandler(caseContext,
clipIndex,
false);
diff --git a/source/use_case/kws_asr/src/UseCaseHandler.cc b/source/use_case/kws_asr/src/UseCaseHandler.cc
index d598de6..1e1a400 100644
--- a/source/use_case/kws_asr/src/UseCaseHandler.cc
+++ b/source/use_case/kws_asr/src/UseCaseHandler.cc
@@ -53,11 +53,10 @@ namespace app {
/**
* @brief Presents kws inference results using the data presentation
* object.
- * @param[in] platform reference to the hal platform object
* @param[in] results vector of classification results to be displayed
* @return true if successful, false otherwise
**/
- static bool PresentInferenceResult(hal_platform& platform, std::vector<arm::app::kws::KwsResult>& results);
+ static bool PresentInferenceResult(std::vector<arm::app::kws::KwsResult>& results);
/**
* @brief Presents asr inference results using the data presentation
@@ -66,7 +65,7 @@ namespace app {
* @param[in] results vector of classification results to be displayed
* @return true if successful, false otherwise
**/
- static bool PresentInferenceResult(hal_platform& platform, std::vector<arm::app::asr::AsrResult>& results);
+ static bool PresentInferenceResult(std::vector<arm::app::asr::AsrResult>& results);
/**
* @brief Returns a function to perform feature calculation and populates input tensor data with
@@ -186,9 +185,8 @@ namespace app {
std::vector<arm::app::kws::KwsResult> kwsResults;
/* Display message on the LCD - inference running. */
- auto& platform = ctx.Get<hal_platform&>("platform");
std::string str_inf{"Running KWS inference... "};
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
@@ -258,11 +256,11 @@ namespace app {
/* Erase. */
str_inf = std::string(str_inf.size(), ' ');
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
- if (!PresentInferenceResult(platform, kwsResults)) {
+ if (!PresentInferenceResult(kwsResults)) {
return output;
}
@@ -285,8 +283,7 @@ namespace app {
constexpr uint32_t dataPsnTxtInfStartY = 40;
auto& profiler = ctx.Get<Profiler&>("profiler");
- auto& platform = ctx.Get<hal_platform&>("platform");
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
/* Get model reference. */
auto& asrModel = ctx.Get<Model&>("asrmodel");
@@ -356,7 +353,7 @@ namespace app {
/* Display message on the LCD - inference running. */
std::string str_inf{"Running ASR inference... "};
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
@@ -407,11 +404,11 @@ namespace app {
/* Erase */
str_inf = std::string(str_inf.size(), ' ');
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
}
- if (!PresentInferenceResult(platform, asrResults)) {
+ if (!PresentInferenceResult(asrResults)) {
return false;
}
@@ -423,8 +420,7 @@ namespace app {
/* Audio inference classification handler. */
bool ClassifyAudioHandler(ApplicationContext& ctx, uint32_t clipIndex, bool runAll)
{
- auto& platform = ctx.Get<hal_platform&>("platform");
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
/* If the request has a valid size, set the audio index. */
if (clipIndex < NUMBER_OF_FILES) {
@@ -457,14 +453,13 @@ namespace app {
}
- static bool PresentInferenceResult(hal_platform& platform,
- std::vector<arm::app::kws::KwsResult>& results)
+ static bool PresentInferenceResult(std::vector<arm::app::kws::KwsResult>& results)
{
constexpr uint32_t dataPsnTxtStartX1 = 20;
constexpr uint32_t dataPsnTxtStartY1 = 30;
constexpr uint32_t dataPsnTxtYIncr = 16; /* Row index increment. */
- platform.data_psn->set_text_color(COLOR_GREEN);
+ hal_lcd_set_text_color(COLOR_GREEN);
/* Display each result. */
uint32_t rowIdx1 = dataPsnTxtStartY1 + 2 * dataPsnTxtYIncr;
@@ -484,7 +479,7 @@ namespace app {
std::string{"s: "} + topKeyword + std::string{" ("} +
std::to_string(static_cast<int>(score * 100)) + std::string{"%)"};
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
resultStr.c_str(), resultStr.size(),
dataPsnTxtStartX1, rowIdx1, 0);
rowIdx1 += dataPsnTxtYIncr;
@@ -502,13 +497,13 @@ namespace app {
return true;
}
- static bool PresentInferenceResult(hal_platform& platform, std::vector<arm::app::asr::AsrResult>& results)
+ static bool PresentInferenceResult(std::vector<arm::app::asr::AsrResult>& results)
{
constexpr uint32_t dataPsnTxtStartX1 = 20;
constexpr uint32_t dataPsnTxtStartY1 = 80;
constexpr bool allow_multiple_lines = true;
- platform.data_psn->set_text_color(COLOR_GREEN);
+ hal_lcd_set_text_color(COLOR_GREEN);
/* Results from multiple inferences should be combined before processing. */
std::vector<arm::app::ClassificationResult> combinedResults;
@@ -528,7 +523,7 @@ namespace app {
std::string finalResultStr = audio::asr::DecodeOutput(combinedResults);
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
finalResultStr.c_str(), finalResultStr.size(),
dataPsnTxtStartX1, dataPsnTxtStartY1, allow_multiple_lines);
diff --git a/source/use_case/noise_reduction/src/MainLoop.cc b/source/use_case/noise_reduction/src/MainLoop.cc
index c6214e3..bcaff6d 100644
--- a/source/use_case/noise_reduction/src/MainLoop.cc
+++ b/source/use_case/noise_reduction/src/MainLoop.cc
@@ -98,7 +98,7 @@ void main_loop(hal_platform& platform)
if (bUseMenu) {
DisplayMenu();
- menuOption = arm::app::ReadUserInputAsInt(platform);
+ menuOption = arm::app::ReadUserInputAsInt();
printf("\n");
}
switch (menuOption) {
@@ -108,7 +108,7 @@ void main_loop(hal_platform& platform)
case MENU_OPT_RUN_INF_CHOSEN: {
printf(" Enter the audio clip IFM index [0, %d]: ", NUMBER_OF_FILES-1);
fflush(stdout);
- auto clipIndex = static_cast<uint32_t>(arm::app::ReadUserInputAsInt(platform));
+ auto clipIndex = static_cast<uint32_t>(arm::app::ReadUserInputAsInt());
SetAppCtxClipIdx(caseContext, clipIndex);
executionSuccessful = NoiseReductionHandler(caseContext, false);
break;
diff --git a/source/use_case/noise_reduction/src/UseCaseHandler.cc b/source/use_case/noise_reduction/src/UseCaseHandler.cc
index 792b460..acb8ba7 100644
--- a/source/use_case/noise_reduction/src/UseCaseHandler.cc
+++ b/source/use_case/noise_reduction/src/UseCaseHandler.cc
@@ -64,8 +64,6 @@ namespace app {
pMemDumpBytesWritten = ctx.Get<size_t*>("MEM_DUMP_BYTE_WRITTEN");
}
std::reference_wrapper<size_t> memDumpBytesWritten = std::ref(*pMemDumpBytesWritten);
-
- auto& platform = ctx.Get<hal_platform&>("platform");
auto& profiler = ctx.Get<Profiler&>("profiler");
/* Get model reference. */
@@ -106,7 +104,7 @@ namespace app {
audioFileAccessorFunc = ctx.Get<std::function<const char*(const uint32_t)>>("featureFileNames");
}
do{
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
auto startDumpAddress = memDumpBaseAddr + memDumpBytesWritten;
auto currentIndex = ctx.Get<uint32_t>("clipIndex");
@@ -158,7 +156,7 @@ namespace app {
std::string str_inf{"Running inference... "};
/* Display message on the LCD - inference running. */
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
@@ -191,7 +189,7 @@ namespace app {
/* Erase. */
str_inf = std::string(str_inf.size(), ' ');
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
@@ -218,14 +216,14 @@ namespace app {
IncrementAppCtxClipIdx(ctx);
std::string clearString{' '};
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
clearString.c_str(), clearString.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
std::string completeMsg{"Inference complete!"};
/* Display message on the LCD - inference complete. */
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
completeMsg.c_str(), completeMsg.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
diff --git a/source/use_case/object_detection/src/MainLoop.cc b/source/use_case/object_detection/src/MainLoop.cc
index 4bec357..0f98c8a 100644
--- a/source/use_case/object_detection/src/MainLoop.cc
+++ b/source/use_case/object_detection/src/MainLoop.cc
@@ -67,7 +67,7 @@ void main_loop(hal_platform& platform)
int menuOption = common::MENU_OPT_RUN_INF_NEXT;
if (bUseMenu) {
DisplayDetectionMenu();
- menuOption = arm::app::ReadUserInputAsInt(platform);
+ menuOption = arm::app::ReadUserInputAsInt();
printf("\n");
}
switch (menuOption) {
@@ -77,7 +77,7 @@ void main_loop(hal_platform& platform)
case common::MENU_OPT_RUN_INF_CHOSEN: {
printf(" Enter the image index [0, %d]: ", NUMBER_OF_FILES-1);
fflush(stdout);
- auto imgIndex = static_cast<uint32_t>(arm::app::ReadUserInputAsInt(platform));
+ auto imgIndex = static_cast<uint32_t>(arm::app::ReadUserInputAsInt());
executionSuccessful = ObjectDetectionHandler(caseContext, imgIndex, false);
break;
}
diff --git a/source/use_case/object_detection/src/UseCaseHandler.cc b/source/use_case/object_detection/src/UseCaseHandler.cc
index 27d767d..f3b317e 100644
--- a/source/use_case/object_detection/src/UseCaseHandler.cc
+++ b/source/use_case/object_detection/src/UseCaseHandler.cc
@@ -30,31 +30,27 @@ namespace app {
/**
* @brief Presents inference results along using the data presentation
* object.
- * @param[in] platform Reference to the hal platform object.
* @param[in] results Vector of detection results to be displayed.
* @return true if successful, false otherwise.
**/
- static bool PresentInferenceResult(hal_platform& platform,
- const std::vector<arm::app::object_detection::DetectionResult>& results);
+ static bool PresentInferenceResult(const std::vector<arm::app::object_detection::DetectionResult>& results);
/**
* @brief Draw boxes directly on the LCD for all detected objects.
- * @param[in] platform Reference to the hal platform object.
* @param[in] results Vector of detection results to be displayed.
* @param[in] imageStartX X coordinate where the image starts on the LCD.
* @param[in] imageStartY Y coordinate where the image starts on the LCD.
* @param[in] imgDownscaleFactor How much image has been downscaled on LCD.
**/
- static void DrawDetectionBoxes(hal_platform& platform,
- const std::vector<arm::app::object_detection::DetectionResult>& results,
- uint32_t imgStartX,
- uint32_t imgStartY,
- uint32_t imgDownscaleFactor);
+ static void DrawDetectionBoxes(
+ const std::vector<arm::app::object_detection::DetectionResult>& results,
+ uint32_t imgStartX,
+ uint32_t imgStartY,
+ uint32_t imgDownscaleFactor);
/* Object detection classification handler. */
bool ObjectDetectionHandler(ApplicationContext& ctx, uint32_t imgIndex, bool runAll)
{
- auto& platform = ctx.Get<hal_platform&>("platform");
auto& profiler = ctx.Get<Profiler&>("profiler");
constexpr uint32_t dataPsnImgDownscaleFactor = 1;
@@ -64,7 +60,7 @@ namespace app {
constexpr uint32_t dataPsnTxtInfStartX = 150;
constexpr uint32_t dataPsnTxtInfStartY = 40;
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
auto& model = ctx.Get<Model&>("model");
@@ -114,7 +110,7 @@ namespace app {
image::RgbToGrayscale(curr_image, dstPtr, copySz);
/* Display image on the LCD. */
- platform.data_psn->present_data_image(
+ hal_lcd_display_image(
(channelsImageDisplayed == 3) ? curr_image : dstPtr,
nCols, nRows, channelsImageDisplayed,
dataPsnImgStartX, dataPsnImgStartY, dataPsnImgDownscaleFactor);
@@ -125,7 +121,7 @@ namespace app {
}
/* Display message on the LCD - inference running. */
- platform.data_psn->present_data_text(str_inf.c_str(), str_inf.size(),
+ hal_lcd_display_text(str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
/* Run inference over this image. */
@@ -138,7 +134,7 @@ namespace app {
/* Erase. */
str_inf = std::string(str_inf.size(), ' ');
- platform.data_psn->present_data_text(str_inf.c_str(), str_inf.size(),
+ hal_lcd_display_text(str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
/* Detector post-processing*/
@@ -153,14 +149,14 @@ namespace app {
results);
/* Draw boxes. */
- DrawDetectionBoxes(platform, results, dataPsnImgStartX, dataPsnImgStartY, dataPsnImgDownscaleFactor);
+ DrawDetectionBoxes(results, dataPsnImgStartX, dataPsnImgStartY, dataPsnImgDownscaleFactor);
#if VERIFY_TEST_OUTPUT
arm::app::DumpTensor(modelOutput0);
arm::app::DumpTensor(modelOutput1);
#endif /* VERIFY_TEST_OUTPUT */
- if (!PresentInferenceResult(platform, results)) {
+ if (!PresentInferenceResult(results)) {
return false;
}
@@ -173,11 +169,9 @@ namespace app {
return true;
}
-
- static bool PresentInferenceResult(hal_platform& platform,
- const std::vector<arm::app::object_detection::DetectionResult>& results)
+ static bool PresentInferenceResult(const std::vector<arm::app::object_detection::DetectionResult>& results)
{
- platform.data_psn->set_text_color(COLOR_GREEN);
+ hal_lcd_set_text_color(COLOR_GREEN);
/* If profiling is enabled, and the time is valid. */
info("Final results:\n");
@@ -192,8 +186,7 @@ namespace app {
return true;
}
- static void DrawDetectionBoxes(hal_platform& platform,
- const std::vector<arm::app::object_detection::DetectionResult>& results,
+ static void DrawDetectionBoxes(const std::vector<arm::app::object_detection::DetectionResult>& results,
uint32_t imgStartX,
uint32_t imgStartY,
uint32_t imgDownscaleFactor)
@@ -202,20 +195,20 @@ namespace app {
for (const auto& result: results) {
/* Top line. */
- platform.data_psn->present_box(imgStartX + result.m_x0/imgDownscaleFactor,
+ hal_lcd_display_box(imgStartX + result.m_x0/imgDownscaleFactor,
imgStartY + result.m_y0/imgDownscaleFactor,
result.m_w/imgDownscaleFactor, lineThickness, COLOR_GREEN);
/* Bot line. */
- platform.data_psn->present_box(imgStartX + result.m_x0/imgDownscaleFactor,
+ hal_lcd_display_box(imgStartX + result.m_x0/imgDownscaleFactor,
imgStartY + (result.m_y0 + result.m_h)/imgDownscaleFactor - lineThickness,
result.m_w/imgDownscaleFactor, lineThickness, COLOR_GREEN);
/* Left line. */
- platform.data_psn->present_box(imgStartX + result.m_x0/imgDownscaleFactor,
+ hal_lcd_display_box(imgStartX + result.m_x0/imgDownscaleFactor,
imgStartY + result.m_y0/imgDownscaleFactor,
lineThickness, result.m_h/imgDownscaleFactor, COLOR_GREEN);
/* Right line. */
- platform.data_psn->present_box(imgStartX + (result.m_x0 + result.m_w)/imgDownscaleFactor - lineThickness,
+ hal_lcd_display_box(imgStartX + (result.m_x0 + result.m_w)/imgDownscaleFactor - lineThickness,
imgStartY + result.m_y0/imgDownscaleFactor,
lineThickness, result.m_h/imgDownscaleFactor, COLOR_GREEN);
}
diff --git a/source/use_case/vww/src/MainLoop.cc b/source/use_case/vww/src/MainLoop.cc
index 30e85bf..03d6196 100644
--- a/source/use_case/vww/src/MainLoop.cc
+++ b/source/use_case/vww/src/MainLoop.cc
@@ -58,7 +58,7 @@ void main_loop(hal_platform &platform)
int menuOption = common::MENU_OPT_RUN_INF_NEXT;
if (bUseMenu) {
DisplayCommonMenu();
- menuOption = arm::app::ReadUserInputAsInt(platform);
+ menuOption = arm::app::ReadUserInputAsInt();
printf("\n");
}
@@ -69,7 +69,7 @@ void main_loop(hal_platform &platform)
case common::MENU_OPT_RUN_INF_CHOSEN: {
printf(" Enter the image index [0, %d]: ", NUMBER_OF_FILES-1);
fflush(stdout);
- auto imgIndex = static_cast<uint32_t>(arm::app::ReadUserInputAsInt(platform));
+ auto imgIndex = static_cast<uint32_t>(arm::app::ReadUserInputAsInt());
executionSuccessful = ClassifyImageHandler(caseContext, imgIndex, false);
break;
}
diff --git a/source/use_case/vww/src/UseCaseHandler.cc b/source/use_case/vww/src/UseCaseHandler.cc
index a47f191..56ba2b5 100644
--- a/source/use_case/vww/src/UseCaseHandler.cc
+++ b/source/use_case/vww/src/UseCaseHandler.cc
@@ -42,7 +42,6 @@ namespace app {
/* Image inference classification handler. */
bool ClassifyImageHandler(ApplicationContext &ctx, uint32_t imgIndex, bool runAll)
{
- auto& platform = ctx.Get<hal_platform &>("platform");
auto& profiler = ctx.Get<Profiler&>("profiler");
constexpr uint32_t dataPsnImgDownscaleFactor = 1;
@@ -89,7 +88,7 @@ namespace app {
std::vector<ClassificationResult> results;
do {
- platform.data_psn->clear(COLOR_BLACK);
+ hal_lcd_clear(COLOR_BLACK);
/* Strings for presentation/logging. */
std::string str_inf{"Running inference... "};
@@ -98,7 +97,7 @@ namespace app {
LoadImageIntoTensor(ctx.Get<uint32_t>("imgIndex"), inputTensor);
/* Display this image on the LCD. */
- platform.data_psn->present_data_image(
+ hal_lcd_display_image(
static_cast<uint8_t *>(inputTensor->data.data),
nCols, nRows, nChannels,
dataPsnImgStartX, dataPsnImgStartY, dataPsnImgDownscaleFactor);
@@ -115,7 +114,7 @@ namespace app {
}
/* Display message on the LCD - inference running. */
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
@@ -129,7 +128,7 @@ namespace app {
/* Erase. */
str_inf = std::string(str_inf.size(), ' ');
- platform.data_psn->present_data_text(
+ hal_lcd_display_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
@@ -145,7 +144,7 @@ namespace app {
arm::app::DumpTensor(outputTensor);
#endif /* VERIFY_TEST_OUTPUT */
- if (!PresentInferenceResult(platform, results)) {
+ if (!PresentInferenceResult(results)) {
return false;
}