shape_based_matching icon indicating copy to clipboard operation
shape_based_matching copied to clipboard

图片缩小2倍,引发程序崩溃

Open wly2020-robot opened this issue 4 years ago • 98 comments

你好!我把模板图像和要检测图像分别缩小2倍,进行训练和检测,但是在运行这行代码:std::vectorline2Dup::Match matches = detector.match(padded_img, ui->matchThreshSpinBox->value(), ids);会出现程序崩溃;如果不缩放,程序正常运行。

wly2020-robot avatar Jan 05 '21 11:01 wly2020-robot

我指的缩小是用resize函数实现的。

wly2020-robot avatar Jan 05 '21 11:01 wly2020-robot

请问在match函数中是不是有异常没有处理呢?

wly2020-robot avatar Jan 05 '21 12:01 wly2020-robot

非fusion branch需要满足图像大小是8的整数倍

meiqua avatar Jan 05 '21 13:01 meiqua

我把测试图像长宽大小都调到8的整数倍,一样在match函数处,导致整个程序退出。

wly2020-robot avatar Jan 06 '21 13:01 wly2020-robot

说错了,16的倍数

meiqua avatar Jan 06 '21 14:01 meiqua

我把padding_ing大小调整到了16的整数倍,一样在match程序异常退出。

wly2020-robot avatar Jan 07 '21 02:01 wly2020-robot

而且不是立即退出,是连续检测了几分钟后在match函数退出。

wly2020-robot avatar Jan 07 '21 03:01 wly2020-robot

没碰到过这种情况,有什么报错或log吗

meiqua avatar Jan 07 '21 12:01 meiqua

还在测试;我循环每间隔300ms从摄像头获取一张2448*2048大小图片,进行单个对象检测,测试下来没发现会异常退出。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月7日(星期四) 晚上8:41 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

没碰到过这种情况,有什么报错或log吗

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 07 '21 12:01 wly2020-robot

但是对原图像用resize进行缩小,检测就会在match函数出异常退出问题。还有就是在视场内放多个检测对象也会在macth函数异常退出。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月7日(星期四) 晚上8:41 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

没碰到过这种情况,有什么报错或log吗

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 07 '21 12:01 wly2020-robot

测试下来,感觉图片大小要满足16整数倍关系与异常退出关系不到。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月7日(星期四) 晚上8:41 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

没碰到过这种情况,有什么报错或log吗

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 07 '21 12:01 wly2020-robot

大小不对是直接crash。多个检测对象异常是直接还是也跑一会才异常?

meiqua avatar Jan 07 '21 13:01 meiqua

match函数异常程序直接退出有,但比较少;一般都是运行几分钟左右就在match函数处退出。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月7日(星期四) 晚上9:04 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

大小不对是直接crash。多个检测对象异常是直接还是也跑一会才异常?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 07 '21 13:01 wly2020-robot

有报错信息吗

meiqua avatar Jan 07 '21 13:01 meiqua

跑程序没有报任何错。我明天在调试模式下,看看是否报错。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月7日(星期四) 晚上9:14 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

有报错信息吗

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 07 '21 13:01 wly2020-robot

今天用VS的debug模式下跑了一天没有出现异常。但是debug模式检测速度很慢,将近2.5S检测一次,release模式60ms检测一次,循环加压检测这样。但是release模式很容易在match函数异常退出。

wly2020-robot avatar Jan 08 '21 13:01 wly2020-robot

可以分段打log,看看在哪退出

meiqua avatar Jan 08 '21 13:01 meiqua

我之前就是在release模式下跑程序分段打log,每次程序异常退出都是定位在match函数的log,之后就没有相关的log信息。这个debug不好弄呀。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月8日(星期五) 晚上9:47 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

可以分段打log,看看在哪退出

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 09 '21 01:01 wly2020-robot

我的意思是在match里面插满log,看看在哪退出

meiqua avatar Jan 09 '21 09:01 meiqua

好的。非常感谢。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月9日(星期六) 下午5:13 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

我的意思是在match里面插满log,看看在哪退出

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 09 '21 09:01 wly2020-robot

你好。我在match函数中分段插入log信息,在视场中添加两个或多个检测对象时,match函数中的matchClass(lm_pyramid, sizes, threshold, matches, it->first, it->second);-> for (int32_t template_id = 0; template_id < template_pyramids.size(); ++template_id);for循环中一定会立即使程序运行异常退出;因为在for循环中插入log信息,算法检测时间大增,程序不会退出,所以在for循环中不好定位是哪个程序段有问题。在视场中只添加一个检测对象,相对比较稳定,但是偶尔也会在match函数中的std::vectorcv::Mat out_v = lm_pyramid[cur_l][0];处程序异常退出。 以下是测试异常场景: 1 视场中添加到3个时,程序异常立即退出; 三个 2:视场中添加2个不相交,运行一段时间程序异常退出; 不交叉 3:视场中添加两个,并交叉,程序立即异常退出。 Uploading 交叉.png…

wly2020-robot avatar Jan 11 '21 09:01 wly2020-robot

补充一下,视场中两个不相交对象,检测一段时间,整个软件界面操作程序卡死不动,也不退出。

wly2020-robot avatar Jan 11 '21 10:01 wly2020-robot

你改过里面的代码吗?

meiqua avatar Jan 11 '21 11:01 meiqua

检测多少个应该没啥影响

meiqua avatar Jan 11 '21 11:01 meiqua

没有的,只是加了一些log信息

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月11日(星期一) 晚上7:50 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

你改过里面的代码吗?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 11 '21 11:01 wly2020-robot

立即退出的情况试试debug,看有什么报错?

meiqua avatar Jan 11 '21 11:01 meiqua

好奇怪,debug调试模式,不会发生异常。异常退出全部都是在release模式。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月11日(星期一) 晚上7:53 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

立即退出的情况试试debug,看有什么报错?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 11 '21 11:01 wly2020-robot

想起来了,之前融合fusion和ICP版本时候,修改了不同之处。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月11日(星期一) 晚上7:53 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

立即退出的情况试试debug,看有什么报错?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 11 '21 11:01 wly2020-robot

你好,通过测试和对比,基本确定导致程序退出代码段;我在matchClass函数中for循环前和后分别添加了如下代码段:

#ifdef _OPENMP  #pragma omp parallel   {  #endif    std::vector<Match> match_private;  #ifdef _OPENMP  #pragma omp for nowait  #endif 

 #ifdef _OPENMP  #pragma omp critical    {  #endif    matches.insert(matches.end(), match_private.begin(), match_private.end());  #ifdef _OPENMP    }   }  #endif

删除该代码段,之前说的情况不会导致程序退出。

但是从测试来看,当视场中检测物(相关或不相关)越多时,检测时间会有明显提升;而加入上面那段,并行运算代码,检测时间也会上升,但是变化幅度不大。如果要使用并行计算,如何优化?谢谢。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月11日(星期一) 晚上7:53 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] 图片缩小2倍,引发程序崩溃 (#122)

立即退出的情况试试debug,看有什么报错?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wly2020-robot avatar Jan 12 '21 07:01 wly2020-robot

很多干扰字符

meiqua avatar Jan 12 '21 12:01 meiqua