Converting a NumPy image into a C-byte array
Our application will be running on a virtual platform with no access to a camera module. Therefore, we must provide a valid test input image for our application to check whether the model works as expected.
In this recipe, we will get an image from the validation dataset belonging to the ship class. The sample will then be converted into an int8_t
C array and saved as an input.h
file.
Getting ready
To prepare this recipe, we must know how to structure the C file containing the input test image. The structure of this file is quite simple and illustrated in Figure 10.7:
Figure 10.7: The C header file structure for the input test image
As you can observe from the file structure, we only need an array and two variables to describe our input test sample. These variables are as follows:
g_test
: Anint8_t
array containing a ship image with the normalized and quantized pixel values. The pixel values (// Data
...