You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Cigarette/CigaretteSingle/AlgCommon.h

32 lines
1.2 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/types_c.h>
#define NOMINMAX
#include <windows.h>
#include <string>
//保护rect边界防止越界访问造成程序崩溃
bool protectRect(cv::Rect& rect, int width, int height);
//显示中文
void GetStringSize(HDC hDC, const char* str, int* w, int* h);
void putTextZH(cv::Mat& dst, const char* str, cv::Point org, cv::Scalar color, int fontSize,
const char* fn = "Arial", bool italic = false, bool underline = false);
//显示英文文本在某个角落
void putTextCorner(cv::Mat& image, std::string text, cv::Scalar color, int where);
//先腐蚀后膨胀
void fistEROthenDIL(cv::Mat& input, uint8_t EROsize,uint8_t DILsize);
//先膨胀后腐蚀
void fistDILthenERO(cv::Mat& input, uint8_t DILsize, uint8_t EROsize);
//判断矩形1是否在矩形2中
bool isInside(cv::Rect rect1, cv::Rect rect2);
//获得矩形中点
cv::Point getCenterPoint(cv::Rect rect);
//扩大矩形范围
cv::Rect rectCenterScale(cv::Rect rect, cv::Size size);
//rgb2cmyk
cv::Mat rgb2cmyk(cv::Mat& rgb);
bool sort_rect_by_x_center(cv::Rect r1, cv::Rect r2);
bool sort_rect_by_height(cv::Rect r1, cv::Rect r2);
bool sort_rect_by_y_center(cv::Rect r1, cv::Rect r2);
bool sort_rect_by_width(cv::Rect r1, cv::Rect r2);