2524 views|4 replies

382

Posts

9

Resources
The OP
 

R329 Development Board Application - Operation Image (2) [Copy link]

 

R329 development board application - operation image ( 2 )

In the previous post ( https://bbs.eeworld.com.cn/thread-1181408-1-1.html ), we have successfully sent the image to the small screen on the board. This post will implement Baidu AI processing.

  • What can AI do?

This R329 development board supports the network, so we can consider implementing AI functions from both local and network aspects . Considering the popularity, Baidu AI is selected as the network implementation. Baidu AI can recognize faces based on pictures and infer age, appearance, face shape, etc. Here we only quote the coordinates of the face.

  • accomplish

First, use your Baidu account to apply for the AI application interface. After a successful application, you can obtain the AppID, API Key, and Secret Key . Then calculate the application token based on the API key and Secret Key , and then apply this token to the web request. The response contains information such as the number of faces recognized and the location of the face.

Compared with the previous code, only a small section of code for base64 conversion of the image and network access is inserted, and it is not expanded. One thing that is a bit tricky is that I don’t know how to directly generate base64 code from the image in cv2 , but save it as a temporary file and then read the file in the local path, which feels a bit awkward.

As mentioned in the previous article, if the camera is above the screen, the image read will be inverted, and Baidu AI will automatically rotate the image 180 degrees before recognition, so the returned value of x and y will be at the bottom right of the image we need to recognize, while w and h will extend to the upper left. When writing the code frame, you should use xw and yh .

When cv2 is drawing, the coordinates must be identified as integers ( int ), otherwise an error will be prompted. Therefore, when using the cv2.rectangle command to draw, you need to use int(x) , int(y) , int(xw) , int(yh) for forced conversion.

Due to Baidu's restrictions, fast real-time recognition is not possible, so a restriction condition is added. When the number of recognized faces in the same frame reaches 3 (or more), the current image is saved and the program is interrupted.

  • result

As described in "Operating Images ( 1 )" ( https://bbs.eeworld.com.cn/thread-1181408-1-1.html ), enter echo -e "\033[?25l" > /dev/tty0 in the terminal command line to cancel the prompt cursor. Point the camera at a random photo of a person on the Internet, and the camera content can be displayed on the screen. At the same time, the face of the person in the picture can be identified

Attached is a large screen image:

Here, we take out the temporary file, which is an inverted picture.

At the same time, we can see that it takes about 0.5 seconds to process each frame of the image . On the one hand, this is due to network reasons. On the other hand, the efficiency of cv2 drawing is also one of the limitations.

In addition to real people, we also tried cartoon characters, which is also acceptable.

This post is from Domestic Chip Exchange

Latest reply

You need to save it as a temporary file first, and then read the file from the local path. It's really a pit   Details Published on 2021-10-5 19:10
 
 

9717

Posts

24

Resources
2
 

Doesn’t Baidu AI give any prompt in the data returned after automatically rotating the picture?

This post is from Domestic Chip Exchange

Comments

No, I use addition for normal pictures, but I get the pictures from the camera right by subtracting them, I have tried many times.  Details Published on 2021-10-5 16:55
 
 
 

382

Posts

9

Resources
3
 
littleshrimp posted on 2021-10-5 08:57 Doesn't Baidu AI give any prompts in the data returned after automatically rotating the picture?

No, I use addition for normal pictures, but I get the pictures from the camera right by subtracting them, I have tried many times.

This post is from Domestic Chip Exchange

Comments

If you don't know that the image you sent is reversed, can you tell from the returned data that he rotated the image?  Details Published on 2021-10-5 18:33
 
 
 

9717

Posts

24

Resources
4
 
tobot posted on 2021-10-5 16:55 No, I use addition for normal pictures, but I use subtraction for camera pictures, and it’s correct. I tried it many times.

If you don't know that the image you sent is reversed, can you tell from the returned data that he rotated the image?

This post is from Domestic Chip Exchange
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 
 

1668

Posts

0

Resources
5
 

You need to save it as a temporary file first, and then read the file from the local path.

It's really a pit

This post is from Domestic Chip Exchange
 
 
 

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