派生自 Algorithm/baseDetector

Scheaven
2021-07-22 21b7b5dc0884254080499ea2136e53041c813ec6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// Created by Scheaven on 2020/4/23.
//
 
#include "draw_util.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include "log_util.h"
#include <opencv2/opencv.hpp>                   // C++
 
using namespace cv;
using namespace std;
 
 
void create_foldert(const char *path)
{
    // if(access(path, 0) == -1)
    // {
    //     int flag = mkdir(path,0777);
    //     if(flag==0)
    //     {
    //         DEBUG( ":::::::::create folder!::::::");
    //     }else
    //     {
    //         DEBUG( ":::::::::create folder! error!::::::");
    //     }
    // }
    DEBUG("=2==create_path:")
    char DirName[256];
    strcpy(DirName,path);
    int i,len = strlen(DirName);
    if(DirName[len-1]!='/')
    strcat(DirName,"/");
    len = strlen(DirName);
    for(i=1;i<len;i++)
    {
        if(DirName[i]=='/')
        {
            // DirName[i] = 0;
            // if(access(DirName,NULL) != 0)
            // {
            //    if(mkdir(DirName,0777) == -1)
            //    {
            //        perror("mkdir error");
            //    }
            // }
            DEBUG("=1==create_path:")
            int a = access(DirName, F_OK);
            if(a ==-1)
            {
                mkdir(DirName,0755);
            }
            DirName[i] = '/';
         }
     }
}
 
void save_human_img(cv::Mat aaaa, string path, int type, string name)
{
    // aaaa.convertTo(aaaa, CV_8UC3, 255.0f);
    // cv::cvtColor(aaaa, aaaa, cv::COLOR_RGB2BGR); // 颜色空间需要确认一下Z
    string file_path ="./02_humanID/"+ path +"/";
    create_foldert(file_path.c_str());
    cv::imwrite(file_path + name + "_" + to_string(type) + ".jpg", aaaa);
}
 
void draw_SDK_result(cv::Mat mat_img, Target& target)
{
    cv::Rect tmp_rect = cv::Rect(target.rect.left,target.rect.top,target.rect.right-target.rect.left,target.rect.bottom-target.rect.top);
    cv::rectangle(mat_img, tmp_rect , cv::Scalar(50, 200, 50), 2);
    // cv::resize(mat_img, mat_img, frameSize);
    // cv::imwrite("1111.jpg", mat_img);
    cv::imshow(to_string(1), mat_img);
    cv::waitKey(0);
}