Commit c7efc275 张士柳

1 个父辈 79de92b9
...@@ -6,11 +6,11 @@ using System.Runtime.InteropServices; ...@@ -6,11 +6,11 @@ using System.Runtime.InteropServices;
// 控制。更改这些特性值可修改 // 控制。更改这些特性值可修改
// 与程序集关联的信息。 // 与程序集关联的信息。
[assembly: AssemblyTitle("eyemLib-Sharp")] [assembly: AssemblyTitle("eyemLib-Sharp")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("eyemLib调试")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("上海挚锦科技有限公司")]
[assembly: AssemblyProduct("eyemLib-Sharp")] [assembly: AssemblyProduct("eyemLib-Sharp")]
[assembly: AssemblyCopyright("Copyright © 2020")] [assembly: AssemblyCopyright("Copyright 2020 © NeoTel. All Rights Reserved")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
......
...@@ -61,7 +61,7 @@ namespace eyemLib_Sharp ...@@ -61,7 +61,7 @@ namespace eyemLib_Sharp
{ {
// dispose managed resources // dispose managed resources
} }
//这里特别修改了eyemCvtToEyemImage的内存分配,因此皆可以由此接口释放 //这里特别修改了eyemCvtToEyemImage的内存分配,因此皆可以由此接口释放
eyemImageFree(ref image); eyemImageFree(ref image);
} }
......
...@@ -229,3 +229,18 @@ int eyemClp2dTangentPointToCircle(EyemOcsDXY tpPoint, EyemOcsDXYR tpCircle, Eyem ...@@ -229,3 +229,18 @@ int eyemClp2dTangentPointToCircle(EyemOcsDXY tpPoint, EyemOcsDXYR tpCircle, Eyem
tpPoint.dX*tpContact2.dY; tpPoint.dX*tpContact2.dY;
return FUNC_OK; return FUNC_OK;
} }
int eyemClp2dIntersectionLineAndConvexPolygon()
{
return FUNC_OK;
}
int eyemClp2dAreaOfPolygon()
{
return FUNC_OK;
}
int eyemClp2dPointInPolygon()
{
return FUNC_OK;
}
\ No newline at end of file \ No newline at end of file
...@@ -279,7 +279,6 @@ static void fitLine2D_wods(int iPtnNum, const EyemOcsDXY2D *taPoints, EyemOcsDAB ...@@ -279,7 +279,6 @@ static void fitLine2D_wods(int iPtnNum, const EyemOcsDXY2D *taPoints, EyemOcsDAB
} }
cv::Vec4f linebuf; cv::Vec4f linebuf;
cv::fitLine(points, linebuf, cv::DIST_HUBER, .0, 1e-2, 1e-2); cv::fitLine(points, linebuf, cv::DIST_HUBER, .0, 1e-2, 1e-2);
double px = linebuf[2], py = linebuf[3]; double px = linebuf[2], py = linebuf[3];
double nx = linebuf[1], ny = -linebuf[0]; double nx = linebuf[1], ny = -linebuf[0];
//直线一般式 //直线一般式
...@@ -757,7 +756,7 @@ static void fitEllipse_wods(int iPtnNum, const EyemOcsDXY *taPoints, float *weig ...@@ -757,7 +756,7 @@ static void fitEllipse_wods(int iPtnNum, const EyemOcsDXY *taPoints, float *weig
linebuf[0] = rbox.center.x; linebuf[1] = rbox.center.y; linebuf[2] = cv::max(rbox.size.width / 2.0f, rbox.size.height / 2.0f); linebuf[3] = cv::min(rbox.size.width / 2.0f, rbox.size.height / 2.0f); linebuf[4] = rbox.angle*(float)PI / 180.0f; linebuf[0] = rbox.center.x; linebuf[1] = rbox.center.y; linebuf[2] = cv::max(rbox.size.width / 2.0f, rbox.size.height / 2.0f); linebuf[3] = cv::min(rbox.size.width / 2.0f, rbox.size.height / 2.0f); linebuf[4] = rbox.angle*(float)PI / 180.0f;
} }
int eyemRobustFitEllipse(int iPtnNum, EyemOcsDXY * taPoint, int iCalcMode, double dRobustCoef, EyemOcsDXYLSQ & tpEllipse) int eyemRobustFitEllipse(int iPtnNum, EyemOcsDXY *taPoint, int iCalcMode, double dRobustCoef, EyemOcsDXYLSQ &tpEllipse)
{ {
float linebuf[5] = { .0f }; float linebuf[5] = { .0f };
memset(linebuf, 0, 5 * sizeof(float)); memset(linebuf, 0, 5 * sizeof(float));
...@@ -779,3 +778,12 @@ int eyemRobustFitEllipse(int iPtnNum, EyemOcsDXY * taPoint, int iCalcMode, doubl ...@@ -779,3 +778,12 @@ int eyemRobustFitEllipse(int iPtnNum, EyemOcsDXY * taPoint, int iCalcMode, doubl
return FUNC_OK; return FUNC_OK;
} }
int eyemRobustFitRectangle(int iPtnNum, EyemOcsDXY *taPoint, int iCalcMode, double dRobustCoef, EyemRotateRect &tpRect)
{
//先计算最小外包,然后计算各点到矩形的最小平方差和
//cv::minAreaRect();
return FUNC_OK;
}
...@@ -31,6 +31,12 @@ void setProcessLevel(double processLevel_) ...@@ -31,6 +31,12 @@ void setProcessLevel(double processLevel_)
processLevel = processLevel_; processLevel = processLevel_;
} }
double fineTuning = 0.7;
void setFineTuning(double fineTuning_)
{
fineTuning = fineTuning_;
}
std::map<std::string, EyemImage> imageMap; std::map<std::string, EyemImage> imageMap;
void loadImage2Mem(const char *key, EyemImage tpImage) void loadImage2Mem(const char *key, EyemImage tpImage)
{ {
......
...@@ -7,6 +7,18 @@ ...@@ -7,6 +7,18 @@
#include <opencv.hpp> #include <opencv.hpp>
#ifndef FILEVERSION
#define FILEVERSION "2.4.8.2"
#endif
#ifndef COPYRIGHT
#define COPYRIGHT "Copyright (C) 2020-2022 NeoTel. All Rights Reserved"
#endif
#ifndef ORIGINALFILENAME
#define ORIGINALFILENAME "eyemLib.dll"
#endif
#ifndef EXPORTS #ifndef EXPORTS
#define EXPORTS __declspec(dllexport) #define EXPORTS __declspec(dllexport)
#endif #endif
...@@ -189,14 +201,6 @@ typedef struct { ...@@ -189,14 +201,6 @@ typedef struct {
double dVar; // 可能会使用的值 double dVar; // 可能会使用的值
} EyemRect3; } EyemRect3;
//// 旋转矩形定义
//typedef struct {
// double dWidth; // 旋转矩形宽度
// double dHeight; // 旋转矩形高度
// double dAngle; // 旋转矩形角度(-90==>90)
// EyemOcsDXY tC; // 旋转矩形中心
//} EyemRotateRect;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Orthogonal Coordinate System // Orthogonal Coordinate System
...@@ -371,6 +375,13 @@ typedef struct { ...@@ -371,6 +375,13 @@ typedef struct {
} EyemHSVModel; // 用于HSV颜色模型分割(H(0-180)、S(0-255)、V(0-255)) } EyemHSVModel; // 用于HSV颜色模型分割(H(0-180)、S(0-255)、V(0-255))
typedef struct {
EyemOcsDXY tC; // 旋转矩形中心
double dWidth; // 旋转矩形宽度
double dHeight; // 旋转矩形高度
double dAngle; // 旋转矩形角度
} EyemRotateRect; // 旋转矩形定义
/********************************************************************************************/ /********************************************************************************************/
/* 每个特定于源的标头 */ /* 每个特定于源的标头 */
/********************************************************************************************/ /********************************************************************************************/
...@@ -916,6 +927,7 @@ extern "C" { ...@@ -916,6 +927,7 @@ extern "C" {
EXPORTS int eyemCountObjectE(EyemImage tpImage, EyemRect tpRoi, const char *fileName, int *ipReelNum, EyemImage *tpDstImg); EXPORTS int eyemCountObjectE(EyemImage tpImage, EyemRect tpRoi, const char *fileName, int *ipReelNum, EyemImage *tpDstImg);
EXPORTS int eyemCountObjectIrregularParts(EyemImage tpImage, EyemRect tpRoi, const char *fileName, const char * ccSubType, int *ipReelNum, EyemImage *tpDstImg); EXPORTS int eyemCountObjectIrregularParts(EyemImage tpImage, EyemRect tpRoi, const char *fileName, const char * ccSubType, int *ipReelNum, EyemImage *tpDstImg);
EXPORTS int eyemCountObjectIrregularPartsE(EyemImage tpImage, EyemRect tpRoi, const char *fileName, const char *ccTplName, IntPtr hModelID, int *ipReelNum, EyemImage *tpDstImg); EXPORTS int eyemCountObjectIrregularPartsE(EyemImage tpImage, EyemRect tpRoi, const char *fileName, const char *ccTplName, IntPtr hModelID, int *ipReelNum, EyemImage *tpDstImg);
EXPORTS int eyemCountObjectIrregularPartsMultiopt(EyemImage tpImage, EyemRect tpRoi, int iOptions[4], int *ipReelNum, EyemImage *tpDstImg);
EXPORTS int eyemAchvMatchMat(EyemImage tpImage, EyemRect tpRoi, EyemImage *tpDstImg); EXPORTS int eyemAchvMatchMat(EyemImage tpImage, EyemRect tpRoi, EyemImage *tpDstImg);
EXPORTS int eyemAchvTemplateImage(EyemImage tpImage, EyemRect tpRoi, EyemImage *tpDstImg); EXPORTS int eyemAchvTemplateImage(EyemImage tpImage, EyemRect tpRoi, EyemImage *tpDstImg);
EXPORTS int eyemCreateTemplateModel(EyemImage tpImage, EyemRect tpRoi, double dMinScore, const char *ccTplName); EXPORTS int eyemCreateTemplateModel(EyemImage tpImage, EyemRect tpRoi, double dMinScore, const char *ccTplName);
...@@ -935,6 +947,8 @@ extern "C" { ...@@ -935,6 +947,8 @@ extern "C" {
EXPORTS int eyemDrawCircle(EyemImage tpImage, EyemOcsDXYR tpCircle); EXPORTS int eyemDrawCircle(EyemImage tpImage, EyemOcsDXYR tpCircle);
EXPORTS int eyemDrawRectangle(EyemImage tpImag, EyemRect tpRect); EXPORTS int eyemDrawRectangle(EyemImage tpImag, EyemRect tpRect);
EXPORTS int eyemTrainImageSampler(EyemImage tpImage, int iSize, const char *ccClassName, const char *ccToPath, EyemImage *tpMatchImg, EyemImage *tpDstImg); EXPORTS int eyemTrainImageSampler(EyemImage tpImage, int iSize, const char *ccClassName, const char *ccToPath, EyemImage *tpMatchImg, EyemImage *tpDstImg);
EXPORTS int eyemAffineTransform(EyemImage tpImage, double tAngle, EyemOcsDXY tpCenter, EyemImage *tpDstImg);
#ifdef __cplusplus #ifdef __cplusplus
} }
...@@ -946,6 +960,9 @@ extern "C" __declspec(dllexport) void setSkipProcessID(int pid); ...@@ -946,6 +960,9 @@ extern "C" __declspec(dllexport) void setSkipProcessID(int pid);
// 设置全局参数 // 设置全局参数
extern "C" __declspec(dllexport) void setProcessLevel(double pl); extern "C" __declspec(dllexport) void setProcessLevel(double pl);
// 设置A算法全局参数
extern "C" __declspec(dllexport) void setFineTuning(double ft);
// 加载图像到内存 // 加载图像到内存
extern "C" __declspec(dllexport) void loadImage2Mem(const char *key, EyemImage tpImage); extern "C" __declspec(dllexport) void loadImage2Mem(const char *key, EyemImage tpImage);
......
此文件类型无法预览
...@@ -704,3 +704,37 @@ int eyemWarpShiftSubpix(EyemImage tpImage, double dShiftX, double dShiftY, EyemI ...@@ -704,3 +704,37 @@ int eyemWarpShiftSubpix(EyemImage tpImage, double dShiftX, double dShiftY, EyemI
cv::warpAffine(image, imageShift, matM, image.size(), iInterMethod, 0); cv::warpAffine(image, imageShift, matM, image.size(), iInterMethod, 0);
return FUNC_OK; return FUNC_OK;
} }
bool eyemCheckBinary(EyemImage tpImage)
{
CV_Assert(NULL != tpImage.vpImage);
cv::Mat image = cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage).clone();
if (image.empty())
return false;
int X = image.cols, Y = image.rows;
int incn = image.channels();
if (incn != 1) {
return false;
}
int bs = 16, b = (X*incn) / bs, stride = (int)image.step;
for (int y = 0; y < Y; y++)
{
unsigned char *LinePS = image.data + y * stride;
for (int x = 0; x < b * bs; x += bs) {
__m128i SrcV = _mm_loadu_si128((__m128i *)(LinePS + x));
__m128i MaskW = _mm_cmpeq_epi8(SrcV, _mm_set1_epi8(255));
__m128i MaskB = _mm_cmpeq_epi8(SrcV, _mm_setzero_si128());
__m128i Mask = _mm_or_si128(MaskW, MaskB);
if (_mm_movemask_epi8(Mask) != 65535) {
return false;
}
}
for (int x = b * bs; x < X * incn; x++) {
if ((LinePS[x] != 255) && (LinePS[x] != 0)) {
return false;
}
}
}
return true;
}
\ No newline at end of file \ No newline at end of file
此文件的差异太大,无法显示。
...@@ -14,6 +14,7 @@ constexpr double c = PI / 180.; ...@@ -14,6 +14,7 @@ constexpr double c = PI / 180.;
extern Logger logger; extern Logger logger;
extern int killProcessID; extern int killProcessID;
extern double processLevel; extern double processLevel;
extern double fineTuning;
extern std::map<std::string, EyemImage> imageMap; extern std::map<std::string, EyemImage> imageMap;
#endif/* __EYEM_MISC_H */ #endif/* __EYEM_MISC_H */
...@@ -380,7 +380,7 @@ int eyemNonLocalMeansFilter(EyemImage tpImage, int iCMPSize, int iSearchSize, do ...@@ -380,7 +380,7 @@ int eyemNonLocalMeansFilter(EyemImage tpImage, int iCMPSize, int iSearchSize, do
return FUNC_IMAGE_NOT_EXIST; return FUNC_IMAGE_NOT_EXIST;
} }
cv::Mat dest; cv::Mat dest;
nonLocalMeansFilter_SSE(image, dest, cv::Size(3, 3), cv::Size(5, 5), 10.0, -1, 0); nonLocalMeansFilter_SSE(image, dest, cv::Size(3, 3), cv::Size(3, 3), 5.0, -1, 0);
return FUNC_OK; return FUNC_OK;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!