HOME
Shop
  • English
  • 简体中文
HOME
Shop
  • English
  • 简体中文
  • Product Series

    • FPGA+ARM

      • GM-3568JHF

        • Introduction

          • GM-3568JHF Introduction
        • Quick Start

          • Preface
          • Environment Setup
          • Compilation Notes
          • Flashing Guide
          • Debugging Tools
          • Software Update
          • Viewing System Information
          • Test Commands
          • Application Compilation
          • Source Code Access
        • Peripherals & Interfaces

          • USB
          • Display and Touch
          • Ethernet
          • WIFI
          • Bluetooth
          • TF-Card
          • Audio
          • Serial Port
          • CAN
          • RTC
        • Application Development

          • UART Read/Write Demo
          • Key Detection Demo
          • LED Blink Demo
          • MIPI Screen Detection Demo
          • Read USB Device Information Demo
          • FAN Detection Demo
          • FPGA FSPI Communication Demo
          • FPGA DMA Read/Write Demo
          • GPS Debugging Demo
          • Ethernet Test Demo
          • RS485 Read/Write Demo
          • FPGA I2C Read/Write Demo
          • PN532 NFC Card-Reading Demo
          • TF Card Read/Write Demo
        • QT Development

          • ARM64 Cross-Compiler Environment Setup
          • Adding a QT Program to Boot Auto-Start
        • RKNN_NPU Development

          • RK3568 NPU Overview
          • Development Environment Setup
          • Run the Official YOLOv5 Example
        • FPGA Development

          • ARM and FPGA Communication
          • FPGA Development Manual
        • Others

          • Modifying the Root Filesystem
          • System Auto-Start Services
        • Downloads

          • Downloads
      • MB-E30P

        • Introduction

          • MB-E30P Introduction
        • Quick Start

          • Preface
          • Environment Setup
          • Compilation Instructions
          • Flashing Guide
          • Debugging Tools
          • Software Update
          • Viewing Information
          • Test Commands
          • Application Compilation
          • Source Code Acquisition
        • Peripherals & Interfaces

          • USB
          • Display and Touch
          • Ethernet
          • WIFI
          • Bluetooth
          • TF-Card
          • Audio
          • RTC
        • Application Development

          • Key Detection Demo
          • LED Blink Demo
          • MIPI Screen Detection Demo
          • Read USB Device Information Demo
          • FAN Detection Demo
          • FPGA FSPI Communication Demo
          • FPGA DMA Read/Write Demo
          • Ethernet Test Demo
          • FPGA IIC Read/Write Demo
          • PN532 NFC Card Reading Demo
          • TF Card Read/Write Demo
        • QT Development

          • ARM64 Cross-Compiler Environment Setup
          • Adding a QT Program to the Boot Auto-Start Service
        • RKNN_NPU Development

          • RK3568 NPU Overview
          • Development Environment Setup
          • Run the Official YOLOv5 Example
          • Model Conversion In Detail
          • Run Custom Models on the Board
        • FPGA Development

          • ARM and FPGA Communication
          • FPGA Development Manual
        • Others

          • Modifying the Root Filesystem
          • System Auto-Start Service
        • Downloads

          • Downloads
    • ShimetaPi

      • M4-R1

        • Introduction

          • M4-R1 Introduction
        • Quick Start

          • OpenHarmony Overview
          • Image Burning
          • Application Development Quick Start
          • Device Development Quick Start
        • Application Development

          • ArkUI

            • ArkTS Language Overview
            • UI Components - Row Container Introduction
            • UI Components - Column Container Introduction
            • UI Components - Text Component
            • UI Components - Toggle Component
            • UI Components - Slider Component
            • UI Components - Animation Component & Transition Component
          • Documentation

            • OpenHarmony Official Materials
          • Development Notes

            • Full-SDK Replacement Tutorial
            • Introducing and Using Third-Party Libraries
            • HDC Debugging
            • Restore Factory Mode via Command Line
            • Upgrade App to System Permission
          • First App

            • Build Your First ArkTS Application - HelloWorld
          • Demos

            • Serial-Debug-Assistant Application Demo
            • Writing-Board Application Demo
            • Digital Clock Application Demo
            • Wi-Fi Information Acquisition Application Demo
        • Device Development

          • Ubuntu Development

            • Environment Setup
            • Download Source Code
            • Compile Source Code
          • DevEco Device Tool

            • Tool Introduction
            • Development Environment Construction
            • Import the SDK
            • HUAWEI DevEco Tool Function Introduction
        • Kernel Peripherals & Interfaces

          • Guide
          • Device Tree Introduction
          • NAPI Introduction
          • ArkTS Introduction
          • NAPI Development Hands-on Demo
          • GPIO Introduction
          • I2C Communication
          • SPI Communication
          • PWM Control
          • UART Communication
          • TF Card (MicroSD)
          • Screen (Display)
          • Touch
          • Ethernet
          • M.2 SSD
          • Audio
          • WIFI & BT
          • Camera
        • Downloads

          • Downloads
      • M5-R1

        • Introduction

          • M5-R1 Development Docs
        • Quick Start

          • Image Burning
          • Environment Setup
          • Download Source Code
        • Peripherals & Interfaces

          • Raspberry Pi Interfaces
          • GPIO Interface
          • I2C Interface
          • SPI Communication
          • PWM Control
          • Serial Port Communication
          • TF Card
          • Display
          • Touch
          • Audio
          • RTC
          • Ethernet
          • M.2
          • MINI-PCIE
          • Camera
          • WIFI & BT
        • Downloads

          • Downloads
      • Pico-G1

        • Product Overview

          • Product Introduction
          • SDK Version Information
        • Quick Start

          • Development Environment Setup
          • Image Build
          • Image Flashing
          • System Login
          • Network Configuration
          • File Transfer
          • SDK Directory Structure
          • Deploying Your First Application
          • Deploying Your First Driver
          • Mounting an SD Card
        • Peripherals & Interfaces

          • GPIO Control
          • UART Serial Communication
          • I2C Communication
          • SPI Communication
        • MPP Media Development

          • MPP Media Processing Software
          • Image Processing Chain
          • Video Input
          • Image Encoding
        • NPU & AI

          • NPU Driver and Runtime Library Architecture
          • .xmm Model Loading
          • SVP Video Processing
          • AI Noise Reduction (AI_NR)
        • Application Samples

          • Encryption/Decryption Application
          • ADC Acquisition Application
          • Low-Power Application
          • Audio Processing Application
          • Video Encoding Application
          • Video Input Application
          • Video Graphics Subsystem (VGS) Application
          • 08 Region Overlay Application
          • 09 Intelligent Video Engine Application
          • 10 UVC Webcam Application
          • 11 All-in-One Quickstart Application
          • 12 FPN Correction Application
          • 13 Regional Motion Detection Application
          • 14 MTCNN Face Detection Application
        • Expansion Board Peripheral Examples

          • 00 - Pico Expansion Board Peripheral Examples Overview
          • 01 - OLED Display Application
          • 02 - TFT Display Application
          • 03 - MPU6050 Gyroscope Application
          • 04 - ADC Acquisition Application
          • 05 - Passive Buzzer Application
          • 06 - MQ Gas Sensor Application
          • 07 - GPS Positioning Application
          • 08 - SHT20 Temperature & Humidity Application
          • 09 - Ultrasonic Ranging Application
          • 10 - SpO2 Sensor Application
          • 11 - DC Motor Control Application
          • 12 - Servo Control Application
    • OpenHarmony

      • SC-3568HA

        • Introduction

          • SC-3568HA Overview
        • Quick Start Guide

          • OpenHarmony Overview
          • Image Flashing
          • Setting Up the Development Environment
          • Hello World Application and Deployment
        • Application Development

          • ArkUI

            • Introduction to ArkTS Language
            • Introduction to UI Components and Practical Applications (Part 1)
            • Introduction to UI Components and Practical Applications (Part 2)
            • Introduction to UI Components and Practical Applications (Part 3)
          • Expand

            • Getting Started Guide
            • Referencing and Using Third-Party Libraries
            • Application Compilation and Deployment
            • Command-Line Factory Reset
            • System Debugging -- HDC Debugging
            • APP Stability Testing
            • Chapter 7 Application Testing
        • Device Development

          • Environment Setup
          • Download Source Code
          • Compiling Source Code
        • Peripheral And Interface

          • Raspberry Pi interface
          • GPIO Interface
          • I2C Interface
          • SPI communication
          • PWM (Pulse Width Modulation) control
          • Serial port communication
          • TF Card
          • Display Screen
          • Touch
          • Audio
          • RTC
          • Ethernet
          • M.2
          • MINI-PCIE
          • Camera
          • WIFI&BT
          • Raspberry Pi expansion board
        • Downloads

          • Downloads
      • M-K1HSE

        • Introduction

          • M-K1HSE Introduction
        • Quick Start

          • Development environment construction
          • Source code acquisition
          • Compilation Notes
          • Burning Guide
        • Application Development

          • Application Development Environment Setup
          • First Application - Hello World
        • Peripherals and interfaces

          • 01 Audio
          • 02 RS485
          • 03 Display
        • System customization development

          • System transplant
          • System customization
          • Driver Development
          • System Debugging
          • OTA Update
        • Downloads

          • Downloads
    • HVS Camera

      • Quick Start

        • SDK Overview
        • Downloads
        • Your First C++ Program
        • Python Data Analysis
        • MultiVision Studio
      • Development

        • Programming Guides

          • Open Camera
          • Read Events
          • Recording & Replay
          • Event Processing (Denoising)
          • Display & Visualization
          • Tuning
          • Capture APS Image
        • Toolkit SDK

          • Hybrid Vision Toolkit
          • Quick Start
          • C++ API
          • Python API
        • Algorithm

          • Hybrid Vision Algo
          • Hybrid Vision Algo API
          • Windows Algo SDK
        • Samples Overview
        • Applications
      • Fundamentals

        • Event Camera Fundamentals
        • HVS Hybrid Vision
        • Event Visualization
        • Data Formats Reference
        • Glossary
        • Bias & Tuning
        • Video Tutorials
      • USB Cameras

        • HVS Camera Quick Start
        • Networking Capabilities

          • HVS Camera System Architecture
          • EVS Network Server
          • EVS Time Sync
          • Web Window
        • HVS Camera Compatibility Matrix
        • FAQ & Troubleshooting Guide
        • Products

          • CF-NRS1 (Lingguang No.1 Hybrid Vision Camera)
      • MIPI Modules

        • MIPI Module Quick Start
        • Carrier Boards

          • RDK X5 Carrier Board Adaptation
          • Raspberry Pi Carrier Board Adaptation
          • Digua Pi Carrier Board Adaptation
          • ShimeTai Board Carrier Board Adaptation
        • MIPI Module Compatibility Matrix
        • Products

          • EVS_003 Sensor Module
    • AI-model

      • 1684XB-32T

        • Introduction

          • AIBOX-1684XB-32 Introduction
        • Quick Start

          • First Use
          • Network Configuration
          • Disk Usage
          • Memory Allocation
          • Fan Control Strategy
          • Firmware Upgrade
          • Cross Compilation
          • Model Quantization
        • Application Development

          • Development Overview

            • Sophgo SDK Development
            • Sophgo Demo Introduction
          • Large Language Models

            • Deploying Llama3 Example
            • Sophon LLM_api_server Development
            • Deploying MiniCPM-V-2_6
            • Qwen-2-5-VL Image and Video Recognition Demo
            • Qwen3-chat Demo
            • Qwen3-Qwen Agent-MCP Development
            • Qwen3-langchain-AI Agent
          • Deep Learning

            • ResNet (Image Classification)
            • LPRNet (License Plate Recognition)
            • SAM (General Image Segmentation Foundation Model)
            • YOLOv5 (Object Detection)
            • OpenPose (Human Keypoint Detection)
            • PP-OCR (Optical Character Recognition)
        • Downloads

          • Downloads
      • 1684X-416T

        • Introduction

          • AIBOX-1684X-416 Introduction
        • Demo Quick Guide

          • ShimeTai Intelligent Monitoring Demo Quick Usage Guide
      • RDK-X5

        • Introduction

          • RDK-X5 Hardware Introduction
        • Quick Start

          • RDK-X5 Quick Start
        • Application Development

          • AI Online Model Development

            • Experiment 01 - Access Volcengine Doubao AI
            • Experiment 02 - Image Analysis
            • Experiment 03 - Multimodal Visual Analysis & Localization
            • Experiment 04 - Multimodal Image-Text Comparison
            • Experiment 05 - Multimodal Document/Table Analysis
            • Experiment 06 - Camera-based AI Visual Analysis
          • Large Language Models

            • Experiment 01 - Speech Recognition
            • Experiment 02 - Voice Conversation
            • Experiment 03 - Multimodal Image Analysis - Voice
            • Experiment 04 - Multimodal Image Comparison - Voice
            • Experiment 05 - Multimodal Document Analysis - Voice
            • Experiment 06 - Multimodal Vision Application - Voice
          • ROS2 Basics

            • Experiment 01 - Environment Setup
            • Experiment 02 - Create & Build a Workspace Package
            • Experiment 03 - Run ROS2 Topic Communication Node
            • Experiment 04 - ROS2 Camera Application
          • 40-pin IO Development

            • Experiment 01 - GPIO Output (LED Blink)
            • Experiment 02 - GPIO Input
            • Experiment 03 - Button-controlled LED
            • Experiment 04 - PWM Output
            • Experiment 05 - Serial Output
            • Experiment 06 - I2C Experiment
            • Experiment 07 - SPI Experiment
          • USB Module Usage

            • Experiment 01 - USB Voice Module Usage
            • Experiment 02 - Sound Source Localization Module
          • Machine Vision Practice

            • Experiment 01 - Open USB Camera
            • Experiment 02 - Color Recognition
            • Experiment 03 - Gesture Recognition
            • Experiment 04 - YOLOv5 Object Detection
      • RDK-S100

        • Introduction

          • RDK-S100 Hardware Introduction
        • Quick Start

          • RDK-S100 Quick Start
        • Application Development

          • AI Online Model Development

            • Experiment 01 - Access Volcengine Doubao AI
            • Experiment 02 - Image Analysis
            • Experiment 03 - Multimodal Visual Analysis & Localization
            • Experiment 04 - Multimodal Image-Text Comparison
            • Experiment 05 - Multimodal Document/Table Analysis
            • Experiment 06 - Camera-based AI Visual Analysis
          • Large Language Models

            • Experiment 01 - Speech Recognition
            • Experiment 02 - Voice Conversation
            • Experiment 03 - Multimodal Image Analysis - Voice
            • Experiment 04 - Multimodal Image Comparison - Voice
            • Experiment 05 - Multimodal Document Analysis - Voice
            • Experiment 06 - Multimodal Vision Application - Voice
          • ROS2 Basics

            • Experiment 01 - Environment Setup
            • Experiment 02 - Create & Build a Workspace Package
            • Experiment 03 - Run ROS2 Topic Communication Node
            • Experiment 04 - ROS2 Camera Application
          • 40-pin IO Development

            • Experiment 01 - GPIO Output (LED Blink)
            • Experiment 02 - GPIO Input
            • Experiment 03 - Button-controlled LED
            • Experiment 04 - PWM Output
            • Experiment 05 - Serial Output
            • Experiment 06 - I2C Experiment
            • Experiment 07 - SPI Experiment
          • USB Module Usage

            • Experiment 01 - USB Voice Module Usage
            • Experiment 02 - Sound Source Localization Module
          • Machine Vision Practice

            • Experiment 01 - Open USB Camera
            • Experiment 02 - Image Processing Basics
            • Experiment 03 - Object Detection
            • Experiment 04 - Image Segmentation
      • RK1828

        • Introduction

          • M5-182X-A1 AI Edge Box - Product Introduction
          • M5-182X-A1 Hardware Specifications
          • M5-182X-A1 Usage & Safety
        • Quick Start

          • M5-182X-A1 Image Flashing
          • RK182X Hardware Installation & Verification
          • RK182X Development Environment Quick Setup
          • RK182X SDK Overview
          • RK182X Environment Setup in Detail
          • RK182X Quick Start
          • Vendor SDK Data Extraction Record
        • Development Guide

          • ClawChips Architecture and Principles
          • SKILL User Manual
          • RK182X Series LLM Inference (RK1828 Model)
          • RK182X Series CNN Inference (RK1828 Model)
          • Model Conversion
          • RK182X AI Agent Application Development Guide
          • RK182X Industrial Anomaly Detection Application
        • SDK Reference

          • RKNN3-SDK Overview

            • RKNN3 SDK Overview
          • RKNN3-Toolkit

            • RKNN3 Toolkit Installation and Usage
          • RKLLM

            • RKLLM On-Device LLM Inference
          • RK182X Series NPU Overview and Architecture (RK1828 Model)
          • RK182X INT8 Quantized Inference Deployment
          • RK182X MPP Multimedia Framework
          • MPP Details

            • RK182X Video Decoding
            • RK182X Video Encoding
          • NPU Details

            • RKNN Model Conversion
            • RK182X NPU INT8 Quantized Inference
            • RK182X Multi-Model Parallel Inference
          • RGA Details

            • RK182X RGA 2D Graphics Acceleration
          • VPU Details

            • RK182X VPU Codec
        • Hardware Reference

          • RK182X Series Hardware Architecture Overview (RK1828 Model)
          • RK182X Pin Definitions and Multiplexing Configuration
          • RK182X Pin Definitions
          • RK182X Power Management
          • RK182X Clock and PLL Configuration
          • RK182X Clock and Frequency Configuration
        • Tutorials

          • Hello World
          • Hello RK1828 - The First Program
          • RTSP Streaming
          • RTSP Streaming + AI Analysis
          • ShiMetaPi AI Lobster One-Click Deployment
          • PaddleOCR-VL Text Recognition
          • Qwen3-1.7B LLM Text Chat
          • AI Multi-View Inspection (Qwen3-VL Wrapper)
          • YOLOv5 Object Detection
        • Downloads

          • Downloads
        • FAQ

          • FAQ
    • Core-Board

      • C-3568BQ

        • Introduction

          • C-3568BQ Overview
      • C-3588LQ

        • Introduction

          • C-3588LQ Overview
      • GC-3568JBAF

        • Introduction

          • GC-3568JBAF Overview
      • C-K1BA

        • Introduction

          • C-K1BA Overview
    • Software Platform

      • ShiMetaPi Workbench

        • Introduction

          • Product Overview
          • Core Architecture
          • Feature Entries
          • Supported Hardware
          • Release Notes
        • Quick Start

          • Install & Login
          • Connect the Device
          • Set Up the Environment
          • Connect to AIHub
          • First Inference
        • User Guide

          • Workspace Overview
          • Device Manager
          • Model Market
          • One-Click Deploy
          • Vision — SVP
          • Vision - Custom Models
          • shimeta-py IDE
          • Terminal
          • Agent Debug Assistant
          • Settings and Resources
        • FAQ

          • Installation & Login
          • Device Connection
          • Models & Deployment
          • Vision & Runtime
          • Settings & Other
      • ShimetaPi Repository

        • Introduction

          • ShimetaPi Software Repository
        • Pico G1 (GK7206)

          • Quick Start

            • Installation & First Inference
            • shimeta_infer — Image Inference
            • shimeta_camera — Real-time Camera Inference
            • SVP Scene Detection
            • File Transfer & Built-in Model Reference
            • FAQ
          • HTTP API & Python SDK

            • HTTP API Reference
      • Model Fine-tuning Platform

        • Introduction

          • Model Training Platform
        • Quick Start

          • Register & Login
          • Create Your First Model (30-Minute Quick Experience)
        • Training Guide

          • Data Preparation & Annotation
          • Training Parameter Configuration
          • Start & Monitor Training
          • Model Evaluation & Testing
        • Model Deployment

          • Export Model
          • Deploy to Edge Device

Windows Algo SDK

The Algo SDK is a software development kit designed specifically for EVS devices. It provides algorithm features and a simple operating model, helping developers easily integrate each feature.

Environment setup

Make sure the following required components are installed in your development environment:

  • Operating system: Windows 10 64-bit
  • Compiler: a C/C++ compiler for your operating system
  • Dependency libraries: make sure the necessary libraries are installed, plus OpenCV. We provide the OpenCV version matching the SDK; configure the environment variables yourself.
  • Development tools: an IDE such as Visual Studio 2019

Recommendation: use fully English paths for development.

Algo module overview

The Algo library is divided into three main modules:

  1. OpticalFlow

    • Function: an EVS-based optical-flow implementation.
  2. HandDetector

    • Function: an EVS-based hand detector implementation.
  3. HumanDetector

    • Function: an EVS-based person detector implementation.

Algo directory layout

  • bin directory: contains all core libraries and their dependencies

  • docs directory: contains the interface documentation

  • include directory: contains the interface header files

  • lib directory: contains the .lib files for all development libraries

  • models directory: contains the trained-model data

  • samples_cpp directory: contains simple samples for operating the device; running the samples requires an OpenCV environment

    Note: after compiling the samples, you must copy the models directory and the dynamic libraries under the bin directory to the same directory as the .exe executable.

1. OpticalFlow

This API is an EVS-based optical-flow implementation.

Of function

The Of function is the initialization constructor of the optical-flow class. Parameters:

    Of(
    uint16_t width,
    uint16_t height,
    uint8_t scale,
    uint8_t search_radius,
    uint8_t block_dimension);
  • width: the width of the EVS image.
  • height: the height of the EVS image.
  • scale: the EVS downsampling factor.
  • search_radius: the optical-flow search radius; 4 is generally recommended.
  • block_dimension: the image size used for the features involved in optical-flow computation; 21 is generally recommended — larger is more accurate but less efficient.

run function

The run function is the core function that runs the optical-flow algorithm. Parameters:

    int run(
    const cv::Mat& in_img,
    cv::Mat& out_img,
    uint8_t stack_nums = 1);
  • in_img: the EVS input image used to compute optical flow. Usually 0 means no event; 1 and 2 mean positive and negative events respectively.
  • out_img: the computed optical-flow image, represented by the CV_8SC2 type. The two channels of each pixel represent the x and y optical-flow magnitudes, and the sign indicates direction.
  • stack_nums: the number of EVS stacked frames, default 1 (no stacking); events are usually sparse and need stacking.

showOf function

The showOf function visualizes the optical-flow image produced by run as HVS-space arrows. Parameters:

    int showOf(
    cv::Mat& of_result,
    cv::Mat& of_mask,
	uint8_t ratio = 2,
    uint8_t step = 2);
  • of_result: the optical-flow image computed by run.
  • of_mask: the resulting optical-flow visualization of of_result.
  • ratio: how many times to scale up the visualized optical-flow arrows.
  • step: the sparse-sampling factor for the visualized optical-flow arrows.

Example

// 使用光流算法
#include <AlpOpticalFlow/Of.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <chrono>
#include <thread>
#include <ctime>
#include <regex>
#include <filesystem>
#include <fstream>

namespace fs = std::filesystem;
using  namespace ALP;

/**
 * @brief 用于存储和管理程序运行时所需的各种变量
 *
 * 该结构体包含处理 EVS 数据帧所需的成员变量,以及相关的线程和锁。
 */
struct SampleVar
{

    // 保护 EVS 数据帧列表的互斥锁
    std::mutex evs_mutex_;
    // 标记是否关闭数据处理
    bool is_close_ = false;
    // 播放 EVS 数据的线程
    std::unique_ptr<std::thread > evs_thread_;
    // 是否开启 EVS 数据存储
    bool is_evs_show_ = false;
    // evs 图像的宽度
    int evs_width_ = 768;
    // evs 图像的高度
    int evs_height_ = 608;

    std::string evs_image_dir_ = "C:/Users/SMTPC-0430/Desktop/Pic/EVS_RAW";//D:/TestData/Human/20250115161806780/evs_raw

    // 创建光流类
    std::shared_ptr<Of> optical_flow_ = nullptr;
};

std::shared_ptr<SampleVar> var_ = std::make_shared<SampleVar>();


/*
* @brief readRawImage 采用二进制方式读取 .raw 文件,并将其转换为 cv::Mat,以 8-bit 灰度格式解析数据。
*
* 直接使用 cv::imread 读取 .raw 文件会失败,因为它不是标准图片格式。
*
*/

cv::Mat readRawImage(const std::string& filename, int width, int height)
{
    std::ifstream file(filename, std::ios::binary);
    if (!file) {
        std::cerr << "ERROR: Cannot open file: " << filename << std::endl;
        return cv::Mat();
    }

    cv::Mat image(height, width, CV_8UC1); // 8-bit 单通道灰度图
    image *= 100;
    file.read(reinterpret_cast<char*>(image.data), width * height);

    if (file.gcount() != width * height) {
        std::cerr << "WARNING: File size mismatch: " << filename << std::endl;
        return cv::Mat();
    }

    return image;
}


/**
 * @brief 显示 EVS 图像界面(本地文件版本)
 *
 * 该函数创建一个新的线程来处理和显示本地存储的EVS图像文件。
 * 图像文件将按文件系统顺序循环读取,并计算/显示光流信息。
 */
void displayEVS()
{
    var_->evs_thread_ = std::make_unique<std::thread>([&]()
        {
            var_->is_evs_show_ = true;

            std::vector<std::string> image_files;
            for (const auto& entry : fs::directory_iterator(var_->evs_image_dir_)) {
                if (entry.path().extension() == ".raw") {
                    image_files.push_back(entry.path().string());
                }
            }

            if (image_files.empty()) {
                std::cerr << "ERROR: No image files found in " << var_->evs_image_dir_ << std::endl;
                var_->is_evs_show_ = false;
                return;
            }

            std::sort(image_files.begin(), image_files.end()); // 确保按顺序处理
            size_t frame_index = 0;
            const int frame_delay = 30;

            while (!var_->is_close_) {
                cv::Mat tem = readRawImage(image_files[frame_index], var_->evs_width_, var_->evs_height_);
                if (tem.empty()) {
                    frame_index = (frame_index + 1) % image_files.size();
                    continue;
                }

                cv::Mat out;
                if (!var_->optical_flow_->run(tem, out, 10)) {
                    cv::Mat of_mask;
                    var_->optical_flow_->showOf(out, of_mask, 10, 3);
                    cv::namedWindow("of", cv::WINDOW_FREERATIO);
                    cv::imshow("of", of_mask);
                    cv::waitKey(1);
                }

                frame_index = (frame_index + 1) % image_files.size();
                std::this_thread::sleep_for(std::chrono::milliseconds(frame_delay));
            }

            var_->is_evs_show_ = false;
        });
}




/**
 * @brief 关闭设备
 *
 * 该函数用于关闭 Eiger 设备,停止所有数据流,并释放相关资源。
 */
void closeDevice()
{
    // 等待 EVS 显示线程结束
    if (var_->evs_thread_)
    {
        var_->evs_thread_->join();
        var_->evs_thread_ = nullptr;
    }
}


int main(int argc, char* argv[])
{
    // 创建光流类
    var_->optical_flow_ = std::make_shared<Of>(var_->evs_width_, var_->evs_height_, 6, 4, 31);
    displayEVS();
    closeDevice();
    return 0;
}

Effect

of_flow

2. HandDetector

HandDetector function

This function constructs a HandDetector object with an initial hand-detector type. Parameters:

HandDetector(HandDetectorType type);
  • type: aps or evs Currently only supports HumanDetectorType::evs

detect function

Detects on the input image, then gets the result from boxes and landmarks. Parameters:

int detect  ( const cv::Mat & image,
  std::vector< cv::Rect > & boxes,
  std::vector< std::vector< cv::Point2f > > & landmarks ) ;
  • image: input image
  • boxes: the detected hand-box results
  • landmarks: the hand keypoints

init function

Initialization function. Parameters:

int init(const std::string& device="cpu");
  • cpu" or "cuda", defalut is "cpu"

Example

#pragma execution_character_set("utf-8")
/**********************************************
* 此样例为播放保存的evs raw数据          *
***********************************************/

//手势检测
#include <ALPML/HandDetector/hand_detector.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <chrono>
#include <thread>
#include <ctime>
#include <regex>
#include <filesystem>
#include <fstream>


namespace fs = std::filesystem;
using  namespace ALP;

/**
 * @brief 用于存储和管理程序运行时所需的各种变量
 *
 * 该结构体包含处理 APS 和 EVS 数据帧所需的成员变量,以及相关的线程和锁。
 */
struct SampleVar
{
    // 保护 EVS 数据帧列表的互斥锁
    std::mutex evs_mutex_;
    // 标记是否关闭数据处理
    bool is_close_ = false;
    // 播放 EVS 数据的线程
    std::unique_ptr<std::thread > evs_thread_;
    // 是否开启 EVS 数据存储
    bool is_evs_show_ = false;
    // evs 图像的宽度
    int evs_width_ = 768;
    // evs 图像的高度
    int evs_height_ = 608;
    // WriterFile类的智能指针
    const int play_evs_ = 2;
    // 创建手势检测
    std::shared_ptr<HandDetector> detector_ = nullptr;


    std::string evs_image_dir_ = "C:/Users/SMTPC-0430/Desktop/Pic/EVS_RAW";
};

std::shared_ptr<SampleVar> var_ = std::make_shared<SampleVar>();

/*
* @brief readRawImage 采用二进制方式读取 .raw 文件,并将其转换为 cv::Mat,以 8-bit 灰度格式解析数据。
*
* 直接使用 cv::imread 读取 .raw 文件会失败,因为它不是标准图片格式。
*
*/
cv::Mat readRawImage(const std::string& filename, int width, int height)
{
    std::ifstream file(filename, std::ios::binary);
    if (!file) {
        std::cerr << "ERROR: Cannot open file: " << filename << std::endl;
        return cv::Mat();
    }

    cv::Mat image(height, width, CV_8UC1); // 8-bit 单通道灰度图
    image *= 100;
    file.read(reinterpret_cast<char*>(image.data), width * height);

    if (file.gcount() != width * height) {
        std::cerr << "WARNING: File size mismatch: " << filename << std::endl;
        return cv::Mat();
    }

    return image;
}

/**
 * @brief 显示 EVS 图像界面
 *
 * 该函数创建一个新的线程来处理和显示 EVS 数据帧。
 * 在这个线程中,会从 `var_->evs_frames_` 列表中获取最新的 EVS 数据帧,
 * 并将其转换为 OpenCV 的 Mat 对象进行显示。
 */

void displayEVS()
{
    // 创建一个新的线程来处理 EVS 数据帧的显示
    var_->evs_thread_ = std::make_unique<std::thread>([&]()
        {
            // 开始存储EVS数据
            var_->is_evs_show_ = true;
            std::vector<std::string> image_files;
            for (const auto& entry : fs::directory_iterator(var_->evs_image_dir_)) {
                if (entry.path().extension() == ".raw") {
                    image_files.push_back(entry.path().string());
                }
            }

            if (image_files.empty()) {
                std::cerr << "ERROR: No image files found in " << var_->evs_image_dir_ << std::endl;
                var_->is_evs_show_ = false;
                return;
            }

            std::sort(image_files.begin(), image_files.end()); // 确保按顺序处理
            size_t frame_index = 0;
            const int frame_delay = 15;
            // 主循环,持续处理 EVS 数据直到关闭标志被设置
            while (!var_->is_close_)
            {
                // 获取互斥锁以保护 EVS 数据帧列表
                std::unique_lock<std::mutex> locker(var_->evs_mutex_);



                    const cv::Mat tem = readRawImage(image_files[frame_index], var_->evs_width_, var_->evs_height_);
                    if (tem.empty()) {
                        frame_index = (frame_index + 1) % image_files.size();
                        continue;
                    }

                    if (var_->detector_) {
                        std::vector<cv::Rect> box;
                        std::vector<std::vector<cv::Point2f>> landmarks;
                        cv::Mat image = tem;
                        var_->detector_->detect(image, box, landmarks);
                        cv::cvtColor(image, image, cv::COLOR_GRAY2BGR);
                        image *= 100;
                        for (size_t i = 0; i < box.size(); i++) {
                            cv::rectangle(image, box[i], cv::Scalar(0, 0, 255), 2);
                        }
                        for (auto& landmark : landmarks) {
                            for (auto& point : landmark) {
                                cv::circle(image, point, 2, cv::Scalar(0, 0, 255), 2);
                            }
                        }
                        cv::imshow("image", image);
                        cv::waitKey(25);
                    }
                    frame_index = (frame_index + 1) % image_files.size();


            }

            // 停止存储EVS数据
            var_->is_evs_show_ = false;
        });
}


/**
 * @brief 关闭设备
 *
 * 该函数用于关闭 Eiger 设备,停止所有数据流,并释放相关资源。
 */
void closeDevice()
{
    // 等待 EVS 显示线程结束
    if (var_->evs_thread_)
    {
        var_->evs_thread_->join();
        var_->evs_thread_ = nullptr;
    }
}

int main(int argc, char* argv[])
{
    // 创建手势检测
    var_->detector_ = std::make_shared<HandDetector>(HandDetectorType::evs);
    var_->detector_->init("cpu");
    // 启动显示 EVS 图像的线程
    displayEVS();
    closeDevice();
    return 0;
}

Effect

hand

3. HumanDetector

HumanDetector function

This function constructs a HumanDetector object with an initial detector type. Parameters:

HumanDetector(HumanDetectorType type);
  • type: aps or evs Currently only supports HumanDetectorType::evs

detect function

Inputs the image to detect, then gets the result from the boxes. Parameters:

int detect(const cv::Mat& image, std::vector<cv::Rect>& boxes);
  • image: input image
  • boxes: output detection boxes

init function

Initialization function. Parameters:

int init  ( const std::string & device = "cpu" )
  • device type:"cpu" or "cuda", defalut is "cpu"

Example

#pragma execution_character_set("utf-8")
/**********************************************
*  此样例为播放保存的evs raw数据          *
***********************************************/

// 人形检测
#include <AlpML/HumanDetector/human_detector.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <chrono>
#include <thread>
#include <ctime>
#include <regex>
#include <filesystem>
#include <fstream>


namespace fs = std::filesystem;
using  namespace ALP;

/**
 * @brief 用于存储和管理程序运行时所需的各种变量
 *
 * 该结构体包含处理 APS 和 EVS 数据帧所需的成员变量,以及相关的线程和锁。
 */
struct SampleVar
{
    // 保护 EVS 数据帧列表的互斥锁
    std::mutex evs_mutex_;
    // 标记是否关闭数据处理
    bool is_close_ = false;
    // 播放 EVS 数据的线程
    std::unique_ptr<std::thread > evs_thread_;
    // 是否开启 EVS 数据存储
    bool is_evs_show_ = false;
    // evs 图像的宽度
    int evs_width_ = 768;
    // evs 图像的高度
    int evs_height_ = 608;

    const int play_evs_ = 2;

    std::string evs_image_dir_ = "C:/Users/SMTPC-0430/Desktop/Pic/human/EVS_RAW";//D:/TestData/Human/20250115161806780/evs_raw C:/Users/SMTPC-0430/Desktop/Pic/human/EVS_RAW

    // 创建人形检测类
    std::shared_ptr<ALP::HumanDetector> detector_ = nullptr;
};

std::shared_ptr<SampleVar> var_ = std::make_shared<SampleVar>();

/*
* @brief readRawImage 采用二进制方式读取 .raw 文件,并将其转换为 cv::Mat,以 8-bit 灰度格式解析数据。
*
* 直接使用 cv::imread 读取 .raw 文件会失败,因为它不是标准图片格式。
*
*/
cv::Mat readRawImage(const std::string& filename, int width, int height)
{
    std::ifstream file(filename, std::ios::binary);
    if (!file) {
        std::cerr << "ERROR: Cannot open file: " << filename << std::endl;
        return cv::Mat();
    }

    cv::Mat image(height, width, CV_8UC1); // 8-bit 单通道灰度图
    image *= 100;
    file.read(reinterpret_cast<char*>(image.data), width * height);

    if (file.gcount() != width * height) {
        std::cerr << "WARNING: File size mismatch: " << filename << std::endl;
        return cv::Mat();
    }

    return image;
}

/**
 * @brief 显示 EVS 图像界面
 *
 * 该函数创建一个新的线程来处理和显示 EVS 数据帧。
 * 在这个线程中,会从 `var_->evs_frames_` 列表中获取最新的 EVS 数据帧,
 * 并将其转换为 OpenCV 的 Mat 对象进行显示。
 */
void displayEVS()
{
    // 创建一个新的线程来处理 EVS 数据帧的显示
    var_->evs_thread_ = std::make_unique<std::thread>([&]()
        {
            // 开始存储EVS数据
            var_->is_evs_show_ = true;

            var_->is_evs_show_ = true;
            std::vector<std::string> image_files;
            for (const auto& entry : fs::directory_iterator(var_->evs_image_dir_)) {
                if (entry.path().extension() == ".raw") {
                    image_files.push_back(entry.path().string());
                }
            }

            if (image_files.empty()) {
                std::cerr << "ERROR: No image files found in " << var_->evs_image_dir_ << std::endl;
                var_->is_evs_show_ = false;
                return;
            }

            std::sort(image_files.begin(), image_files.end()); // 确保按顺序处理
            size_t frame_index = 0;
            const int frame_delay = 15;
            // 主循环,持续处理 EVS 数据直到关闭标志被设置
            while (!var_->is_close_)
            {
                // 获取互斥锁以保护 EVS 数据帧列表
                std::unique_lock<std::mutex> locker(var_->evs_mutex_);



                const cv::Mat tem = readRawImage(image_files[frame_index], var_->evs_width_, var_->evs_height_);
                if (tem.empty()) {
                    frame_index = (frame_index + 1) % image_files.size();
                    continue;
                }

                if (var_->detector_)
                {
                    std::vector<cv::Rect> box;
                    cv::Mat image = tem;
                    var_->detector_->detect(image, box);
                    cv::cvtColor(image, image, cv::COLOR_GRAY2BGR);
                    image *= 100;
                    for (size_t i = 0; i < box.size(); i++)
                    {
                        cv::rectangle(image, box[i], cv::Scalar(0, 0, 255), 2);
                    }
                    cv::imshow("image", image);
                    cv::waitKey(25);
                }
                frame_index = (frame_index + 1) % image_files.size();


            }

            // 停止存储EVS数据
            var_->is_evs_show_ = false;
        });

}


/**
 * @brief 关闭设备
 *
 * 该函数用于关闭 Eiger 设备,停止所有数据流,并释放相关资源。
 */
void closeDevice()
{
    // 等待 EVS 显示线程结束
    if (var_->evs_thread_)
    {
        var_->evs_thread_->join();
        var_->evs_thread_ = nullptr;
    }

}


int main(int argc, char* argv[])
{
    // 创建手势检测
    var_->detector_ = std::make_shared<HumanDetector>(HumanDetectorType::evs);
    var_->detector_->init("cpu");
    // 启动显示 EVS 图像的线程
    displayEVS();
    closeDevice();
    return 0;
}

Effect

human

Edit this page on GitHub
Prev
Hybrid Vision Algo API