49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
#pragma once
|
|
#include "opencv2/opencv.hpp"
|
|
#include <string>
|
|
#include <set>
|
|
#include "afxctl.h"
|
|
|
|
class MicroImage {
|
|
public:
|
|
MicroImage();
|
|
|
|
~MicroImage();
|
|
|
|
void CalDistance();
|
|
|
|
void StandardLineDetect(); //(0.2mm)标准线段检测
|
|
|
|
//void RealLengthDetect(); //可以 时间比较长 15s左右
|
|
|
|
//int StatisticsPixel(); //第一版
|
|
|
|
void Init(const BITMAP& bmp);
|
|
static std::string GetStrTime();
|
|
private:
|
|
void StatisticsBGColor();
|
|
void StatisticsRGB(cv::Mat& cropMat);
|
|
void SquareRemove();
|
|
void IsLandRemove();
|
|
void CalBorderCrop(int& dx, int& dy);
|
|
void CropByBorder(int yBegin, int yEnd, int xBegin, int xEnd);
|
|
bool IslandCheck(int y, int x, std::set<int>& tempSet); //判断是否是孤岛噪点,四周被黑色包围
|
|
bool IsBlack(int y, int x);
|
|
void DrawRedLine(int length, int x, int y); //画一红色线段
|
|
|
|
public:
|
|
int m_width; //图片宽
|
|
int m_height; //图片高
|
|
uchar* m_OriginData; //图片原始数据
|
|
uchar* m_CalData; //计算后数据
|
|
std::string m_ImgName; //图片名称
|
|
float m_DistanceX; //x方向上的距离
|
|
float m_DistanceY; //y方向上的距离
|
|
uint m_TotalSize; //图片大小
|
|
private:
|
|
cv::Mat m_image; //图片
|
|
int m_knowLength = 148; //已知0.2mm占用的像素个数 先固定
|
|
std::set<int> m_RgbSet; //背景rgb集合
|
|
|
|
float m_Radio; //宽高比
|
|
}; |