Commit a2f38dd2 张士柳

1 个父辈 56be4c30
......@@ -755,6 +755,12 @@ namespace eyemLib_Sharp
//通过名称获取模板
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemAchvModelByName(string ccTplName, IntPtr hModelID, ref EyemModelID tpModelID);
//插入模板
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemInsertModel(ref IntPtr hModelID, string ccTplName);
//通过名称移除模板
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemRemoveModelByName(ref IntPtr hModelID, string ccTplName);
//释放模板内存
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemReleaseModel(ref IntPtr hModelID);
......@@ -973,16 +979,30 @@ namespace eyemLib_Sharp
//flag = eyemCreateTemplateModel(tpDstImg, tpRoi2, matchDeg, "D:\\模板文件\\" + file.Replace(".png", ".tpl"));
//加载模板到内存
IntPtr hModelIDs = IntPtr.Zero;
IntPtr hModelID = IntPtr.Zero;
flag = eyemInitModel("D:\\模板文件", out hModelIDs);
flag = eyemInitModel("D:\\模板文件", out hModelID);
string selectModel = "";
flag = eyemMatchTemplateModel(tpDstImg, hModelIDs, ref selectModel);
flag = eyemMatchTemplateModel(tpDstImg, hModelID, ref selectModel);
//插入模板
flag = eyemInsertModel(ref hModelID, "D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl");
//根据名称获取模板
EyemModelID tpModelID = new EyemModelID();
eyemAchvModelByName(selectModel.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0], hModelIDs, ref tpModelID);
eyemAchvModelByName(selectModel.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0], hModelID, ref tpModelID);
//EyemImage tpModeImg = new EyemImage();
//tpModeImg.iChannels = 1; tpModeImg.iDepth = 0;
//tpModeImg.iWidth = tpModelID.iWidth; tpModeImg.iHeight = tpModelID.iHeight; tpModeImg.vpImage = tpModelID.vpImage;
//Bitmap bitmap = eyemCvtToBitmap(tpModeImg);
//if (bitmap != null)
//{
// bitmap.Save(System.Windows.Forms.Application.StartupPath + "\\ResOut\\" + file);
//}
//最好释放掉,如果对象供其他接口使用要先释放
eyemImageFree(ref tpDstImg);
......@@ -991,9 +1011,12 @@ namespace eyemLib_Sharp
//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.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0], hModelIDs, ref pNumObj, out tpDstImg);
eyemCountObjectIrregularPartsE(image, tpRoi, file.Replace(".png", ""), selectModel.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0], hModelID, ref pNumObj, out tpDstImg);
//eyemCountObjectIrregularPartsE(image, tpRoi, file.Replace(".png", ""), "D:\\模板文件\\" + /*file.Replace(".png", ".tpl")*/"74d571ed-9fd4-4959-85dd-3195261e4b48.tpl", ref pNumObj, out tpDstImg);
//移除模板
flag = eyemRemoveModelByName(ref hModelID, "D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl");
//Bitmap bitmap = eyemCvtToBitmap(tpDstImg);
//if (bitmap != null)
......@@ -1016,7 +1039,7 @@ namespace eyemLib_Sharp
Console.WriteLine("耗时:" + sw.ElapsedMilliseconds.ToString() + ",结果:" + pNumObj);
//在关闭程序时释放
eyemReleaseModel(ref hModelIDs);
eyemReleaseModel(ref hModelID);
//free image
eyemImageFree(ref tpDstImg);
eyemImageFree(ref image);
......@@ -1049,6 +1072,13 @@ namespace eyemLib_Sharp
//获取用于制作模板的图像
flag = eyemAchvTemplateImage(image, tpRoi, out tpDstImg);
//测试插入模板
//eyemInsertModel(ref hModelID, "D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl");
////测试获取模板
//EyemModelID tpModelID0 = new EyemModelID();
//eyemAchvModelByName("D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl", hModelID, ref tpModelID0);
string selectModel = "";
flag = eyemMatchTemplateModel(tpDstImg, hModelID, ref selectModel);
......@@ -1056,11 +1086,13 @@ namespace eyemLib_Sharp
EyemModelID tpModelID = new EyemModelID();
eyemAchvModelByName(selectModel.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0], hModelID, ref tpModelID);
//EyemImage tpModeImg = new EyemImage();
//tpModeImg.iChannels = 1; tpModeImg.iDepth = 0;
//tpModeImg.iWidth = tpModelID.iWidth; tpModeImg.iHeight = tpModelID.iHeight; tpModeImg.vpImage = tpModelID.vpImage;
EyemImage tpModeImg = new EyemImage();
tpModeImg.iChannels = 1; tpModeImg.iDepth = 0;
tpModeImg.iWidth = tpModelID.iWidth; tpModeImg.iHeight = tpModelID.iHeight; tpModeImg.vpImage = tpModelID.vpImage;
//Bitmap bitmap = eyemCvtToBitmap(tpModeImg);
string str = Marshal.PtrToStringAnsi(tpModelID.lpszName);
Bitmap bitmap = eyemCvtToBitmap(tpModeImg);
//if (bitmap != null)
//{
......@@ -1073,6 +1105,9 @@ namespace eyemLib_Sharp
//点料
eyemCountObjectIrregularPartsE(image, tpRoi, file.Replace(".png", ""), selectModel.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0], hModelID, ref pNumObj, out tpDstImg);
//测试移除模板
//eyemRemoveModelByName(ref hModelID, "D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl");
//free image
eyemImageFree(ref tpDstImg);
eyemImageFree(ref image);
......
......@@ -23,19 +23,33 @@ namespace eyemLib_Sharp
//}
//EyemLib.eyemTest2(fileNames);
//foreach (var item in fileNames)
//{
// EyemLib.eyemReadImageTool(item);
//}
//for (int i = 0; i < 1; i++)
//{
// EyemLib.eyemTestVideoCapture("D:\\插件完成检测\\视频\\WeChat2.mp4");
//}
IntPtr hModelID;
EyemLib.eyemInitModelE(out hModelID);
for (int i = 0; i < 5000; i++)
{
for (int j = 0; j < fileNames.Length; j++)
//for (int j = 0; j < fileNames.Length; j++)
//{
// EyemLib.eyemReadImageToolE(fileNames[j], hModelID);
//}
//并行测试
ParallelOptions po = new ParallelOptions();
po.MaxDegreeOfParallelism = 3;
Parallel.ForEach(fileNames, po, fn =>
{
EyemLib.eyemReadImageToolE(fileNames[j], hModelID);
}
EyemLib.eyemReadImageToolE(fn, hModelID);
});
}
EyemLib.eyemReleaseModelE(ref hModelID);
......
......@@ -1225,6 +1225,7 @@ int eyemDetectAndDecode(EyemImage tpImage, EyemRect tpRoi, const char *ccFileNam
bool eyemDetectAndDecodeFree(IntPtr hObject)
{
std::vector<EyemBarCode> *tpResults = reinterpret_cast<std::vector<EyemBarCode>*>(hObject);
//清空容器
tpResults->clear();
......
......@@ -894,9 +894,13 @@ bool eyemVideoCaptureFree(IntPtr hObject)
for (std::vector<EyemImage>::iterator it = tpImages->begin(); it != tpImages->end(); ++it)
{
(*it).iWidth = (*it).iHeight = (*it).iDepth = (*it).iChannels = 0;
free((*it).vpImage), (*it).vpImage = NULL;
EyemImage *tpImage = &(*it);
tpImage->iWidth = tpImage->iHeight = tpImage->iDepth = tpImage->iChannels = 0;
free(tpImage->vpImage), tpImage->vpImage = NULL;
}
//清空
tpImages->clear();
//释放
delete tpImages;
tpImages = NULL;
......
......@@ -853,8 +853,8 @@ extern "C" {
EXPORTS int eyemMatchTemplateModel(EyemImage tpImage, IntPtr hModelID, LPSTR *lpszTplName);
EXPORTS int eyemInitModel(const char *ccTplName, IntPtr *hModelID);
EXPORTS int eyemAchvModelByName(const char *ccTplName, IntPtr hModelID, EyemModelID &tpModelID);
EXPORTS int eyemInsertModel(const char *ccTplName, IntPtr hModelID, EyemModelID &tpModelID);
EXPORTS int eyemInsertModel(const char *ccTplName, IntPtr hModelID, EyemModelID &tpModelID);
EXPORTS int eyemInsertModel(IntPtr &hModelID, const char *ccTplName);
EXPORTS int eyemRemoveModelByName(IntPtr &hModelID, const char *ccTplName);
EXPORTS int eyemReleaseModel(IntPtr &hModelID);
EXPORTS int eyemTrackFeature(EyemImage tpPrevImg, EyemImage tpNextImg, EyemRect3 *tpRois, int iRoiNum, int *ipResults);
EXPORTS int eyemAOIForTSAV(EyemImage tpRefImg, EyemImage tpNextImg, EyemRect3 *tpRois, int iRoiNum);
......
......@@ -14,7 +14,7 @@
constexpr double c = PI / 180.;
//std::mutex mtx;
std::mutex mtx;
#endif/* __EYEM_MISC_H */
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!