//
|
// 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(1);
|
}
|
|
cv::VideoWriter writer("./01_baseDetector.avi", cv::VideoWriter::fourcc('M','J','P','G'),24, cv::Size(800,500), true);
|
// cv::VideoWriter writer("/opt/vasystem/valog/01_Scheanve/01_baseDetector.avi", cv::VideoWriter::fourcc('M','J','P','G'),24, cv::Size(800,500), true);
|
|
void draw_SDK_result(const int cam_id, cv::Mat mat_img, TResult* t_result)
|
{
|
cv::Rect tmp_rect;
|
|
for (int i = 0; i < t_result->count; ++i)
|
{
|
auto &result = t_result->targets[i];
|
tmp_rect = cv::Rect(result.rect.left,result.rect.top,result.rect.right-result.rect.left,result.rect.bottom-result.rect.top);
|
cv::rectangle(mat_img, tmp_rect , cv::Scalar(50, 200, 50), 2);
|
// cv::putText(mat_img, std::to_string(result.id), Point((result.rect.left+result.rect.right)/2,result.rect.top+150), CV_FONT_HERSHEY_SIMPLEX, 0.8, Scalar(255,255,0), 2);
|
}
|
// delete tmp_rect;
|
cv::resize(mat_img, mat_img, cv::Size(800,500));
|
// cv::imwrite("1111.jpg", mat_img);
|
// cv::imshow("RESULT", mat_img);
|
writer<< mat_img;
|
// cv::waitKey(0);
|
}
|