Skip to content

Updated API docs. Added new example docs and images. #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions source/amebapro2/API_Documents/FileSystem/Class AmebaFatFS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ A class for file management using FatFS File system.
+----------------------------+------------------------------------------+
| AmebaFatFS::status | Check if the file system is initialized |
+----------------------------+------------------------------------------+
| AmebaFatFS::get_free_space | Retrieve the free space of SDcard |
+----------------------------+------------------------------------------+
| AmebaFatFS::get_used_space | Retrieve the used space of SDcard |
+----------------------------+------------------------------------------+

**AmebaFatFS::AmebaFatFS**
--------------------------
Expand Down Expand Up @@ -604,3 +608,66 @@ This function returns 1 if the file system is initialized, 0 otherwise.
NA

.. note :: "AmebaFatFS.h" must be included to use the class function.

**AmebaFatFS::get_free_space**
------------------------------

**Description**
~~~~~~~~~~~~~~~

Retrieve the free space of SDcard.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

long long int get_free_space(void);

**Parameters**
~~~~~~~~~~~~~~
NA

**Returns**
~~~~~~~~~~~

This function returns the value of free space size up to 8-bytes.

**Example Code**
~~~~~~~~~~~~~~~~

Example: `GetFreeAndUseSpace <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/FileSystem/examples/GetFreeAndUseSpace/GetFreeAndUseSpace.ino>`_

.. note :: "AmebaFatFS.h" must be included to use the class function.

**AmebaFatFS::get_used_space**
------------------------------

**Description**
~~~~~~~~~~~~~~~

Retrieve the used space of SDcard.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

long long int get_used_space(void);

**Parameters**
~~~~~~~~~~~~~~
NA

**Returns**
~~~~~~~~~~~

This function returns the value of used space size up to 8-bytes.

**Example Code**
~~~~~~~~~~~~~~~~

Example: `GetFreeAndUseSpace <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/FileSystem/examples/GetFreeAndUseSpace/GetFreeAndUseSpace.ino>`_

.. note :: "AmebaFatFS.h" must be included to use the class function.

38 changes: 38 additions & 0 deletions source/amebapro2/API_Documents/Multimedia/Class VideoStream.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,10 @@ A class used to configure and initialize the camera to generate video data strea
| Video::printInfo | Print out current configuration of |
| | video channels. |
+----------------------------+-----------------------------------------+
| Video::videostream_status | Retrieve video stream module contents |
| | from specific channel and pass for |
| | checking on UVC connection status. |
+----------------------------+-----------------------------------------+

**Video::configVideoChannel**
-----------------------------
Expand Down Expand Up @@ -2000,3 +2004,37 @@ NA
Example: `StreamRTSP/VideoOnly <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/Multimedia/examples/StreamRTSP/VideoOnly/VideoOnly.ino>`_

.. note :: "VideoStream.h" must be included to use the class function.

**Video::videostream_status**
------------------------------

**Description**
~~~~~~~~~~~~~~~

Retrieve video stream module contents from specific channel and pass for checking on UVC connection status.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

int videostream_status(int ch);

**Parameters**
~~~~~~~~~~~~~~

ch: Channel to configure.

- 0

**Returns**
~~~~~~~~~~~

This function returns 1 if the UVC device is connected to PC, 0 otherwise.

**Example Code**
~~~~~~~~~~~~~~~~

Example: `UVCDObjectDetectionLoop <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/NeuralNetwork/examples/UVCDObjectDetectionLoop/UVCDObjectDetectionLoop.ino>`_

.. note :: "VideoStream.h" must be included to use the class function.
80 changes: 80 additions & 0 deletions source/amebapro2/API_Documents/USB/Class UVCD.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,17 @@ A class for USB UVC device API.
+-----------------------------------+----------------------------------+
| **Public Methods** |
+-----------------------------------+----------------------------------+
| UVCD::isUsbUvcConnected | Check if the UVC device |
| | is connected to PC and |
| | video stream. |
+-----------------------------------+----------------------------------+
| UVCD::configVideo | Start config video of using USB |
| | UVC device. |
+-----------------------------------+----------------------------------+
| UVCD::nnbegin | Begin video streaming of using |
| | USB UVC device for object |
| | detection. |
+-----------------------------------+----------------------------------+
| UVCD::begin | Begin video streaming of using |
| | USB UVC device. |
+-----------------------------------+----------------------------------+
Expand Down Expand Up @@ -72,6 +80,38 @@ Example: `UVC_Device <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/

.. note :: "UVCD.h", "StreamIO.h" and "VideoStream.h" must be included to use the class function.

**UVCD::isUsbUvcConnected**
---------------------------

**Description**
~~~~~~~~~~~~~~~

Check if the UVC device is connected to PC or video stream.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

int isUsbUvcConnected(int uvcd_getctx_state);

**Parameters**
~~~~~~~~~~~~~~

uvcd_getctx_state: A return integer value of 1 if the UVC device is connected to PC, 0 otherwise.

**Returns**
~~~~~~~~~~~

This function returns 1 if the video stream module is initialized and UVC device is connected to PC, 0 otherwise.

**Example Code**
~~~~~~~~~~~~~~~~

Example: `UVCDObjectDetectionLoop <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/NeuralNetwork/examples/UVCDObjectDetectionLoop/UVCDObjectDetectionLoop.ino>`_

.. note :: "UVCD.h" and "VideoStream.h" must be included to use the class function.

**UVCD::configVideo**
---------------------

Expand Down Expand Up @@ -104,6 +144,46 @@ Example: `UVC_Device <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/

.. note :: "UVCD.h", "StreamIO.h" and "VideoStream.h" must be included to use the class function.

**UVCD::nnbegin**
-----------------

**Description**
~~~~~~~~~~~~~~~

Begin video streaming of using USB UVC device for object detection.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

void nnbegin(const MMFModule &module_videocam, void *module_videolinker, int uvcd_channel, int nn_channel, int uvcd_getctx_check);

**Parameters**
~~~~~~~~~~~~~~

module_videocam: stream data from camera video.

module_videolinker: StreamIO object for uvcd.

uvcd_channel: video channel.

nn_channel: neural network channel.

uvcd_getctx_check: A return integer value of 1 if the UVC device is connected to PC, 0 otherwise.

**Returns**
~~~~~~~~~~~

NA

**Example Code**
~~~~~~~~~~~~~~~~

Example: `UVCDObjectDetectionLoop <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/NeuralNetwork/examples/UVCDObjectDetectionLoop/UVCDObjectDetectionLoop.ino>`_

.. note :: "UVCD.h", "StreamIO.h" and "VideoStream.h" must be included to use the class function.

**UVCD::begin**
---------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Display Free and Use space of SD card
=====================================

.. contents::
:local:
:depth: 2

Materials
---------

- `AMB82-mini <https://www.amebaiot.com/en/where-to-buy-link/#buy_amb82_mini>`_ x 1

- MicroSD card

Example
-------

In this example, we will be using Ameba Pro2 development board to retrieve free and use space of SD card.

Procedure
~~~~~~~~~

Insert a MicroSD card into the SD card slot of the AMB82 MINI board.

Open the example, "Files" -> "Examples" -> "AmebaFileSystem" -> "GetFreeAndUseSpace".

|image01|

Upload the code and press the reset button on the board once the upload is finished.

The sample code will print out the used space and free space of the SD card to the serial monitor.

|image02|

.. |image01| image:: ../../../_static/amebapro2/Example_Guides/File_System/Display_Used_and_Free_space_of_SD_card/image01.png
:width: 900 px
:height: 550 px
.. |image02| image:: ../../../_static/amebapro2/Example_Guides/File_System/Display_Used_and_Free_space_of_SD_card/image02.png
:width: 700 px
:height: 400 px

4 changes: 3 additions & 1 deletion source/amebapro2/Example_Guides/File System/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ File System
:maxdepth: 1

Read and display HTML file from SD card
Simple applications with SD card
Simple applications with SD card
Display Free and Use space of SD card

Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
UVCD Object Detection
=====================

.. contents::
:local:
:depth: 2

Materials
---------

- `AMB82-mini <https://www.amebaiot.com/en/where-to-buy-link/#buy_amb82_mini>`_ x 1

Example
-------

In this example, we will be using Ameba Pro2 development board to detect 80 different kinds of objects such as person, bicycle, car, laptop etc using on-board camera sensor (JX-F37P).

The following examples show how Object Detection and On-Screen Display is used.

Open the example, “File” -> “Examples” -> “AmebaNN” -> "UVCDObjectDetectionLoop".

|image01|

Select Neural Network (NN) task and models using modelSelect() function highlighted in yellow. This function takes 4 arguments: Neural Network task, Object Detection model, Face Detection model and Face Recognition model. Replace with “NA_MODEL” if they are not necessary for your selected Neural Network task. Note that it is mandatory to call modelSelect() function before calling the begin() function.

Valid Neural Network task: OBJECT_DETECTION, FACE_DETECTION, FACE_RECOGNITION

Valid Object Detection model:

YOLOv3 model: DEFAULT_YOLOV3TINY, CUSTOMIZED_YOLOV3TINY

YOLOv4 model: DEFAULT_YOLOV4TINY, CUSTOMIZED_YOLOV4TINY

YOLOv7 model: DEFAULT_YOLOV7TINY, CUSTOMIZED_YOLOV7TINY

Valid Face Detection model: DEFAULT_SCRFD, CUSTOMIZED_SCRFD

Valid Face Recognition model: DEFAULT_MOBILEFACENET, CUSTOMIZED_MOBILEFACENET

Choose the customized option (e.g., CUSTOMIZED_YOLOV4TINY/ CUSTOMIZED_SCRFD/ CUSTOMIZED_MOBILEFACENET) if you would like to use your own NN model. To learn about the process of converting an AI model, refer to https://www.amebaiot.com/en/amebapro2-ai-convert-model/ . Additionally, refer to https://www.amebaiot.com/en/amebapro2-apply-ai-model-docs/ to understand how to install and use the converted model.

Note that for Yolov7 object detection training from pytorch, you will need to perform an additional step for reparameterization. For this reparameterization step, Realtek has provided two scripts in the folder Yolov7_reparam_scripts, under ~/NeuralNetwork/Yolov7_reparam_scripts.

Command to run is:

python reparam_yolov7-tiny.py --weights weights/best.pt --custom_yaml custom/yolov7-tiny-deploy.yaml --output best_reparam.pt

|image02|

Compile the code and upload it to Ameba. After pressing the Reset button, connect the “USB OTG” via micro-USB cable to the target device such as PC.

|image03|

Review the USB cam driver as following picture.

|image04|

The result of detected objects can be validated using Potplayer. You may download Potplayer from the link `here <https://potplayer.org/en/potplayer-zip.html>`__.

Upon the completion of the software installation, open Potplayer, and go to “PotPlayer” -> “Open” -> "Device Settings".

|image05|

Next, on Device and Format drop down menu, select "USB UVC CLASS" and "H264 1920x1080 24" and click "Open device".

|image06|

The video stream from the camera will be shown in Potplayer.

A bounding box with its object name and confidence score will be drawn on the RTSP video stream to highlight the recognised objects.

|image07|

.. |image01| image:: ../../../_static/amebapro2/Example_Guides/Neural_Network/Neural_Network_-_UVCD_Object_Detection/image01.png
:width: 900 px
:height: 550 px

.. |image02| image:: ../../../_static/amebapro2/Example_Guides/Neural_Network/Neural_Network_-_UVCD_Object_Detection/image02.png
:width: 817 px
:height: 550 px

.. |image03| image:: ../../../_static/amebapro2/Example_Guides/Neural_Network/Neural_Network_-_UVCD_Object_Detection/image03.png
:width: 687 px
:height: 600 px

.. |image04| image:: ../../../_static/amebapro2/Example_Guides/Neural_Network/Neural_Network_-_UVCD_Object_Detection/image04.png
:width: 432 px
:height: 482 px

.. |image05| image:: ../../../_static/amebapro2/Example_Guides/Neural_Network/Neural_Network_-_UVCD_Object_Detection/image05.png
:width: 900 px
:height: 550 px

.. |image06| image:: ../../../_static/amebapro2/Example_Guides/Neural_Network/Neural_Network_-_UVCD_Object_Detection/image06.png
:width: 602 px
:height: 400 px

.. |image07| image:: ../../../_static/amebapro2/Example_Guides/Neural_Network/Neural_Network_-_UVCD_Object_Detection/image07.png
:width: 772 px
:height: 453 px

1 change: 1 addition & 0 deletions source/amebapro2/Example_Guides/Neural Network/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Neural Network
Face Recognition
Image Classification
Object Detection
UVCD Object Detection

Loading