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.

64 lines
2.4 KiB

/*
* @Descripttion:
* @version:
* @Author: sueRimn
* @Date: 2022-04-28 10:41:42
* @LastEditors: sueRimn
* @LastEditTime: 2022-04-28 15:32:49
*/
/*
* 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 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 int CalHj(const cv::Mat &img, const cv::Mat &mask, cv::Rect &rect,int exp = 50);
static int printROI(cv::Rect roi, std::string str = "");
static bool RoiInImg(cv::Rect roi, cv::Mat img);
static int getBlobLength(cv::Rect roi, float scale);
static int AlignImg(cv::Mat searchImg, cv::Mat KernelImg, cv::Point &AlignP);
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::Rect findMaxBoundingBox(const cv::Mat &binaryImage);
static cv::RotatedRect findMaxBoundingMinBox(const cv::Mat &binaryImage);
static bool pathExists(const std::string &path);
static std::string splitFilePath(const std::string &fullPath);
static int MatchImg(cv::Mat img, cv::Mat templ, cv::Point &reuslt);
static cv::RotatedRect UpdataRotatedRect(cv::RotatedRect oldRrect, int start_x, int start_y, float fscale_x, float fscale_y);
static int adjustRectToBounds(cv::Rect &rect, const cv::Size &imgSize);
static double point2fDistance(const cv::Point2f &p1, const cv::Point2f &p2); // 1107-add
static cv::Point getCenterPoint(cv::Rect rect);//0922-add
};
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_