Face Detection Face Recognition artificial intelligence APP-

Recently, artificial intelligence is very hot, more and more kinds of applications. AI APP

AI requires a lot of data as a fuel, but also requires a lot of computation, it gives people a feeling of inscrutable.

In fact, AI is not elusive, because many companies have provided API, multi-layered process they are resolved, we need only call the result, the use of artificial intelligence is achievable popularization.

We can also take advantage of the use of APP Inventor API or combination of various types of plug-ins (aix), making APP smarter, is worthy of our inquiry!

Face Detection Face        AIA and source material      aix extension assembly

It is the use of plug-in components FaceDetection, the selected image upload to the server is detected, and returns the result (JSON data).

APP JSON then utilizing the returned data, draw lines, and so the recognition result.

Import project A_SimpleFaceDetect1_0.aia in AI2 platform, view programming.

1, application plug-ins

The download extract obtained aix extension component cn.edu.scut.cs.mlx.aix app inventor introduced into the project.

  

 

2. An assembly method of a list

3, upload pictures

Path 1. Use the image selection frame components such as acquiring JPG format image file
2. Call UploadAndUseImage, upload images to a server
3. After uploading the end, produce ImageUploadFinished event, then you can obtain the URL of an image by GetUploadedImageURL. If the URL is empty, then upload failed.

Note: The uploaded image must be in JPG format and size <5MB.

If the condition is not satisfied, the format conversion may be canvas, or the widget image processing TaifunImage reduce the image.

4, the detection result of the processing

(1) 索引值index从1开始。
(2)GetDetectionBox返回的是一个四项的列表,包含物体包围框的左上角坐标(xmin, ymin)和右下角坐标(xmax, ymax)。四个数字范围都在[0, 1]之间。
(3) GetDetectionEncoding返回一个128维向量,可用于比较人脸的相似度。
(4)GetDetectionLandmarkPositions返回坐标(x, y)的列表, 范围在[0, 1]之间。

5、获得的原始JSON数据

(1)使用RawJSONData方法获取原始JSON数据。每一张检测到的人脸都有location, landmark和encoding数据。

 

[

   {

        "location": [

            0.4280155642023346,

            0.350187265917603,

            0.5680933852140078,

            0.552434456928839

        ],

        "landmark": {

            "top_lip":[

                [0.47470817120622566,0.4850187265917603],

                [0.48378728923476005,0.4794007490636704],

                ...

            ],

            "nose_tip":[...],

            "nose_bridge":[...],

            ...

        },

        "encoding": [

            -0.09882616251707077,

            0.03372788056731224,

            0.0321364663541317,

            -0.04331062361598015,

            -0.15623915195465088,

            -0.031561896204948425,

            -0.021884676069021225,

            -0.051772814244031906,

            0.17310640215873718,

            -0.16299796104431152,

            0.10914535820484161,

            ...

        ]

   },

   ...

]

 

(2)location为人脸包围框的坐标数据。


按顺序为左上坐标和右下坐标。
坐标0.4280155642023346等是归一化后的结果,可以分别乘上
图像的宽和高,得到以像素为单位的实际坐标。

(3)landmark为器官位置坐标数据,每一个器官有坐标列表:

"landmark": {
    "top_lip": [
        [0.47470817120622566, 0.4850187265917603],
        [0.48378728923476005, 0.4794007490636704],
        ...
    ],
    "nose_tip": [...],
    "nose_bridge": [...],
    ...
},

坐标0.47470817120622566, 0.4850187265917603等是归一化后的结果,可以分别乘上图像的宽和高,得到以像素为单位的实际坐标。

6、将相应的数据在画布上画线,绘制出检测的结果

绘制五官轮廓效果

绘制人脸位置方框

练习任务:

理解程序逻辑设计代码,尝试修改实现:在下方的画布2显示绘制人脸的轮廓线条。

Guess you like

Origin www.cnblogs.com/eduit/p/12111950.html