"test/srt/openai_server/basic/test_openai_server.py" did not exist on "8b39274e3429c7813a5459d06b02cc032e8cb116"
main.cpp 1.66 KB
Newer Older
Your Name's avatar
Your Name committed
1
2
3
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
liucong's avatar
liucong committed
4
5
6
#include <SimpleLog.h>
#include <Filesystem.h>
#include <RetinaFace.h>
Your Name's avatar
Your Name committed
7

liucong's avatar
liucong committed
8
int main()
Your Name's avatar
Your Name committed
9
{
liucong's avatar
liucong committed
10
11
12
13
    // 创建RetinaFace检测器
    migraphxSamples::DetectorRetinaFace detector;
    migraphxSamples::InitializationParameterOfDetector initParamOfDetectorRetinaFace;
    initParamOfDetectorRetinaFace.configFilePath = CONFIG_FILE;
liucong's avatar
liucong committed
14
15
    migraphxSamples::ErrorCode errorCode = detector.Initialize(initParamOfDetectorRetinaFace);
    if(errorCode != migraphxSamples::SUCCESS)
Your Name's avatar
Your Name committed
16
    {
liucong's avatar
liucong committed
17
18
        LOG_ERROR(stdout, "fail to initialize detector!\n");
        exit(-1);
Your Name's avatar
Your Name committed
19
    }
liucong's avatar
liucong committed
20
21
22
    LOG_INFO(stdout, "succeed to initialize detector\n");

    // 读取测试图片
liucong's avatar
liucong committed
23
    cv::Mat srcImage = cv::imread("../Resource/Images/FaceDetect.jpg", 1);
liucong's avatar
liucong committed
24
25
26

    // 推理
    std::vector<migraphxSamples::ResultOfDetection> predictions;
liucong's avatar
liucong committed
27
    detector.Detect(srcImage, predictions);
liucong's avatar
liucong committed
28
29

    // 获取推理结果
liucong's avatar
liucong committed
30
31
    LOG_INFO(stdout, "========== Detection Results ==========\n");
    for(int i = 0; i < predictions.size(); ++i)
Your Name's avatar
Your Name committed
32
    {
liucong's avatar
liucong committed
33
34
35
36
37
38
39
40
41
42
43
        migraphxSamples::ResultOfDetection result = predictions[i];
        cv::rectangle(srcImage, result.boundingBox, cv::Scalar(0, 255, 255), 2);

        LOG_INFO(stdout,
                 "box:%d %d %d %d,label:%d,confidence:%f\n",
                 predictions[i].boundingBox.x,
                 predictions[i].boundingBox.y,
                 predictions[i].boundingBox.width,
                 predictions[i].boundingBox.height,
                 predictions[i].classID,
                 predictions[i].confidence);
Your Name's avatar
Your Name committed
44
    }
liucong's avatar
liucong committed
45
46
    cv::imwrite("Result.jpg", srcImage);
    LOG_INFO(stdout, "Detection results have been saved to ./Result.jpg\n");
liucong's avatar
liucong committed
47

Your Name's avatar
Your Name committed
48
49
    return 0;
}