Commit 19dd9381 张士柳

1 个父辈 c56e3788
......@@ -710,10 +710,10 @@ namespace eyemLib_Sharp
#region 项目
//普通器件
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemCountObject(EyemImage tpImage, string fileName, double dOffset, int iMinArea, int iMaxArea, int iWinSize, ref string pNumObj, out EyemImage tpDstImg);
private static extern int eyemCountObject(EyemImage tpImage, EyemRect tpRoi, string fileName, double dOffset, int iMinArea, int iMaxArea, int iWinSize, ref string pNumObj, out EyemImage tpDstImg);
//异型器件
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemCountObjectIrregularParts(EyemImage tpImage, string fileName, double dOffset, string strType, int iMaxArea, int iWinSize, ref string pNumObj, out EyemImage tpDstImg);
private static extern int eyemCountObjectIrregularParts(EyemImage tpImage, EyemRect tpRoi, string fileName, double dOffset, string strType, int iMaxArea, int iWinSize, ref string pNumObj, out EyemImage tpDstImg);
//普通器件(新版本)
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemCountObjectE(EyemImage tpImage, EyemRect tpRoi, string fileName, ref string pNumObj, out EyemImage tpDstImg);
......@@ -946,9 +946,9 @@ namespace eyemLib_Sharp
eyemImageFree(ref tpDstImg);
//"IP_SMALL_PARTS","IP_LARGE_PARTS","IP_LONG_PARTS",""
//eyemCountObject(image, file.Replace(".png", ""), 35, 0, 100, 5, ref pNumObj, out tpDstImg);
//eyemCountObjectIrregularParts(image, file.Replace(".png", ""), 0.1, "IP_LARGE_PARTS", 100, 7, ref pNumObj, out tpDstImg);
eyemCountObjectE(image, tpRoi, fileName, ref pNumObj, out tpDstImg);
//eyemCountObject(image, tpRoi, file.Replace(".png", ""), 35, 0, 100, 5, ref pNumObj, out tpDstImg);
//eyemCountObjectIrregularParts(image, tpRoi, file.Replace(".png", ""), 0.1, "IP_LARGE_PARTS", 100, 7, ref pNumObj, out tpDstImg);
//eyemCountObjectE(image, tpRoi, fileName, ref pNumObj, out tpDstImg);
eyemCountObjectIrregularPartsE(image, tpRoi, file.Replace(".png", ""), selectModel, ref pNumObj, out tpDstImg);
Bitmap bitmap = eyemCvtToBitmap(tpDstImg);
......
......@@ -832,9 +832,9 @@ extern "C" {
#endif
EXPORTS int eyemDetectAndDecode(EyemImage tpImage, EyemRect tpRoi, const char *ccFileName, const char *ccCodeType, IntPtr *hObject, EyemBarCode **tpResult, int *ipNum, bool bUseNiBlack, int iBlockSize, const int iRangeC, int iSymbolMin, int iSymbolMax, double dScaleUpAndDown = 0.5, double dToleErr = 0.5, double dMinorStep = 1.0);
EXPORTS bool eyemDetectAndDecodeFree(IntPtr hObject);
EXPORTS int eyemCountObject(EyemImage tpImage, 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 eyemCountObjectIrregularParts(EyemImage tpImage, 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, LPSTR *lpszNumObj, EyemImage *tpDstImg);
EXPORTS int eyemAchvTemplateImage(EyemImage tpImage, EyemRect tpRoi, EyemImage *tpDstImg);
EXPORTS int eyemCreateTemplateModel(EyemImage tpImage, EyemRect tpRoi, double dMinScore, const char *ccTplName);
......
此文件类型无法预览
......@@ -569,7 +569,7 @@ static bool checkSize(cv::Mat &srcPrev, cv::Mat &mask, int &partSize)
#pragma endregion
int eyemCountObject(EyemImage tpImage, const char *fileName, double dOffset, int iMinArea, int iMaxArea, int iWinSize, LPSTR *lpszNumObj, EyemImage *tpDstImg)
int eyemCountObject(EyemImage tpImage, EyemRect tpRoi, const char *fileName, double dOffset, int iMinArea, int iMaxArea, int iWinSize, LPSTR *lpszNumObj, EyemImage *tpDstImg)
{
cv::Mat src = cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage);
if (src.empty()) {
......@@ -579,11 +579,8 @@ int eyemCountObject(EyemImage tpImage, const char *fileName, double dOffset, int
if (src.channels() != 1)
cv::cvtColor(src, src, cv::COLOR_BGR2GRAY);
cv::Mat src8U;
//环鸿&佳世达
src = src(cv::Range(200, src.cols - 70), cv::Range(200, src.rows - 10)).clone();
//其他设备
//src = src(cv::Range(20, src.cols - 20), cv::Range(20, src.rows - 20)).clone();
//图像裁剪
src = src(cv::Rect(tpRoi.iXs, tpRoi.iYs, tpRoi.iWidth, tpRoi.iHeight)).clone();
//image size
int X = src.cols, Y = src.rows;
......@@ -602,6 +599,8 @@ int eyemCountObject(EyemImage tpImage, const char *fileName, double dOffset, int
src /= (max - min);
src *= 65535;
src.convertTo(src, CV_16UC1);
cv::Mat src8U;
src.convertTo(src8U, CV_8UC1, 1 / 255.);
//for show
cv::Mat cc;
......@@ -1539,7 +1538,7 @@ int eyemCountObject(EyemImage tpImage, const char *fileName, double dOffset, int
return FUNC_OK;
}
int eyemCountObjectIrregularParts(EyemImage tpImage, const char *fileName, double dOffset, const char * ccSubType, int iMaxArea, int iWinSize, LPSTR *lpszNumObj, EyemImage *tpDstImg)
int eyemCountObjectIrregularParts(EyemImage tpImage, EyemRect tpRoi, const char *fileName, double dOffset, const char * ccSubType, int iMaxArea, int iWinSize, LPSTR *lpszNumObj, EyemImage *tpDstImg)
{
cv::Mat src = cv::Mat(tpImage.iHeight, tpImage.iWidth, MAKETYPE(tpImage.iDepth, tpImage.iChannels), tpImage.vpImage);
if (src.empty()) {
......@@ -1549,10 +1548,8 @@ int eyemCountObjectIrregularParts(EyemImage tpImage, const char *fileName, doubl
if (src.channels() != 1)
cv::cvtColor(src, src, cv::COLOR_BGR2GRAY);
//环鸿&佳世达
src = src(cv::Range(200, src.cols - 70), cv::Range(200, src.rows - 10)).clone();
//其他设备
//src = src(cv::Range(20, src.cols - 20), cv::Range(20, src.rows - 20)).clone();
//图像裁剪
src = src(cv::Rect(tpRoi.iXs, tpRoi.iYs, tpRoi.iWidth, tpRoi.iHeight)).clone();
//图像尺寸
int X = src.cols, Y = src.rows;
......@@ -4536,7 +4533,7 @@ int eyemCountObjectIrregularPartsE(EyemImage tpImage, EyemRect tpRoi, const char
if (trayEnd) {
//不再判断,大概率已经终止
found = false;
}
}
else if (trackMat.ptr<uint8_t>(cvRound(trackCenterT.y))[cvRound(trackCenterT.x)] == 255) {
//不再判断,大概率已经终止
found = false;
......@@ -4587,8 +4584,8 @@ int eyemCountObjectIrregularPartsE(EyemImage tpImage, EyemRect tpRoi, const char
//std::cout << "总体耗时:" << 1000 * (static_cast<double>(cv::getTickCount()) - begin0) / cv::getTickFrequency() << std::endl;
trackEnd = (!found);
} while (!trackEnd);
}
} while (!trackEnd);
}
//#pragma omp section //(逆时针)
{
......@@ -4694,7 +4691,7 @@ int eyemCountObjectIrregularPartsE(EyemImage tpImage, EyemRect tpRoi, const char
{
//不再判断,大概率已经终止
found = false;
}
}
else if (trackMat.ptr<uint8_t>(cvRound(trackCenterT.y))[cvRound(trackCenterT.x)] == 255) {
//不再判断,大概率已经终止
found = false;
......@@ -4743,9 +4740,9 @@ int eyemCountObjectIrregularPartsE(EyemImage tpImage, EyemRect tpRoi, const char
}
trackEnd = (!found);
} while (!trackEnd);
}
}
} while (!trackEnd);
}
}
}
//计数
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!