//
|
// 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);
|
}
|