The Internet of Things on AWS – Official Blog

Efficient video streaming and vision AI at the edge with Realtek, Plumerai, and Amazon Kinesis Video Streams

Artificial Intelligence (AI) at the edge is popular among smart video devices. For example, Smart Home cameras and video doorbells revolutionized home monitoring. What began as simple recording and remote viewing tools has evolved into intelligent observers. With AI infusion, today’s cameras can actively analyze scenes, alert users to motion events, recognize familiar faces, spot package deliveries, and dynamically adjust their recording behavior. Enterprise surveillance cameras are another example. These cameras have superior resolution, enhanced computing power, and can drive more sophisticated AI models. These enhanced capabilities result in sharper detection at greater distances.

As illustrated, customers demand intelligent monitoring systems that can process data locally while maintaining privacy and reducing bandwidth costs. To address these needs, the AWS Internet of Things (AWS IoT) team has developed a smart camera solution with AWS partners that combines Amazon Kinesis Video Streams, Realtek’s low-power Ameba Pro2 microcontroller, and efficient machine learning models from Plumerai. This blog post provides guidance for event-triggered video uploads coupled with human detection algorithm processing at the edge.

Solution architecture

Figure below illustrates the solution architecture that this blog uses:
overall solution architecture

  1. Beginning with the camera, the device firmware has integrated Realtek SDK to access camera modules via defined APIs.
  2. The video fragments are delivered to Plumerai’s machine learning models for object detection.
  3. The sample application adds detection results as bonding box overlay on the original video fragments. This sample continuously uploads the fragments to cloud through Kinesis Video Streams Producer SDK. (As an aside, you can also set detection results to trigger uploads of 20-second video segments.)
  4. The Kinesis Video Streams Producer SDK relies on PutMedia API with long HTTPS connection to upload MKV fragments continuously in a streaming way.
  5. The media data will be ingested and the service stores all media data persistently for later analysis.
  6. A frontend application performs the playback of live, or previously recorded videos, relying on HLS or DASH protocols from Kinesis Video Streams.
  7. The solution feeds video and audio data into Large Language Models (LLMs) for Agentic AI insights. (We will cover semantic video search in our next blog).

Integration highlights

Amazon Kinesis Video Streams

Kinesis Video Streams transforms how businesses handle video solutions for IP cameras, robots, and automobiles. Key benefits include:

  • A fully managed architecture. This helps engineering teams focus on innovation instead of infrastructure and is ideal for companies with limited resources.
  • AWS SDKs are open-sourced. Top brands especially value this independence from platform constraints.
  • Flexible pay-per-use pricing model. While device development can take months or years, you don’t pay until the cameras go live. With typical cloud storage activation below 30% and declining yearly usage, costs stay dramatically lower than fixed license fees.

Plumerai

The Plumerai company specializes in embedded AI solutions, specially focused toward making deep learning tiny and efficient. The Plumerai model helps to provide inference on small, affordable, and low-power hardware. The company also optimizes AI models for the Realtek Ameba Pro2 platform through:

  • Assembly-level optimizations can maximize Arm Cortex-M CPU performance, and leverages DSP instructions for enhanced signal processing capabilities.
  • Neural Architecture Search (NAS) selects optimal AI models for Realtek NPU and memory architecture to achieve 0.4 TOPS NPU acceleration
  • Plumerai models use Realtek on-chip hardware accelerators (scalers, format converters) to reduce computational load.
  • The AI model supports RTOS to seamlessly integrates the SoC’s real-time operating system.
  • The application integrates with Realtek’s media streaming framework.
  • The fast boot design supports rapid booting times, which improves battery life, and ensures high speed of active object detection.
  • The edge AI models are trained on 30 million labeled images and videos.

These enhancements translate into the following real-world performance:

  • Delivers precision without wasting memory.
  • Captures wide scenes through 180° field-of-view lenses.
  • Detects individuals at 20m+ (65ft) distances.
  • Handles crowds by tracking 20 people simultaneously.
  • Maintains individual tracking with a unique ID system.
  • Performs consistently in bright daylight and total darkness.

Realtek Ameba Pro2

AembaPro2Topology

Figure above illustrates Realtek Ameba Pro2’s data architecture. It contains Integrated Video Encoder (IVE) and an Image Signal Processor (ISP) that processes media’s raw data and delivers the result to a Video Offload Engine (VOE). The VOE then manages multiple video channels and concurrent video streams to support the motion detection algorithm. The Neural Processing Unit (NPU) performs inference on images or image regions. The Parallel Processing Unit (PPU) handles multitasking jobs like cropping Regions of Interests (ROIs) from high-resolution images, resizing NPU inference input, and retrieving final output from high-resolution channels.This architecture unlocks powerful capabilities to support video analytics at the edge, including:

  • Runing with minimal CPU power for maximum efficiency.
  • Responding in near real time to motion.
  • Begin video processing even during the boot sequence.
  • Streaming to both the SD card and cloud through secure WiFi or Ethernet.
  • Leveraging NPU to deliver superior AI performance.
  • Integrating with Plumerai models and Kinesis Video Streams through a multimedia framework SDK.

Walkthrough

This section outlines the building steps for the solution to run edge AI and stream the video fragments.

Prerequisites

Set up the building environment

This blog uses an Amazon EC2 with Ubuntu LTS 22.04 as the building environment. You can use your own Ubuntu computer to cross-compile the SDK.

Amazon EC2 instance setup:

  1. Sign in into the AWS management console and navigate to Amazon EC2.
  2. Launch an instance with the following configuration:
  • Instance name: KVS_AmebaPlumerAI_poc
  • Application and OS Images: Ubuntu Server 22.04 LTS (HVM)
  • Instance type: t3.large
  • Create a new key pair for login: kvs-plumerai-realtek-keypair
  • Configure storage: 100GiB
  • Follow SSH connection prerequisites to allow inbound SSH traffic.

Download sample script from Github:

  1. Using the following command, log into your Amazon EC2 instance (be sure to replace xxx.yyy.zzz with the instance’s IP address). For detailed instructions, see Connect to your Linux instance using an SSH client.
ssh -o ServerAliveInterval=60 -i kvs-plumerai-realtek-keypair.pem ubuntu@54.xxx.yyy.zzz
git clone https://github.com/aws-samples/sample-kvs-edge_ai-video-streaming-solution.git
cd ./sample-kvs-edge_ai-video-streaming-solution/KVS_Ameba_Plumerai

Obtain the Plumerai library:

  1. Using the Plumerai contact us form, submit a request to receive a copy of their demo package. Once you have the package, replace the “plumerai” directory with it in the Amazon EC2 instance. The updated directory structure should be the following:

plumerai directory

Obtain the Ameba SDK:

  1. Please contact Realtek to obtain the latest Ameba Pro2 SDK. In the directory structure, replace the “ambpro2_sdk” in Amazon EC2. The directory structure should be the following:

ambpro2 directory

Install dependencies and configure environment

  1. Run the script setup_kvs_ameba_plumerai.sh in the directory sample-kvs-edge_ai-video-streaming-solution from the Github repository:
chmod +x setup_kvs_ameba_plumerai.sh./setup_kvs_ameba_plumerai.sh

The script will automatically install the Linux dependencies, build the Realtek toolchain, run necessary Plumerai patches, copy model files, and download the Kinesis Video Streams Producer SDK. If you experience an error in the process, please contact Realtek or Plumerai for technical support.

Configure sample in Kinesis Video Streams Producer SDK

Use the following to configure AWS credentials, stream name, and AWS region. These can be found in the component/example/kvs_producer_mmf/sample_config.h file.

// KVS general configuration
#define AWS_ACCESS_KEY "xxxxx"
#define AWS_SECRET_KEY "xxxxx"
// KVS stream configuration
#define KVS_STREAM_NAME "kvs-plumerai-realtek-stream"
#define AWS_KVS_REGION "us-east-1"
#define AWS_KVS_SERVICE "kinesisvideo"
#define AWS_KVS_HOST AWS_KVS_SERVICE "." AWS_KVS_REGION ".amazonaws.com"

Comment out example_kvs_producer_mmf(); and example_kvs_producer_with_object_detection(); in the file /home/ubuntu/KVS_Ameba_Plumerai/ambpro2_sdk/component/example/kvs_producer_mmf/app_example.c

//example_kvs_producer_mmf();
//example_kvs_producer_with_object_detection();

Compile and build

Use the following code to navigate to the KVS_Ameba_Plumerai directory, and compile and build the updates.

cd ./KVS_Ameba_Plumerai 
cmake -DVIDEO_EXAMPLE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../ambpro2_sdk/project/realtek_amebapro2_v0_example/GCC-RELEASE/toolchain.cmake -Sambpro2_sdk/project/realtek_amebapro2_v0_example/GCC-RELEASE -Bbuild 
cmake --build build --target flash_nn

Run the sample in Ameba Pro2

Download and flash the binary image:

  1. Download the flash_ntz.nn.bin binary image to your local machine from the Amazon EC2 instance. For example, run the following command on your local machine (be sure to update the command to include your IP address and the correct folder path):
scp -i kvs-keypair.pem ubuntu@54.64.xxx.xxx:/home/ubuntu/sample-kvs-edge_ai-video-streaming-solution/KVS_Ameba_Plumerai/build/flash_ntz.nn.bin ./flash_ntz.nn.bin
  1. Connect the Ameba Pro2 MCU to your local machine via USB and press its buttons on both sides to enter download mode. Use the Ameba Pro2 image tool from Realtek to flash the binary image and reboot it.

For example, use the following command on Microsoft Windows (please update your own path to the tool and COM port number):

C:\Users\Administrator\Desktop\Pro2_PG_tool_v1.3.0>.\uartfwburn.exe -p COM3 -f flash_ntz.nn.bin -b 2000000 -U

Or use the following command on macOS:

./uartfwburn.arm.darwin -p /dev/cu.usbserial-110 -f ./flash_ntz.nn.bin -b 3000000
  1. When the process completes, you’ll receive an output log that’s similar to the following:

image flashed to AmebaPro2

Configure WiFi:

  1. Press the reset button, which is next to the red LED indicator.
  2. Use a serial tool and configure it as follows:
  • Baud rate = 115200
  • Data bits = 8
  • Parity=None
  • stop bits =1, XON_OFF
  1. Paste the WiFi configuration information (be sure to change information that’s specific to your network):
ATW0=myHotspotName 
ATW1=myPassword
ATWC
  1. When you’re finished, press Enter.
  2. When the process completes, you’ll receive an output log that’s similar to the following:

Set WiFi configuration

Verify the video on AWS management console

Keep the Ameba Pro2 connected to the USB port and point the camera to capture human motions.

Open the Kinesis Video Streams console and choose the video stream you created. You should see the video with the bounding boxes showing the detection results.

KVS Console

Video fragments with bounding boxes for humans and their faces have now been successfully ingested and persistently stored by the service.

Performance summary

According to lab test results, the application on the edge requires only 1.5MB of ROM space and is optimized for the Ameba Pro2’s NPU. The firmware achieves approximately 10 frames per second processing speed while consuming only 20% of the CPU. This leaves capacity for additional applications.
AmebaPro2 CPU consumption

Cost and cleaning up

Normally, you will finish the whole compiling and testing steps in 10 hours. The total cost should be less than $5 USD. For detailed pricing for Amazon EC2, see pricing of Amazon EC2 on-demand instance. For detailed pricing for Kinesis Video Streams, see pricing of Kinesis Video Streams. Our sample application involves these three parts:

  • Data Ingested into Kinesis Video Streams
  • Data Consumed from Kinesis Video Streams using HLS
  • Data Stored in Kinesis Video Streams

To save cost, please remove the resources you created:

Conclusion

For more guidance about video applications, see:

The collaboration between Amazon Kinesis Video Streams, Realtek, and Plumerai results in a cutting-edge home security solution that leverages edge vision AI and advanced video streaming capabilities. This integrated system addresses the growing demand for sophisticated AI/ML video solutions in both smart home and enterprise surveillance markets. This collaborative solution also illustrates the potential for AI-driven enhancements in home and enterprise security by offering improved monitoring capabilities, efficient processing, and seamless cloud integration.

With AI detection directly on the device, this edge-first approach means your video data stays local until needed, protecting privacy while dramatically reducing bandwidth usage. As the demand for intelligent video solutions continues to grow, this technology sets a new standard for what’s possible in the realm of smart surveillance and video monitoring systems.


About the authors

Zihang Huang is a solution architect at AWS. He is an IoT domain expert for connected vehicles, smart home, smart renewable energy, and industrial IoT. Before AWS, he gained technical experience at Bosch and Alibaba Cloud. Currently, he focuses on interdisciplinary solutions to integrate AWS IoT, edge computing, big data, AI, and machine learning.

Siva Somasundaram is a senior engineer at AWS and builds embedded SDK and server-side components for Kinesis Video Streams. With over 15 years of experience in video streaming services, he has developed media processing pipelines, transcoding and security features for large-scale video ingestion. His expertise spans across video compression, WebRTC, RTSP, and video AI. He is passionate about creating metadata hubs that power semantic search, RAG experiences, and pushing the boundaries of what’s possible in video technology.

Emily Chou is director at Realtek Semiconductor Corp. She specializes in wireless communication network technology and has worked with several generations of the AmebaIoT MCU. She guides a team to provide connectivity solutions, video analytics, and edge AI computing.

Marco Jacobs is the Head of Product Marketing at Plumerai, where he drives adoption of tiny, highly accurate AI solutions for smart home cameras and IoT devices. With 25 years of experience in camera and imaging applications, he seamlessly connects executives and engineers to drive innovation. Holding seven issued patents, Marco is passionate about transforming cutting-edge AI technology into business opportunities that deliver real-world impact.