OpenCV Pedestrian Detection Application Solution Based on MYIR's T527 Development Board
2025-06-17
303
In this article, we will introduce the testing of OpenCV pedestrian detection solution based on MYIR's MYD-LT527 Development Board (based on Allwinner T527 processor).

MYD-LT527 Development Board Top-view

MYD-LT527 Development Board Bottom-view
1. Software Environment Installation
1.1 Install OpenCV
sudo apt-get install libopencv-dev python3-opencv

1.2 Install pip
sudo apt-get install python3-pip

2. Introduction to Pedestrian Detection
The key steps in building the pedestrian detector using HOG and SVM include:
Prepare Training Dataset: the training dataset should contain large number of positive samples (pedestrian images) and negative samples (non-pedestrian images).
Compute HOG Feature: for each image, compute HOG feature. HOG feature is a one-dimensional vector where each element represents the gradient intensity at a specific location and direction in the image.
Train SVM Classifier: using the HOG feature as input, train the SVM classifier which will learn to distinguish between pedestrians and non-pedestrians.
Evaluate the Model: evaluate the trained model using the test dataset. Calculate metrics such as accuracy, recall and F1 score of the model.
3. Code Implementation
import cv2
import time
def detect(image,scale):
imagex=image.copy( ) # Make a copy of the function internally so that each function runs on a different image;
hog = cv2.HOGDescriptor( ) # Initialization direction gradient histogram description;
#Set up the SVM as a pre-trained pedestrian detector;
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector( ));
# Invoke the function detectMultiScale to detect the corresponding border of the pedestrian;
time_start=time.time( );# Record start time;
# Access (rectangular boxes corresponding to pedestrians, corresponding weights);
(rects, weights) = hog.detectMultiScale(imagex,scale=scale);
time_end = time.time( ) # Record end time;
# Draw each rectangular box;
for(x, y, w, h) in rects:
cv2.rectangle(imagex, (x, y), (x+w, y+h), (0, 0, 255), 2)
print("sacle size:", scale, ",time:", time_end-time_start)
name=str(scale)
cv2.imshow(name; imagex) # Show original effect
image = cv2.imread("back.jpg")
detect(image,1.01)
detect(image,1.05)
detect(image,1.3)
cv2.waitKey(0)
cv2.destroyAllWindows( )
4. Practical Operations


2025-11-27
SECC GreenPHY Solution: Bridging STM32MP135 SOM to V2G Industry Advancement
Debug MSE102x G on MYC-YF13X, providing reference for V2G communication development.
2025-11-20
SECC Solution for Charging Pile Applications
MYIR's SECC solution delivers a high-standard, low-risk rapid development platform for clients, with core strengths in protocol compatibility, operational security, and a comprehensive reference design.
2025-11-02
Simultaneous Control of 4 YOLOv8 Video Streams via MYIR's RK3576 Board
In the era of rapid technological advancement, the integration of artificial intelligence and edge computing is transforming our lives at an unprecedented pace. The RK3576 processor features a quad-co
2025-09-20
Compiling OpenCV and Developing Applications on the RK3576 Board
This article introduces how to compile OpenCV on the RK3576 development board and build an application.
2025-08-30
MYIR T536 Development Board: Multi-protocol IoT Gateway Solution Test
The article details the development and testing of a multi-protocol IoT gateway solution that utilizes MYIR's MYD-LT536 development board, which is based on the Allwinner T536 SoC.
2025-08-29
MYIR RK3576 Development Board: 12-Channel 1080p HD Video Streaming
MYIR has successfully achieved efficient H.264 encoding and low-latency RTSP streaming for 12-channel HD video streams on the Rockchip RK3576 SOM.
2025-08-07
Compiling Kernel for MYD-LMX9X Development Board
This guide walks you through building a Linux kernel for the MYIR MYD-LMX9X Development Board
2025-06-23
RZ/G2L-Based MYD-YG2LX System Startup Time Optimization Application Notes
This article introduces a debugging case for optimizing system boot time based on the MYD-YG2LX development board.
2025-06-23
How to Implement an Environmental Monitoring System on the STM32MP257 Board
This article introduces how to use MYIR's MYD-LD25X development board (MYIR's STM35MP257-based development board) to implement a simple environmental monitoring system.