You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.8 KiB
79 lines
2.8 KiB
/*
|
|
* @Descripttion:
|
|
* @version:
|
|
* @Author: sueRimn
|
|
* @Date: 2022-04-28 10:41:42
|
|
* @LastEditors: xiewenji 527774126@qq.com
|
|
* @LastEditTime: 2025-08-03 21:32:02
|
|
*/
|
|
/*
|
|
* FileName:CoreLogicFactory.hpp
|
|
* Version:V1.0
|
|
* Description:
|
|
* Created On:Mon Sep 10 11:13:13 UTC 2018
|
|
* Modified date:
|
|
* Author:Sky
|
|
*/
|
|
#ifndef _CheckUtil_HPP_
|
|
#define _CheckUtil_HPP_
|
|
#include <iostream>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sys/time.h>
|
|
#include <mutex>
|
|
#include <vector>
|
|
#include <thread>
|
|
#include <opencv2/opencv.hpp>
|
|
using namespace std;
|
|
class CheckUtil
|
|
{
|
|
public:
|
|
static long getcurTime();
|
|
static std::string getCurrentDate();
|
|
static std::string getCurTimeHMS();
|
|
static std::string Op_float2String(float nvalue);
|
|
static int64_t getSnowId();
|
|
static bool JudgRect(cv::Rect roi, int img_w, int img_h);
|
|
static bool JudgRect_SZ(cv::Rect roi, int w, int h);
|
|
static bool compareIgnoreCase(const std::string &str1, const std::string &str2);
|
|
static bool RoiInImg(cv::Rect roi, cv::Mat img);
|
|
static int printROI(cv::Rect roi, std::string str = "");
|
|
static float CalIoU(cv::Rect rect1, cv::Rect rect2);
|
|
static float CalIoU_t(cv::Rect rect1, cv::Rect rect2);
|
|
static int CheckRect(cv::Rect &roi, int img_w, int img_h);
|
|
static int SizeRect(cv::Rect &roi, int img_w, int img_h, int addw, int addh);
|
|
static int CalHj(const cv::Mat &img, const cv::Mat &mask, int b_value);
|
|
static int CalHj(const cv::Mat &img, const cv::Mat &mask, const cv::Mat &backgroundimg);
|
|
static float CalRoi2RoiPre(cv::Rect rect1, cv::Rect rect2);
|
|
// 计算平均灰度
|
|
static float CalImgBrightness(cv::Mat imgRoi);
|
|
// 计算角度
|
|
static float Cal2PointAngle(cv::Point p_left, cv::Point p_right);
|
|
|
|
// 找图片的最大外轮廓
|
|
static cv::Rect getLargestContourROI(const cv::Mat &binaryImg, bool &found);
|
|
|
|
static std::string GetRectString(cv::Rect rect);
|
|
// 创建目录
|
|
static int CreateDir(const std::string &dir);
|
|
|
|
// 点的距离是否过小
|
|
static bool bcalDis(cv::Point p1, cv::Point p2, int disT);
|
|
static double calDis(cv::Point2f p1, cv::Point2f p2);
|
|
static void PrintRect(cv::Rect roi, std::string str = "");
|
|
static int cutSmallImg(cv::Mat img, std::vector<cv::Rect> &samllRoiList, cv::Rect config_roi, int config_SmallImg_Width, int config_SmallImg_Height, int config_MinOverlap_Width, int config_MinOverlap_Height);
|
|
static cv::Point2f transformPoint(const cv::Point2f &point, const cv::Mat &transform_matrix);
|
|
};
|
|
template <typename... Args>
|
|
static std::string str_Format(const std::string &format, Args... args)
|
|
{
|
|
auto size_buf = std::snprintf(nullptr, 0, format.c_str(), args...) + 1;
|
|
std::unique_ptr<char[]> buf(new (std::nothrow) char[size_buf]);
|
|
|
|
if (!buf)
|
|
return std::string("");
|
|
|
|
std::snprintf(buf.get(), size_buf, format.c_str(), args...);
|
|
return std::string(buf.get(), buf.get() + size_buf - 1);
|
|
}
|
|
#endif //_CORELOGICFACTORY_HPP_
|