1360 views|4 replies

106

Posts

4

Resources
The OP
 

Based on the domestic automotive-grade processor T507-H development platform, how to implement image transmission and face recognition with 50 lines of Python code? [Copy link]

We tried the wireless image transmission function on the development board of Mir's domestically produced T507-H automotive-grade processor, and superimposed face recognition to detect whether there is a face in the video. This time we used a USB camera, which can be directly connected to the interface of the development board.

1. Connect the camera

After connecting the camera, use the command dmesg to see that the camera can be read. It is displayed as HIK 720p Camera

Next, use v4l to detect the detailed parameters of the camera.
Install v4l: sudo apt install v4l-utils

Use sudo v4l2-ctl --list-devices to view detailed information and device numbers

2. Face Recognition Using OpenCV

The recognition program used here borrows the code of this CSDN blogger https://blog.csdn.net/qianbin3200896/article/details/123643791

Before we begin, install a few libraries.
sudo apt update Complete update
sudo apt install python3-opencv
pip3 install --upgrade pip
pip3 install zmq
pip3 install pybase64

First, run the following program on the development board to read the camera data and send the data to the PC.

importcv2

importzmq

importbase64





defmain():

'''

主函数

'''

IP = '192.168.2.240'#上位机视频接受端的IP地址



# 创建并设置视频捕获对象

cap = cv2.VideoCapture(0)

print("open? {}".format(cap.isOpened()))

cap.set(cv2.CAP_PROP_FRAME_WIDTH, 320) # 设置图像宽度

cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240) # 设置图像高度



# 建立TCP通信协议

contest = zmq.Context()

footage_socket = contest.socket(zmq.PAIR)

footage_socket.connect('tcp://%s:5555'%IP)

Next, you need to receive the information from the development board on the PC, divide the video into frames, store and process them separately. When a face is recognized, it will be circled in red.
Open the anaconda prompt and run the following

importcv2

importzmq

importbase64

importnumpy asnp



defmain():

'''

主函数

'''

context = zmq.Context()

footage_socket = context.socket(zmq.PAIR)

footage_socket.bind('tcp://*:5555')

cv2.namedWindow('Stream',flags=cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO)





whileTrue:

print("监听中")

frame = footage_socket.recv_string() #接收TCP传输过来的一帧视频图像数据

img = base64.b64decode(frame) #把数据进行base64解码后储存到内存img变量中

npimg = np.frombuffer(img, dtype=np.uint8) #把这段缓存解码成一维数组

source = cv2.imdecode(npimg, 1) #将一维数组解码为图像source

# img=cv2.imread('1.png',1)

grayimg = cv2.cvtColor(source, cv2.COLOR_BGR2GRAY)

face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

faces = face_cascade.detectMultiScale(grayimg, 1.2, 5)

for(x, y, w, h) infaces:

cv2.rectangle(source, (x, y), (x + w, y + h), (0, 0, 255), 2)

cv2.imshow('frame', source)

ifcv2.waitKey(1) == ord('q'):

capture.release()

break



if__name__ == '__main__':

'''

程序入口

'''

main()

When working normally, it will keep printing and monitoring.

At this time, you can see the camera image in the pop-up window on the PC, and it can automatically recognize faces when they appear. However, there is a certain delay.

The MYD-YT507H development board was launched and sold by Mir Electronics in 2022. It is equipped with Allwinner's automotive-grade T507-H processor, which has ultra-high performance and rich peripheral resources. It is an excellent domestic industrial CPU platform. Under the shield is Allwinner's T507-H processor:

Mier MYD-YT507H Development Board

  • Integrated quad-core Cortex-A53, clocked at 1.5GHz, meets automotive AEC-Q100 test requirements;
  • Support 4K video encoding and decoding;
  • Supports four display output interfaces: LVDS, HDMI, RGB and CVBS;
  • Supports dual-screen same display, dual-screen different display, supports MIPI CSI, DVP camera input; provides smooth user experience and professional visual effects.
  • Equipped with 1GB DDR4 memory and 8GB eMMC;
  • The development board has a wealth of peripheral expansions: SD card slot, dual-channel network port, 4 USB2.0 interfaces, 1 SPI, 2 SDIO;
  • The operating temperature range of industrial-grade boards is -40°C - +85°C;
  • The core board is designed with stamp holes.

Mir Electronics is a high-tech enterprise focusing on the design, development, production and sales of embedded processor modules. Mir Electronics has more than 10 years of R&D experience in the field of embedded processors, providing customers with products and services such as CPU modules and charging control systems based on ARM architecture and FPGA architecture; providing customized solutions and OEM services for customers in industries such as smart medical care, smart transportation, smart security, Internet of Things, edge computing, industrial gateways, and artificial intelligence. The company helps customers accelerate the process of product launch through professional and efficient services, and currently serves more than 10,000 corporate customers in the industry.

This post is from Programming Basics

Latest reply

I hope that domestic chips will become stronger and stronger  Details Published on 2023-4-2 06:18
Personal signature

米尔电子,专注嵌入式处理器

 

210

Posts

3

Resources
2
 

As long as it is domestically made, we must support it. I hope that domestic enterprises will respect each other and vigorously adopt domestic chips. If we are all well developed, others will not be able to strangle us.

This post is from Programming Basics
 
 
 

4771

Posts

12

Resources
3
 

This board has so many interfaces. Awesome!

This post is from Programming Basics
 
 
 

6841

Posts

11

Resources
4
 
When using OpenCV for face recognition, is the recognition rate high? Can the data be used for comparison?
This post is from Programming Basics
 
 
 

2

Posts

0

Resources
5
 

I hope that domestic chips will become stronger and stronger


This post is from Programming Basics
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list