This review is provided by the excellent reviewer "eefocus_3914144" of eefocus.com.
This article will introduce the test of the OpenCV-based face detection solution based on the Mir Electronics MYD-LMX93 development board (Mir is based on the NXP i.MX93 development board).
OpenCV provides a very simple interface for capturing a video with a camera (I use the built-in camera on my computer)
1. Install python3-opencv
apt install python3-opencv
2. Check the formats and resolutions supported by the camera
root@debian:~# v4l2-ctl --device=/dev/video0 --list-formats-ext
After testing, it can only support 640*480
For this create opencv_test.py
import cv2
video = cv2.VideoCapture(0)
Set camera parameters
video .set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
video .set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
while True:
ret, frame = video.read()
cv2.imshow("A video", frame)
c = cv2.waitKey(1)
if c == 27:
breakvideo.release()cv2.destroyAllWindows()
Save and execute "python3 opencv_test.py
After OpenCV is installed, it can provide feasibility for the subsequent face detection.
To realize the face recognition function, we must first perform face detection and determine the position of the face in the picture before proceeding to the next step.
OpenCV face detection method
In OpenCV, two features (i.e. two methods) are mainly used for face detection, Haar feature and LBP feature. Haar feature face detection is the most commonly used. In addition, OpenCV also integrates deep learning methods to achieve face detection.
【References】
Use the OpenCV toolkit to successfully implement face detection and face recognition, including traditional vision and deep learning methods (with complete code, model download...)_opencv face recognition-CSDN blog
[Haar cascade detector pre-trained model download]
opencv/opencv: Open Source Computer Vision Library (github.com)
After downloading, there is a model in the opencv-4.xdatahaarcascades folder. Upload it to the development board.
[Get the image for face detection]
I found the ** picture on Baidu and uploaded it to the development board.
【Write detection code】
import numpy as np
import cv2 as cv
if __name__ == '__main__':
# (6) Use the Haar cascade classifier pre-trained model to detect faces
# Read the image to be detected
img = cv.imread("yanmi.jpg")
print(img.shape)
# Load the Haar cascade classifier pre-trained model
model_path = "haarcascade_frontalface_alt2.xml"
face_detector = cv.CascadeClassifier(model_path) #
# Detect faces using cascade classifier
faces = face_detector.detectMultiScale(img, scaleFactor=1.1, minNeighbors=1,
minSize=(30, 30), maxSize=(300, 300))
print(faces.shape) # (17, 4)
print(faces[0]) # (x, y, width, height)
# Draw the face detection frame
for x, y, width, height in faces:
cv.rectangle(img, (x, y), (x + width, y + height), (0, 0, 255), 2, cv.LINE_8, 0)
# Display the image
cv2.imshow("faces", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
[Experimental results]
After running the program, it can be correctly identified, and the effect is as follows:
Previous article:Infineon Technologies SECORA™ Pay Bio Enhances Convenience and Trust in Contactless Biometric Payments
Next article:最后一页
- Popular Resources
- Popular amplifiers
- e-Network Community and NXP launch Smart Space Building Automation Challenge
- The Internet of Things helps electric vehicle charging facilities move into the future
- Nordic Semiconductor Launches nRF54L15, nRF54L10 and nRF54L05 Next Generation Wireless SoCs
- Face detection based on camera capture video in OPENCV - Mir NXP i.MX93 development board
- The UK tests drones equipped with nervous systems: no need to frequently land for inspection
- The power of ultra-wideband: reshaping the automotive, mobile and industrial IoT experience
- STMicroelectronics launches highly adaptable and easy-to-connect dual-radio IoT module for metering and asset tracking applications
- This year, the number of IoT connections in my country is expected to exceed 3 billion
- Infineon Technologies SECORA™ Pay Bio Enhances Convenience and Trust in Contactless Biometric Payments
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Keithley SourceMeter - One Test Instrument Compares to Five
- Tomorrow's live broadcast: The development and latest applications of sensors in industrial motors. Make an appointment now to get 2 chances to win a prize draw.
- What happened to LoRa?
- A brief discussion on the design of switch quantity acquisition circuit and the solution to AC interference problem
- ADI New Chinese Information (July 2019)
- STM32L151RCT6 cannot enter low power after downloading the program
- The CC2541 is connected to the Bluetooth module, but the Bluetooth module cannot receive the data it sends.
- Set the maximum FM bandwidth to 4GHZ
- Selection of digital input chips such as liquid level switches
- 【NXP Rapid IoT Review】+ Unboxing Review