修复定义多个模板时的bug(前面图片绘制的模板区域会保留在后面的图片)

This commit is contained in:
zjc-zjc-123 2024-11-21 21:17:27 +08:00
parent 38202919e6
commit 445d6fc37c

View File

@ -63,6 +63,7 @@ void TemplateMatcher::loadTemplates(const std::vector<std::string>& template_pat
// Define templates
for (size_t i = 0; i < template_paths.size(); ++i) {
MIL_ID template_temporary;
MgraClear(M_DEFAULT, GraphicList);
MbufRestore(convert_to_wstring(ModelImgPaths[i]).c_str(), MilSystem, &template_temporary);
MIL_ID template_temporary_uint8 = convert_to_uint8(template_temporary);
if (this->param["isdisplay"] == 1)
@ -176,13 +177,15 @@ void TemplateMatcher::LoadTemplate(TemplateMatcher& matcher, std::map<std::strin
"C:\\Users\\zjc\\Desktop\\templates\\template1.png",
"C:\\Users\\zjc\\Desktop\\templates\\template2.png",
"C:\\Users\\zjc\\Desktop\\templates\\template3.png",
"C:\\Users\\zjc\\Desktop\\templates\\template2.png",
"C:\\Users\\zjc\\Desktop\\templates\\template4.png",
"C:\\Users\\zjc\\Desktop\\templates\\template5.png",
"C:\\Users\\zjc\\Desktop\\templates\\template6.png",
},
{0, 20, 30, 33}, // offsetX
{0, 20, 30, 33}, // offsetY
{100, 60, 40, 33}, // sizeX
{100, 60, 40, 33}, // sizeY
{M_COLOR_RED, M_COLOR_GREEN, M_COLOR_BLUE, M_COLOR_GREEN} // drawColor
{0, 20, 30, 10,10,10}, // offsetX
{0, 20, 30, 10,10,10}, // offsetY
{100, 60, 60, 66,66,66}, // sizeX
{100, 60, 60, 66,66,66}, // sizeY
{M_COLOR_RED, M_COLOR_GREEN, M_COLOR_BLUE, M_COLOR_GREEN,M_COLOR_BLUE,M_COLOR_BLUE} // drawColor
);
}
@ -199,7 +202,8 @@ void TemplateMatcher::FindTemplates( const MIL_ID& inputImage,const MIL_ID& outp
//TODO: 2加入配置文件解析功能解析后的文件与当前的para map<string, int>兼容
// 配置文件当中加入是否显示参数,能调控加载模板的过程是否显示。已
//TODO: 3修改当前的代码使模板匹配不出错 已
//TODO: 4成立模板文件夹能够加载文件夹下的全部模板并实现检测
//TODO: 4成立模板文件夹能够加载文件夹下的全部模板并实现检测
//TODO: 5制作标准结构的函数例如matcher.findModels(MIL_ID inputImage, MIL_ID output_image, map);
//TODO: 6完善相应部分的手册
////未实现,因为加载和寻找分开后,要对加载和寻找函数传入类成员,无法统一,其余可用到的参数统一,加一个类成员即可。
//TODO: 6完善相应部分的手册 已