Files
ios/Xuxucheck/XuXuCheck/opencv/ImgLocateDryChemistry.h
T
admin d6aeede2bc 导入 XuXuCheck 工程(iOS 干化学尿液试纸分析 App)
从桌面工程复制而来,作为本仓库的 Xuxucheck/ 子目录。

为控制仓库体积做了两处删减:
- 移除 Frameworks/opencv2.xcframework 下的两个 visionOS 切片
  (xros-arm64、xros-arm64-simulator,合计约 106 MB),并同步删掉该
  xcframework 内 Info.plist 里对应的两条 AvailableLibraries 记录,
  只保留 ios-arm64 与 ios-arm64_x86_64-simulator。
- 移除全部 .DS_Store 与 xcuserdata/。

已用 xcodebuild 从本目录完整编译验证:BUILD SUCCEEDED,
ProcessXCFramework 以 --platform ios 成功选中框架,产物含 3699 个 cv:: 符号
(OpenCV 确实链入),嵌入 framework 3 个,与移除无用 pod 之后的状态一致。

仓库约 206 MB,其中 OpenCV 203 MB、其余源码与依赖约 3 MB。
2026-09-23 14:17:31 +08:00

169 lines
4.4 KiB
C++
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <vector>
#include "ContourSelector.h"
using namespace std;
using namespace cv;
class PaperConfig {
public:
PaperConfig();
PaperConfig(int pst,int i, int s, double f, double st, double d, double r, double l);
virtual ~PaperConfig();
public:
int itemsNum;
int paperSpatialType;
int slicesNum;
double firstPos; //real first postion == firstPos * avg slice's width
double step;
double distTimes;//(distance of 2 center points ) % ( height of paper) such as 21.2 (106.5 % 5 )
double whRRatio;//big locator : 2 / 3
double whLRatio;//small locator : 0.6
void Init();
};
class ImgLocateDryChemistry
{
public:
ImgLocateDryChemistry();
~ImgLocateDryChemistry();
private:
enum BlockItems{
BI_14 = 14,
BI_13 = 13,
BI_12 = 12,
BI_11 = 11,
BI_10 = 10,
BI_9 = 9,
BI_8 = 8,
BI_7 = 7,
BI_6 = 6,
BI_5 = 5,
BI_4 = 4,
};
enum BigLocatorType{
BLT_SHORT = 0,//10mm
BLT_LONG = 1,//15mm
};
//locator color: Red, Green, Blue
enum LocatorColorClassification{
LCC_UNKNOWN = 0,
LCC_RED = 1,
LCC_GREEN = 2,
LCC_BLUE = 3,
};
enum PaperSpatialType{
PST_UNKNOWN = 0,
PST_14_S = 1, // ON
PST_14_L = 2, // ON
PST_13_S = 3,
PST_13_L = 4,
PST_12_S = 5, // ON
PST_12_L = 6,
PST_11_S = 7,
PST_11_L = 8, // ON
PST_10_S = 9, // ON
PST_10_L = 10,
PST_9_S = 11,
PST_9_L = 12, // ON
PST_8_S = 13, // ON
PST_8_L = 14,
PST_7_S = 15,
PST_7_L = 16, // ON
PST_6_S = 17, // ON
PST_6_L = 18,
PST_5_S = 19,
PST_5_L = 20, // ON
PST_4_S = 21, // ON
PST_4_L = 22,
};
Mat src; /*保存原始图片 */
Mat roiSrc; /*由SRC裁剪而来,大小ROI */
Mat hsv; /*由rgb convert而来 */
Mat rgb; /*由roiSrc convert而来 */
Mat paperImg; /*定位出的进一步 裁剪后的图片 */
int recode; /* */
int score; /* */
int locatorColor; /*定位块颜色类型 1: green 2:red 3:blue */
int paperItems;
int paperSpatialType;/*试纸类型*/
// int expectedPaperType; /* */
double avgDist; /* */
double totalDist; /* */
double distTimes; /* */
bool bRot; /* */
double topDefinitionValue;/* */
ContourSelector cs; /* 轮廓选择器 */
ContourSelector::VectorPT vecPt; /* */
ContourSelector::PairTExtend lRectContour; /* 左定位块外包轮廓 */
ContourSelector::PairTExtend rRectContour; /* */
cv::RotatedRect lRotRect; /* 左定位块 旋转矩形 */
cv::RotatedRect rRotRect; /* */
int lRotRectWidth; /* */
int rRotRectWidth; /* */
int lRotRectHeight; /* */
int rRotRectHeight; /* */
int paperHeight; /* */
map<int, PaperConfig*> mapPaperConfig;
PaperConfig* paperConfig;
public:
Mat& GetPosition(Mat& s, cv::Rect& roi, bool bDraw, cv::Scalar& wbAvgRgb, vector<cv::Point>&roiPositions);
int GetLastError() { return recode; }
Mat& GetPaperImg() { return paperImg; }
int GetLocatorColor() { return locatorColor; }
int GetLocatorType();
int GetPaperItems();
double GetDefinition() { return topDefinitionValue; }
int GetPaperHeight() { return paperHeight; }
int GetScore() { return score; }
private:
int analyseLocatorColor(Mat& sImg, double& slope);
bool analyseDefinition(Mat& sImg , cv::Rect& roi);
Mat& warpAffineImg(Mat &img);
// bool verifyDistance();
int verifyPaperConfig(double distRadio,double areaRadio);
void initPaperConfig();
void savePaperImg();
bool calGrayImgDefinition(Mat &img,double m,int u);
double calImgDefinition(Mat &img, double &diff, double &avg, int &lowLines, int &upLines);
int readLocatorColor(ContourGfExtend* pContourGfE);//0: green 1:red 2:blue -1:other
void releaseContoursGf(ContourSelector::VectorPT& vectorPt, int code = 0);
int processImage(Mat& sImg, Mat& b, Mat&v, cv::Rect& roi, bool useSThres, bool bDraw, cv::Scalar& wbAvgRgb, vector<cv::Point>&roiPositions);
};