Commit d268845f 张士柳

优化通用点料算法速度与准确度

1 个父辈 e1f406f7
...@@ -21,6 +21,8 @@ namespace eyemLib_Sharp ...@@ -21,6 +21,8 @@ namespace eyemLib_Sharp
string[] fileNames = Directory.GetFiles(@"D:\批量测试图像", "*.*", SearchOption.AllDirectories); string[] fileNames = Directory.GetFiles(@"D:\批量测试图像", "*.*", SearchOption.AllDirectories);
//EyemLib.eyemTestVideoCapture(@"D:\批量测试图像");
//int iter = 0; //int iter = 0;
//for (int i = 0; i < 10000; i++) //for (int i = 0; i < 10000; i++)
//{ //{
......
此文件的差异太大,无法显示。
...@@ -986,9 +986,7 @@ static double getThreshVal_Otsu_8u(const cv::Mat& _src) ...@@ -986,9 +986,7 @@ static double getThreshVal_Otsu_8u(const cv::Mat& _src)
int eyemBinThreshold(EyemImage tpSrcImg, int iLightDark, double dThresh, double dMaxVal, EyemImage *tpDstImg) int eyemBinThreshold(EyemImage tpSrcImg, int iLightDark, double dThresh, double dMaxVal, EyemImage *tpDstImg)
{ {
std::cout << "Test 'eyemBinThreshold' " << std::endl; cv::Mat image = cv::Mat(tpSrcImg.iHeight, tpSrcImg.iWidth, MAKETYPE(tpSrcImg.iDepth, tpSrcImg.iChannels), tpSrcImg.vpImage).clone();
cv::Mat image(tpSrcImg.iHeight, tpSrcImg.iWidth, CV_8UC1, tpSrcImg.vpImage);
if (image.empty()) { if (image.empty()) {
return FUNC_IMAGE_NOT_EXIST; return FUNC_IMAGE_NOT_EXIST;
...@@ -997,7 +995,7 @@ int eyemBinThreshold(EyemImage tpSrcImg, int iLightDark, double dThresh, double ...@@ -997,7 +995,7 @@ int eyemBinThreshold(EyemImage tpSrcImg, int iLightDark, double dThresh, double
//执行二值化操作 //执行二值化操作
cv::threshold(image, binary, dThresh, dMaxVal, iLightDark); cv::threshold(image, binary, dThresh, dMaxVal, iLightDark);
///<输出结果图像 //输出结果图像
{ {
tpDstImg->iWidth = binary.cols; tpDstImg->iHeight = binary.rows; tpDstImg->iDepth = binary.depth(); tpDstImg->iChannels = binary.channels(); tpDstImg->iWidth = binary.cols; tpDstImg->iHeight = binary.rows; tpDstImg->iDepth = binary.depth(); tpDstImg->iChannels = binary.channels();
...@@ -1016,11 +1014,10 @@ int eyemBinThreshold(EyemImage tpSrcImg, int iLightDark, double dThresh, double ...@@ -1016,11 +1014,10 @@ int eyemBinThreshold(EyemImage tpSrcImg, int iLightDark, double dThresh, double
return FUNC_OK; return FUNC_OK;
} }
int eyemBinNiBlack(EyemImage tpSrcImg, EyemImage *tpDstImg, int iType, int iWinSize, double dK, int binMethod, double dR) int eyemBinNiBlack(EyemImage tpSrcImg, int iType, int iWinSize, double dK, int binMethod, double dR, EyemImage *tpDstImg)
{ {
std::cout << "Test 'eyemBinSauvola' " << std::endl; cv::Mat src = cv::Mat(tpSrcImg.iHeight, tpSrcImg.iWidth, MAKETYPE(tpSrcImg.iDepth, tpSrcImg.iChannels), tpSrcImg.vpImage).clone();
cv::Mat src(tpSrcImg.iHeight, tpSrcImg.iWidth, CV_8UC1, tpSrcImg.vpImage);
if (src.empty()) { if (src.empty()) {
return FUNC_IMAGE_NOT_EXIST; return FUNC_IMAGE_NOT_EXIST;
} }
...@@ -1091,7 +1088,7 @@ int eyemBinNiBlack(EyemImage tpSrcImg, EyemImage *tpDstImg, int iType, int iWinS ...@@ -1091,7 +1088,7 @@ int eyemBinNiBlack(EyemImage tpSrcImg, EyemImage *tpDstImg, int iType, int iWinS
break; break;
} }
///<输出计数结果标记图像 //输出图像
{ {
tpDstImg->iWidth = dst.cols; tpDstImg->iHeight = dst.rows; tpDstImg->iDepth = dst.depth(); tpDstImg->iChannels = dst.channels(); tpDstImg->iWidth = dst.cols; tpDstImg->iHeight = dst.rows; tpDstImg->iDepth = dst.depth(); tpDstImg->iChannels = dst.channels();
...@@ -1111,60 +1108,71 @@ int eyemBinNiBlack(EyemImage tpSrcImg, EyemImage *tpDstImg, int iType, int iWinS ...@@ -1111,60 +1108,71 @@ int eyemBinNiBlack(EyemImage tpSrcImg, EyemImage *tpDstImg, int iType, int iWinS
return FUNC_OK; return FUNC_OK;
} }
int eyemBinDynThreshold(EyemImage tpSrcImg, EyemImage tpThresholdImg, int iOffset, int iLightDark, EyemImage *tpDstImg) int eyemBinDynThreshold(EyemImage tpSrcImg, EyemImage tpPreImg, double dOffset, int iType, EyemImage *tpDstImg)
{ {
std::cout << "Test 'eyemBinBinaryDynamic' " << std::endl; CV_Assert(MAKETYPE(tpSrcImg.iDepth, tpSrcImg.iChannels) == MAKETYPE(tpPreImg.iDepth, tpPreImg.iChannels));
cv::Mat src(tpSrcImg.iHeight, tpSrcImg.iWidth, CV_8UC1, tpSrcImg.vpImage); cv::Mat image = cv::Mat(tpSrcImg.iHeight, tpSrcImg.iWidth, MAKETYPE(tpSrcImg.iDepth, tpSrcImg.iChannels), tpSrcImg.vpImage).clone();
if (src.empty()) {
if (image.empty()) {
return FUNC_IMAGE_NOT_EXIST; return FUNC_IMAGE_NOT_EXIST;
} }
cv::Mat srcMean, variance; cv::Mat imagePre, variance;
cv::blur(src, srcMean, cv::Size(11, 7));
cv::Mat thresh; cv::Mat thresh;
{ {
switch (iLightDark) imagePre = cv::Mat(tpPreImg.iHeight, tpPreImg.iWidth, MAKETYPE(tpPreImg.iDepth, tpPreImg.iChannels), tpPreImg.vpImage).clone();
switch (iType)
{ {
case LIGHT: case LIGHT:
variance = src - srcMean; variance = image - imagePre;
break; break;
case DARK: case DARK:
variance = srcMean - src; variance = imagePre - image;
break; break;
case EQUAL: case EQUAL:
variance = abs(src - srcMean); variance = abs(image - imagePre);
break; break;
case NOT_EQUAL: case NOT_EQUAL:
variance = abs(srcMean - src); variance = abs(imagePre - image);
break; break;
default: default:
break; break;
} }
} }
cv::Mat binary, showMat; cv::Mat binary, showMat;
cv::compare(variance, cv::Mat::ones(srcMean.size(), CV_8U)*iOffset, binary, cv::CMP_GT); cv::compare(variance, cv::Mat::ones(imagePre.size(), imagePre.type())*dOffset, binary, cv::CMP_GT);
cv::add(src, cv::Mat::ones(src.size(), CV_8UC1) * 75, src);
cv::cvtColor(src.clone(), showMat, cv::COLOR_GRAY2BGR); //输出结果图像
uchar * upBin = binary.data;
for (int y = 0; y < src.rows; y++)
{
for (int x = 0; x < src.cols; x++)
{ {
if (upBin[(x)+(y)*src.cols] != 0) if (NULL != tpDstImg->vpImage) {
{ tpDstImg->iWidth = tpDstImg->iHeight = tpDstImg->iDepth = tpDstImg->iChannels = 0;
showMat.at<cv::Vec3b>(y, x) = cv::Vec3b(0, 255, 0); //释放
} free(tpDstImg->vpImage);
tpDstImg->vpImage = NULL;
} }
tpDstImg->iWidth = binary.cols; tpDstImg->iHeight = binary.rows; tpDstImg->iDepth = binary.depth(); tpDstImg->iChannels = binary.channels();
//内存尺寸
int _Size = tpDstImg->iWidth*tpDstImg->iHeight*tpDstImg->iChannels * sizeof(uint8_t);
//分配初始化内存
tpDstImg->vpImage = (uint8_t *)malloc(_Size);
if (NULL == tpDstImg->vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpDstImg->vpImage, 0, _Size);
//拷贝数据
memcpy(tpDstImg->vpImage, binary.data, _Size);
} }
//输出结果图
return FUNC_OK; return FUNC_OK;
} }
int eyemBinAutoThreshold(EyemImage tpImage, double dSigma, int iLightDark, int binMethod, EyemImage *tpDstImg) int eyemBinAutoThreshold(EyemImage tpImage, double dSigma, int iLightDark, int binMethod, EyemImage *tpDstImg)
{ {
cv::Mat image(tpImage.iHeight, tpImage.iWidth, CV_8UC1, tpImage.vpImage); cv::Mat image = cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage).clone();
if (image.empty()) { if (image.empty()) {
return FUNC_IMAGE_NOT_EXIST; return FUNC_IMAGE_NOT_EXIST;
} }
...@@ -1208,54 +1216,35 @@ int eyemBinAutoThreshold(EyemImage tpImage, double dSigma, int iLightDark, int b ...@@ -1208,54 +1216,35 @@ int eyemBinAutoThreshold(EyemImage tpImage, double dSigma, int iLightDark, int b
uchar *uPtr = image.data + Y * image.cols; uchar *uPtr = image.data + Y * image.cols;
for (int X = 0; X < image.cols; X++, uPtr++) hist[*uPtr]++; for (int X = 0; X < image.cols; X++, uPtr++) hist[*uPtr]++;
} }
cv::Mat histMat = cv::Mat(1, 256, CV_32S, hist);
//对直方图滤波
cv::Mat F, G;
histMat.convertTo(F, CV_64F);
cv::Mat kernel = cv::getGaussianKernel(cvRound(dSigma * 3), dSigma);
cv::sepFilter2D(F, F, F.depth(), kernel, cv::Mat::ones(1, 1, CV_64F));
F.convertTo(G, CV_32S);
threshold = calc_threshold_param(hist); threshold = calc_threshold_param(hist);
cv::Mat binary; cv::Mat binary;
cv::threshold(image, binary, threshold, 255, iLightDark | cv::THRESH_BINARY); cv::threshold(image, binary, threshold, 255, iLightDark);
cv::Mat ker = cv::Mat::ones(3, 3, CV_8UC1);
cv::morphologyEx(binary, binary, cv::MORPH_OPEN, ker, cv::Point(-1, -1), 2);
cv::Mat bg;
cv::dilate(binary, bg, kernel, cv::Point(-1, -1), 3);
//# noise removal
// kernel = np.ones((3, 3), np.uint8)
// opening = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel, iterations = 2) # 形态开运算
// # sure background area
// sure_bg = cv2.dilate(opening, kernel, iterations = 3)
// # Finding sure foreground area
// dist_transform = cv2.distanceTransform(opening, cv2.DIST_L2, 5)
// ret, sure_fg = cv2.threshold(dist_transform, 0.7*dist_transform.max(), 255, 0)
// # Finding unknown region //输出结果图像
// sure_fg = np.uint8(sure_fg) {
// unknown = cv2.subtract(sure_bg, sure_fg) if (NULL != tpDstImg->vpImage) {
tpDstImg->iWidth = tpDstImg->iHeight = tpDstImg->iDepth = tpDstImg->iChannels = 0;
cv::Mat distMap(image.size(), CV_32FC1); //释放
cv::distanceTransform(binary, distMap, cv::noArray(), cv::DIST_L2, 5); free(tpDstImg->vpImage);
tpDstImg->vpImage = NULL;
}
cv::normalize(distMap, distMap, 0, 255, cv::NORM_MINMAX);
distMap.convertTo(distMap, CV_8UC1); tpDstImg->iWidth = binary.cols; tpDstImg->iHeight = binary.rows; tpDstImg->iDepth = binary.depth(); tpDstImg->iChannels = binary.channels();
cv::Mat fg; //内存尺寸
cv::threshold(distMap, fg, 0.5 * 202, 255, 0); int _Size = tpDstImg->iWidth*tpDstImg->iHeight*tpDstImg->iChannels * sizeof(uint8_t);
fg.convertTo(fg, CV_8UC1); //分配初始化内存
cv::Mat unknown; tpDstImg->vpImage = (uint8_t *)malloc(_Size);
cv::subtract(bg, fg, unknown); if (NULL == tpDstImg->vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpDstImg->vpImage, 0, _Size);
//拷贝数据
memcpy(tpDstImg->vpImage, binary.data, _Size);
}
return FUNC_OK; return FUNC_OK;
} }
......
...@@ -13,7 +13,7 @@ void eyemClp2dCenterTwoPoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, EyemOcsD ...@@ -13,7 +13,7 @@ void eyemClp2dCenterTwoPoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, EyemOcsD
int eyemClp2dLineTwoPoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, EyemOcsDABC &tpLine) int eyemClp2dLineTwoPoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, EyemOcsDABC &tpLine)
{ {
if (std::abs(tpPoint1.dX - tpPoint2.dX) < DBL_EPS && std::abs(tpPoint1.dY - tpPoint2.dY) < DBL_EPS) { if (std::abs(tpPoint1.dX - tpPoint2.dX) < EPS && std::abs(tpPoint1.dY - tpPoint2.dY) < EPS) {
return FUNC_CANNOT_CALC; return FUNC_CANNOT_CALC;
} }
tpLine.dA = -(tpPoint1.dY - tpPoint2.dY); tpLine.dA = -(tpPoint1.dY - tpPoint2.dY);
...@@ -24,7 +24,7 @@ int eyemClp2dLineTwoPoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, EyemOcsDABC ...@@ -24,7 +24,7 @@ int eyemClp2dLineTwoPoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, EyemOcsDABC
int eyemClp2dMidperpendicularTwoPoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, EyemOcsDABC &tpLine) int eyemClp2dMidperpendicularTwoPoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, EyemOcsDABC &tpLine)
{ {
if (std::abs(tpPoint1.dX - tpPoint2.dX) < DBL_EPS && std::abs(tpPoint1.dY - tpPoint2.dY) < DBL_EPS) { if (std::abs(tpPoint1.dX - tpPoint2.dX) < EPS && std::abs(tpPoint1.dY - tpPoint2.dY) < EPS) {
return FUNC_CANNOT_CALC; return FUNC_CANNOT_CALC;
} }
tpLine.dA = 2.0 * (tpPoint2.dX - tpPoint1.dX); tpLine.dA = 2.0 * (tpPoint2.dX - tpPoint1.dX);
...@@ -36,7 +36,7 @@ int eyemClp2dMidperpendicularTwoPoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, ...@@ -36,7 +36,7 @@ int eyemClp2dMidperpendicularTwoPoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2,
int eyemClp2dVerticalLinePointAndLine(EyemOcsDXY tpPoint, EyemOcsDABC tpLine, EyemOcsDABC &tpVertical) int eyemClp2dVerticalLinePointAndLine(EyemOcsDXY tpPoint, EyemOcsDABC tpLine, EyemOcsDABC &tpVertical)
{ {
double v = std::sqrt(std::pow(tpLine.dB, 2) + std::pow(-tpLine.dA, 2)); double v = std::sqrt(std::pow(tpLine.dB, 2) + std::pow(-tpLine.dA, 2));
if (v < DBL_EPS) { if (v < EPS) {
return FUNC_CANNOT_CALC; return FUNC_CANNOT_CALC;
} }
tpVertical.dA = tpLine.dB / v; tpVertical.dA = tpLine.dB / v;
...@@ -54,7 +54,7 @@ void eyemClp2dLinePointAndSlope(EyemOcsDXY tpPoint, double dSlope, EyemOcsDABC & ...@@ -54,7 +54,7 @@ void eyemClp2dLinePointAndSlope(EyemOcsDXY tpPoint, double dSlope, EyemOcsDABC &
int eyemClp2dIntersectionTwoLines(EyemOcsDABC tpLine1, EyemOcsDABC tpLine2, EyemOcsDXY &tpPoint) int eyemClp2dIntersectionTwoLines(EyemOcsDABC tpLine1, EyemOcsDABC tpLine2, EyemOcsDXY &tpPoint)
{ {
if (abs(tpLine1.dA*tpLine2.dB - tpLine2.dA*tpLine1.dB) < DBL_EPS) { if (abs(tpLine1.dA*tpLine2.dB - tpLine2.dA*tpLine1.dB) < EPS) {
return FUNC_CANNOT_CALC; return FUNC_CANNOT_CALC;
} }
//计算系数 //计算系数
...@@ -79,9 +79,7 @@ int eyemClp2dIntersectionTwoLines(EyemOcsDABC tpLine1, EyemOcsDABC tpLine2, Eyem ...@@ -79,9 +79,7 @@ int eyemClp2dIntersectionTwoLines(EyemOcsDABC tpLine1, EyemOcsDABC tpLine2, Eyem
int eyemClp2dAngleTwoLines(EyemOcsDABC tpLine1, EyemOcsDABC tpLine2, double &dpAngle) int eyemClp2dAngleTwoLines(EyemOcsDABC tpLine1, EyemOcsDABC tpLine2, double &dpAngle)
{ {
double det = tpLine1.dA*tpLine2.dB - tpLine2.dA*tpLine1.dB; if (abs(tpLine1.dA*tpLine2.dB - tpLine2.dA*tpLine1.dB) < EPS) {
if (abs(det) < DBL_EPS)
{
return FUNC_CANNOT_CALC; return FUNC_CANNOT_CALC;
} }
double u, v, uv; double u, v, uv;
...@@ -109,7 +107,7 @@ int eyemClp2dCenterLineOfTwoLines(EyemOcsDABC tpLine1, EyemOcsDABC tpLine2, Eyem ...@@ -109,7 +107,7 @@ int eyemClp2dCenterLineOfTwoLines(EyemOcsDABC tpLine1, EyemOcsDABC tpLine2, Eyem
int eyemClp2dDistancePointToLine(EyemOcsDXY tpPoint, EyemOcsDABC tpLine, double &dpDist) int eyemClp2dDistancePointToLine(EyemOcsDXY tpPoint, EyemOcsDABC tpLine, double &dpDist)
{ {
dpDist = abs(tpLine.dA*tpPoint.dX + tpLine.dB*tpPoint.dY + tpLine.dC) / sqrt(tpLine.dA*tpLine.dA + tpLine.dB*tpLine.dB); dpDist = std::abs(tpLine.dA*tpPoint.dX + tpLine.dB*tpPoint.dY + tpLine.dC) / sqrt(tpLine.dA*tpLine.dA + tpLine.dB*tpLine.dB);
return FUNC_OK; return FUNC_OK;
} }
...@@ -158,8 +156,44 @@ int eyemClp2dIntersectionLineAndCircle(EyemOcsDABC tpLine, EyemOcsDXYR tpCircle, ...@@ -158,8 +156,44 @@ int eyemClp2dIntersectionLineAndCircle(EyemOcsDABC tpLine, EyemOcsDXYR tpCircle,
if (dist > tpCircle.dR) { if (dist > tpCircle.dR) {
return FUNC_CANNOT_CALC; return FUNC_CANNOT_CALC;
} }
double dt = tpCircle.dR*tpCircle.dR*(1 + (-tpLine.dA / tpLine.dB)*(-tpLine.dA / tpLine.dB)) - std::pow((tpCircle.dY -
(-tpLine.dA / tpLine.dB)*tpCircle.dX - (-tpLine.dC / tpLine.dB)), 2);
tpPoint1.dX = ((tpCircle.dX + tpCircle.dY*(-tpLine.dA / tpLine.dB)) - (-tpLine.dC / tpLine.dB)*(-tpLine.dA / tpLine.dB) + sqrt(dt)) / (1 + std::pow(-tpLine.dA / tpLine.dB, 2));
tpPoint1.dY = ((-tpLine.dC / tpLine.dB) + tpCircle.dX*(-tpLine.dA / tpLine.dB) + tpCircle.dY*std::pow(-tpLine.dA / tpLine.dB, 2) + (-tpLine.dA / tpLine.dB)*sqrt(dt)) / (1 + std::pow(-tpLine.dA / tpLine.dB, 2));
tpPoint2.dX = ((tpCircle.dX + tpCircle.dY*(-tpLine.dA / tpLine.dB)) - (-tpLine.dC / tpLine.dB)*(-tpLine.dA / tpLine.dB) - sqrt(dt)) / (1 + std::pow(-tpLine.dA / tpLine.dB, 2));
tpPoint2.dY = ((-tpLine.dC / tpLine.dB) + tpCircle.dX*(-tpLine.dA / tpLine.dB) + tpCircle.dY*std::pow(-tpLine.dA / tpLine.dB, 2) - (-tpLine.dA / tpLine.dB)*sqrt(dt)) / (1 + std::pow(-tpLine.dA / tpLine.dB, 2));
return FUNC_OK; return FUNC_OK;
} }
int eyemClp2dTangentPointToCircle(EyemOcsDXY tpPoint, EyemOcsDXYR tpCircle, EyemOcsDABC &tpTangent1, EyemOcsDXY &tpContact1, EyemOcsDABC &tpTangent2, EyemOcsDXY &tpContact2)
{
double dist = std::sqrt(std::pow(tpCircle.dX - tpPoint.dX, 2) + std::pow(tpCircle.dY - tpPoint.dY, 2));
if (dist < tpCircle.dR) {
return FUNC_CANNOT_CALC;
}
else if (abs(dist - tpCircle.dR) < EPS) {
//点在圆上
tpContact1.dX = tpContact2.dX = tpPoint.dX;
tpContact1.dY = tpContact2.dY = tpPoint.dY;
tpTangent1.dA = tpTangent2.dA = tpPoint.dX - tpCircle.dX;
tpTangent1.dB = tpTangent2.dB = tpPoint.dY - tpCircle.dY;
tpTangent1.dC = tpTangent2.dC = -(tpCircle.dR*tpCircle.dR + tpCircle.dX*(tpPoint.dX - tpCircle.dX) + tpCircle.dY*(tpPoint.dY - tpCircle.dY));
return FUNC_OK;
}
tpContact1.dX = (tpCircle.dR*tpCircle.dR*(tpPoint.dX - tpCircle.dX) + tpCircle.dR*(tpPoint.dY - tpCircle.dY)*sqrt(std::pow(tpPoint.dX - tpCircle.dX, 2)
+ std::pow(tpPoint.dY - tpCircle.dY, 2) - tpCircle.dR*tpCircle.dR)) / (std::pow(tpPoint.dX - tpCircle.dX, 2) + std::pow(tpPoint.dY - tpCircle.dY, 2)) + tpCircle.dX;
tpContact1.dY = (tpCircle.dR*tpCircle.dR*(tpPoint.dY - tpCircle.dY) - tpCircle.dR*(tpPoint.dX - tpCircle.dX)*sqrt(std::pow(tpPoint.dX - tpCircle.dX, 2)
+ std::pow(tpPoint.dY - tpCircle.dY, 2) - tpCircle.dR*tpCircle.dR)) / (std::pow(tpPoint.dX - tpCircle.dX, 2) + std::pow(tpPoint.dY - tpCircle.dY, 2)) + tpCircle.dY;
tpTangent1.dA = -(tpPoint.dY - tpContact1.dY); tpTangent1.dB = (tpPoint.dX - tpContact1.dX); tpTangent1.dC = tpContact1.dX*tpPoint.dY -
tpPoint.dX*tpContact1.dY;
tpContact2.dX = (tpCircle.dR*tpCircle.dR*(tpPoint.dX - tpCircle.dX) - tpCircle.dR*(tpPoint.dY - tpCircle.dY)*sqrt(std::pow(tpPoint.dX - tpCircle.dX, 2)
+ std::pow(tpPoint.dY - tpCircle.dY, 2) - tpCircle.dR*tpCircle.dR)) / (std::pow(tpPoint.dX - tpCircle.dX, 2) + std::pow(tpPoint.dY - tpCircle.dY, 2)) + tpCircle.dX;
tpContact2.dY = (tpCircle.dR*tpCircle.dR*(tpPoint.dY - tpCircle.dY) + tpCircle.dR*(tpPoint.dX - tpCircle.dX)*sqrt(std::pow(tpPoint.dX - tpCircle.dX, 2)
+ std::pow(tpPoint.dY - tpCircle.dY, 2) - tpCircle.dR*tpCircle.dR)) / (std::pow(tpPoint.dX - tpCircle.dX, 2) + std::pow(tpPoint.dY - tpCircle.dY, 2)) + tpCircle.dY;
tpTangent2.dA = -(tpPoint.dY - tpContact2.dY); tpTangent2.dB = (tpPoint.dX - tpContact2.dX); tpTangent2.dC = tpContact2.dX*tpPoint.dY -
tpPoint.dX*tpContact2.dY;
return FUNC_OK;
}
\ No newline at end of file \ No newline at end of file
...@@ -469,7 +469,6 @@ extern "C" { ...@@ -469,7 +469,6 @@ extern "C" {
EXPORTS int eyemClp2dCircleThreePoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, EyemOcsDXY tpPoint3, EyemOcsDXYR &tpCircle); EXPORTS int eyemClp2dCircleThreePoints(EyemOcsDXY tpPoint1, EyemOcsDXY tpPoint2, EyemOcsDXY tpPoint3, EyemOcsDXYR &tpCircle);
EXPORTS int eyemClp2dIntersectionLineAndCircle(EyemOcsDABC tpLine, EyemOcsDXYR tpCircle, EyemOcsDXY &tpPoint1, EyemOcsDXY &tpPoint2); EXPORTS int eyemClp2dIntersectionLineAndCircle(EyemOcsDABC tpLine, EyemOcsDXYR tpCircle, EyemOcsDXY &tpPoint1, EyemOcsDXY &tpPoint2);
EXPORTS int eyemClp2dTangentPointToCircle(EyemOcsDXY tpPoint, EyemOcsDXYR tpCircle, EyemOcsDABC &tpTangent1, EyemOcsDXY &tpContact1, EyemOcsDABC &tpTangent2, EyemOcsDXY &tpContact2); EXPORTS int eyemClp2dTangentPointToCircle(EyemOcsDXY tpPoint, EyemOcsDXYR tpCircle, EyemOcsDABC &tpTangent1, EyemOcsDXY &tpContact1, EyemOcsDABC &tpTangent2, EyemOcsDXY &tpContact2);
EXPORTS int eyemClp2dClosestToCircle(EyemOcsDXY tpPoint, EyemOcsDXYR tpCircle, EyemOcsDXY &tpClosest, double &dpDist);
#ifdef __cplusplus #ifdef __cplusplus
} }
...@@ -614,8 +613,8 @@ extern "C" { ...@@ -614,8 +613,8 @@ extern "C" {
// 函数接口 // 函数接口
EXPORTS int eyemBinThreshold(EyemImage tpSrcImg, int iLightDark, double dThresh, double dMaxVal, EyemImage *tpDstImg); EXPORTS int eyemBinThreshold(EyemImage tpSrcImg, int iLightDark, double dThresh, double dMaxVal, EyemImage *tpDstImg);
EXPORTS int eyemBinAutoThreshold(EyemImage tpSrcImg, double dSigma, int iLightDark, int binMethod, EyemImage *tpDstImg); EXPORTS int eyemBinAutoThreshold(EyemImage tpSrcImg, double dSigma, int iLightDark, int binMethod, EyemImage *tpDstImg);
EXPORTS int eyemBinNiBlack(EyemImage tpSrcImg, EyemImage *tpDstImg, int iType, int iWinSize, double dK, int binarizationMethod, double dR); EXPORTS int eyemBinNiBlack(EyemImage tpSrcImg, int iType, int iWinSize, double dK, int binarizationMethod, double dR, EyemImage *tpDstImg);
EXPORTS int eyemBinDynThreshold(EyemImage tpSrcImg, EyemImage tpThresholdImg, int iOffset, int iLightDark, EyemImage *tpDstImg); EXPORTS int eyemBinDynThreshold(EyemImage tpSrcImg, EyemImage tpPreImg, double dOffset, int iType, EyemImage *tpDstImg);
EXPORTS int eyemBinDilation(EyemImage tpSrcImg, int iBinLevel, int iNum, EyemImage *tpDstImg); EXPORTS int eyemBinDilation(EyemImage tpSrcImg, int iBinLevel, int iNum, EyemImage *tpDstImg);
EXPORTS int eyemBinErosion(EyemImage tpSrcImg, int iBinLevel, int iNum, EyemImage *tpDstImg); EXPORTS int eyemBinErosion(EyemImage tpSrcImg, int iBinLevel, int iNum, EyemImage *tpDstImg);
EXPORTS int eyemBinOpening(EyemImage tpSrcImg, int iBinLevel, int iNum, EyemImage *tpDstImg); EXPORTS int eyemBinOpening(EyemImage tpSrcImg, int iBinLevel, int iNum, EyemImage *tpDstImg);
...@@ -772,21 +771,6 @@ extern "C" { ...@@ -772,21 +771,6 @@ extern "C" {
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
// 图像线段检测器(eyemEDLinesDetector.cpp)
//
#ifdef __cplusplus
extern "C" {
#endif
// 函数接口
//EXPORTS int eyemEDLinesDetector(EyemImage tpImage, int _gradThresh, int _anchorThresh, int _scanInterval, int _minPathLen, double _sigma, bool _sumFlag, double _line_error, int _min_line_len, double _max_distance_between_two_lines, double _max_error, EyemImage *tpDstImg);
#ifdef __cplusplus
}
#endif
//////////////////////////////////////////////////////////////////////////////////////////////
// 图像通用处理(eyemGeneric.cpp) // 图像通用处理(eyemGeneric.cpp)
// //
#ifdef __cplusplus #ifdef __cplusplus
...@@ -839,7 +823,7 @@ extern "C" { ...@@ -839,7 +823,7 @@ extern "C" {
EXPORTS int eyemDetectAndDecodeBarcodeUseNN(EyemImage tpImage, EyemRect tpRoi, IntPtr *hObject, EyemBarCode **hResults, int *ipNum, EyemImage *tpDstImg); EXPORTS int eyemDetectAndDecodeBarcodeUseNN(EyemImage tpImage, EyemRect tpRoi, IntPtr *hObject, EyemBarCode **hResults, int *ipNum, EyemImage *tpDstImg);
EXPORTS bool eyemDetectAndDecodeFree(IntPtr hObject); EXPORTS bool eyemDetectAndDecodeFree(IntPtr hObject);
EXPORTS int eyemCountObject(EyemImage tpImage, EyemRect tpRoi, const char *fileName, double dOffset, int iMinArea, int iMaxArea, int iWinSize, LPSTR *lpszNumObj, EyemImage *tpDstImg); EXPORTS int eyemCountObject(EyemImage tpImage, EyemRect tpRoi, const char *fileName, double dOffset, int iMinArea, int iMaxArea, int iWinSize, LPSTR *lpszNumObj, EyemImage *tpDstImg);
EXPORTS int eyemCountObjectE(EyemImage tpImage, EyemRect tpRoi, const char *fileName, LPSTR *lpszNumObj, EyemImage *tpDstImg); EXPORTS int eyemCountObjectE(EyemImage tpImage, EyemRect tpRoi, const char *fileName, LPSTR *lpszReelNum, EyemImage *tpDstImg);
EXPORTS int eyemCountObjectIrregularParts(EyemImage tpImage, EyemRect tpRoi, const char *fileName, double dOffset, const char * ccSubType, int iMaxArea, int iWinSize, LPSTR *lpszNumObj, EyemImage *tpDstImg); EXPORTS int eyemCountObjectIrregularParts(EyemImage tpImage, EyemRect tpRoi, const char *fileName, double dOffset, const char * ccSubType, int iMaxArea, int iWinSize, LPSTR *lpszNumObj, EyemImage *tpDstImg);
EXPORTS int eyemCountObjectIrregularPartsE(EyemImage tpImage, EyemRect tpRoi, const char *fileName, const char *ccTplName, IntPtr hModelID, LPSTR *lpszReelNum, EyemImage *tpDstImg); EXPORTS int eyemCountObjectIrregularPartsE(EyemImage tpImage, EyemRect tpRoi, const char *fileName, const char *ccTplName, IntPtr hModelID, LPSTR *lpszReelNum, EyemImage *tpDstImg);
EXPORTS int eyemAchvTemplateImage(EyemImage tpImage, EyemRect tpRoi, EyemImage *tpDstImg); EXPORTS int eyemAchvTemplateImage(EyemImage tpImage, EyemRect tpRoi, EyemImage *tpDstImg);
...@@ -863,7 +847,6 @@ extern "C" { ...@@ -863,7 +847,6 @@ extern "C" {
//跳过某接口执行 //跳过某接口执行
extern "C" __declspec(dllexport) void setSkipProcessID(int pid); extern "C" __declspec(dllexport) void setSkipProcessID(int pid);
// 日志回调定义 // 日志回调定义
typedef void(__stdcall*TCallback)(const char* msg); typedef void(__stdcall*TCallback)(const char* msg);
...@@ -879,5 +862,4 @@ private: ...@@ -879,5 +862,4 @@ private:
extern "C" __declspec(dllexport) void setLogCallback(TCallback cb); extern "C" __declspec(dllexport) void setLogCallback(TCallback cb);
#endif/* __EYEM_LIB_H */ #endif/* __EYEM_LIB_H */
此文件类型无法预览
此文件的差异太大,无法显示。
#pragma once
//
// eyemMiscͷ
//
#ifndef __EYEM_MISC_H
#define __EYEM_MISC_H
#include <io.h>
#include <fstream>
#include <direct.h>
#include "eyemLib.h"
#include <tbb\tbb.h>
extern Logger logger;
constexpr double c = PI / 180.;
extern int killProcessID;
#endif/* __EYEM_MISC_H */
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!