shape_based_matching icon indicating copy to clipboard operation
shape_based_matching copied to clipboard

arm+linux算法运行能否加速?

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

你好。我是fusion+icp融合版本;在电脑上运行,耗时:70ms左右;移植到瑞芯微RK339 上的arm+linux上运行400ms左右?检测图片已经resize 缩小2倍进行测试;请问算法方面能否加速?使得耗时控制在70ms左右?谢谢。

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

不用icp耗时多少?

meiqua avatar Jan 11 '21 11:01 meiqua

时间变化不大

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

请问你之前在TX2上跑,耗时多少?是用哪个版本?谢谢

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

之前试过master branch,130万无icp像素约150ms

meiqua avatar Jan 11 '21 12:01 meiqua

我的是500W像素的,加上边框估计去到600W,400ms也差不多。能优化吗?这耗时

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月11日(星期一) 晚上8:22 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

之前试过master branch,130万无icp像素约150ms

— 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 12:01 wly2020-robot

不过,我测试图片resize缩小2倍了。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月11日(星期一) 晚上8:22 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

之前试过master branch,130万无icp像素约150ms

— 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 12:01 wly2020-robot

可以把主频 像素 各部分时间详细列一下?你说的时间包含resize什么的吗

meiqua avatar Jan 11 '21 12:01 meiqua

好的,我罗列一下发给你。包括的,非常感谢。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月11日(星期一) 晚上8:51 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

可以把主频 像素 各部分时间详细列一下?你说的时间包含resize什么的吗

— 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 12:01 wly2020-robot

你好,我把QT中的QMAKE_CXXFLAGS += -fopenmp和LIBS += -fopenmp注释,检测时间稳定在260ms左右,而且CPU使用率200%左右,像这种还有没有方法提升CPU的使用速率,以缩短检测时间,提升速率。没注释,检测时间变动比较大,变动范围210ms-380ms,CPU使用率在400%左右。

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

看上去多线程用处不大,可能是内存读写的瓶颈吧

meiqua avatar Jan 29 '21 13:01 meiqua

实时检测,我看内存使用也不大,足够用了。 下面是arm-linux下linux系统资源监测器的一个截图: 7d41796c1931f15e95bc6b70155439c

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

内存读写速度是被硬件限制了吗?在系统层面或应用层面有没有改善的方案?

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

内存大小应该是够的,读写速度可能硬件就只支持这么多

meiqua avatar Jan 30 '21 03:01 meiqua

换个读写速度快点的flash会不会好点?

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

要是这样,内存读写速度跟不上CPU节拍。在硬件层面是不是内存flash与CPU没有搭配好呢?

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

不是的,不同应用需要的memory bandwidth / cpu speed不同;这种情况下,cpu利用率提升两倍,但速度基本没变,所以可能是内存读写速度到顶了。

meiqua avatar Jan 30 '21 03:01 meiqua

那我可以理解为在系统或软件层面,不管怎么加速,以当前我的硬件配置,运用这个匹配算法,要满足我耗时200MS以下速率,是做不到的?

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

不知道图像用的是灰度还是彩色?转成单通道的,再缩小一点可能可以

meiqua avatar Jan 30 '21 11:01 meiqua

我使用的是黑白相机;当前已经对500W像素黑白图像做了1/2的resize处理。但是在arm-linux系统上跑起来耗时在260ms左右,我希望算法耗时能优化在170ms左右就好了。之前有看到你说在TX2上跑130万无ICP像素约150ms,我正在采购130W像素相机和镜头,看看能不能再arm-linux满足精度前提下跑出这个检测速率效果。

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年1月30日(星期六) 晚上7:57 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

不知道图像用的是灰度还是彩色?转成单通道的,再缩小一点可能可以

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

wly2020-robot avatar Feb 01 '21 01:02 wly2020-robot

是的,可以都尝试一下,不同相机,不同arm板

---原始邮件--- 发件人: "wly2020-robot"<[email protected]> 发送时间: 2021年2月1日(周一) 上午9:39 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "meiqua"<[email protected]>;"Comment"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

我使用的是黑白相机;当前已经对500W像素黑白图像做了1/2的resize处理。但是在arm-linux系统上跑起来耗时在260ms左右,我希望算法耗时能优化在170ms左右就好了。之前有看到你说在TX2上跑130万无ICP像素约150ms,我正在采购130W像素相机和镜头,看看能不能再arm-linux满足精度前提下跑出这个检测速率效果。

------------------&nbsp;原始邮件&nbsp;------------------ 发件人: "meiqua/shape_based_matching" <[email protected]&gt;; 发送时间:&nbsp;2021年1月30日(星期六) 晚上7:57 收件人:&nbsp;"meiqua/shape_based_matching"<[email protected]&gt;; 抄送:&nbsp;"正在输入........"<[email protected]&gt;;"Author"<[email protected]&gt;; 主题:&nbsp;Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

不知道图像用的是灰度还是彩色?转成单通道的,再缩小一点可能可以

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

meiqua avatar Feb 01 '21 02:02 meiqua

请问在检测的时候能不能优化掉pading?

------------------ 原始邮件 ------------------ 发件人: "meiqua/shape_based_matching" <[email protected]>; 发送时间: 2021年2月1日(星期一) 上午10:36 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "正在输入........"<[email protected]>;"Author"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

是的,可以都尝试一下,不同相机,不同arm板

---原始邮件--- 发件人: "wly2020-robot"<[email protected]&gt; 发送时间: 2021年2月1日(周一) 上午9:39 收件人: "meiqua/shape_based_matching"<[email protected]&gt;; 抄送: "meiqua"<[email protected]&gt;;"Comment"<[email protected]&gt;; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

我使用的是黑白相机;当前已经对500W像素黑白图像做了1/2的resize处理。但是在arm-linux系统上跑起来耗时在260ms左右,我希望算法耗时能优化在170ms左右就好了。之前有看到你说在TX2上跑130万无ICP像素约150ms,我正在采购130W像素相机和镜头,看看能不能再arm-linux满足精度前提下跑出这个检测速率效果。

------------------&amp;nbsp;原始邮件&amp;nbsp;------------------
发件人: "meiqua/shape_based_matching" <[email protected]&amp;gt;;
发送时间:&amp;nbsp;2021年1月30日(星期六) 晚上7:57
收件人:&amp;nbsp;"meiqua/shape_based_matching"<[email protected]&amp;gt;;
抄送:&amp;nbsp;"正在输入........"<[email protected]&amp;gt;;"Author"<[email protected]&amp;gt;;
主题:&amp;nbsp;Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

不知道图像用的是灰度还是彩色?转成单通道的,再缩小一点可能可以


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

wly2020-robot avatar Feb 01 '21 02:02 wly2020-robot

本来padding就没用,是为了撑大点测试

---原始邮件--- 发件人: "wly2020-robot"<[email protected]> 发送时间: 2021年2月1日(周一) 上午10:38 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "meiqua"<[email protected]>;"Comment"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

请问在检测的时候能不能优化掉pading?

------------------&nbsp;原始邮件&nbsp;------------------ 发件人: "meiqua/shape_based_matching" <[email protected]&gt;; 发送时间:&nbsp;2021年2月1日(星期一) 上午10:36 收件人:&nbsp;"meiqua/shape_based_matching"<[email protected]&gt;; 抄送:&nbsp;"正在输入........"<[email protected]&gt;;"Author"<[email protected]&gt;; 主题:&nbsp;Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

是的,可以都尝试一下,不同相机,不同arm板

---原始邮件---
发件人: "wly2020-robot"<[email protected]&amp;gt;
发送时间: 2021年2月1日(周一) 上午9:39
收件人: "meiqua/shape_based_matching"<[email protected]&amp;gt;;
抄送: "meiqua"<[email protected]&amp;gt;;"Comment"<[email protected]&amp;gt;;
主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

我使用的是黑白相机;当前已经对500W像素黑白图像做了1/2的resize处理。但是在arm-linux系统上跑起来耗时在260ms左右,我希望算法耗时能优化在170ms左右就好了。之前有看到你说在TX2上跑130万无ICP像素约150ms,我正在采购130W像素相机和镜头,看看能不能再arm-linux满足精度前提下跑出这个检测速率效果。

------------------&amp;amp;nbsp;原始邮件&amp;amp;nbsp;------------------
发件人: "meiqua/shape_based_matching" <[email protected]&amp;amp;gt;;
发送时间:&amp;amp;nbsp;2021年1月30日(星期六) 晚上7:57
收件人:&amp;amp;nbsp;"meiqua/shape_based_matching"<[email protected]&amp;amp;gt;;
抄送:&amp;amp;nbsp;"正在输入........"<[email protected]&amp;amp;gt;;"Author"<[email protected]&amp;amp;gt;;
主题:&amp;amp;nbsp;Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

不知道图像用的是灰度还是彩色?转成单通道的,再缩小一点可能可以


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

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

meiqua avatar Feb 01 '21 02:02 meiqua

我说的检测流程中的pading哦,不是train中的pading.

wly2020-robot avatar Feb 01 '21 02:02 wly2020-robot

我测试了,在去掉检测流程中关于padding相关代码,定位会有一个比较大的偏移。 去掉padding相关代码: cv::Mat padded_img = cv::Mat(processImage.rows + 2 * padding, processImage.cols + 2 * padding, processImage.type(), cv::Scalar::all(0)); processImage.copyTo(padded_img(cv::Rect(padding, padding, processImage.cols, processImage.rows)));

修改代码: float train_img_half_width = templWidth / 2.0f + padding; float train_img_half_height = templHeight / 2.0f + padding;

改为: float train_img_half_width = templWidth / 2.0f; float train_img_half_height = templHeight / 2.0f ;

绘制定位位置代码: cv::RotatedRect rotatedRectangle({ centerPoint.x, centerPoint.y }, { 2 * r_scaledWscaleIndex ,2 * r_scaledHscaleIndex }, -m_infos[match.t emplate_id].angle); cv::Point2f vertices[4]; rotatedRectangle.points(vertices); for (int i = 0; i < 4; i++) { int next = (i + 1 == 4) ? 0 : (i + 1); cv::line(outputImage, vertices[i], vertices[next], cv::Scalar(255, 255, 255), 2); }

wly2020-robot avatar Feb 01 '21 03:02 wly2020-robot

我说的也是

---原始邮件--- 发件人: "wly2020-robot"<[email protected]> 发送时间: 2021年2月1日(周一) 上午10:55 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "meiqua"<[email protected]>;"Comment"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

我说的检测流程中的pading哦,不是train中的pading.

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

meiqua avatar Feb 01 '21 03:02 meiqua

不加icp,正常检测误差约2pixel

---原始邮件--- 发件人: "wly2020-robot"<[email protected]> 发送时间: 2021年2月1日(周一) 中午11:06 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "meiqua"<[email protected]>;"Comment"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

我测试了,在去掉检测流程中关于padding相关代码,定位会有一个比较大的偏移。 去掉padding相关代码: cv::Mat padded_img = cv::Mat(processImage.rows + 2 * padding, processImage.cols + 2 * padding, processImage.type(), cv::Scalar::all(0)); processImage.copyTo(padded_img(cv::Rect(padding, padding, processImage.cols, processImage.rows)));

修改代码: float train_img_half_width = templWidth / 2.0f + padding; float train_img_half_height = templHeight / 2.0f + padding;

改为: float train_img_half_width = templWidth / 2.0f; float train_img_half_height = templHeight / 2.0f ;

绘制定位位置代码: cv::RotatedRect rotatedRectangle({ centerPoint.x, centerPoint.y }, { 2 * r_scaledWscaleIndex ,2 * r_scaledHscaleIndex }, -m_infos[match.t emplate_id].angle); cv::Point2f vertices[4]; rotatedRectangle.points(vertices); for (int i = 0; i < 4; i++) { int next = (i + 1 == 4) ? 0 : (i + 1); cv::line(outputImage, vertices[i], vertices[next], cv::Scalar(255, 255, 255), 2); }

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

meiqua avatar Feb 01 '21 03:02 meiqua

我的是加了icp的。 考虑到检测点数,在train中加了padding;在检测流程中,考虑检测耗时,没有加pading。修改padding相关的代码,发现定位有很大偏移。 下面是检测不正常偏移的效果图: 微信图片_20210201111410

wly2020-robot avatar Feb 01 '21 03:02 wly2020-robot

这是transform写错了

---原始邮件--- 发件人: "wly2020-robot"<[email protected]> 发送时间: 2021年2月1日(周一) 中午11:15 收件人: "meiqua/shape_based_matching"<[email protected]>; 抄送: "meiqua"<[email protected]>;"Comment"<[email protected]>; 主题: Re: [meiqua/shape_based_matching] arm+linux算法运行能否加速? (#126)

我的是加了icp的。 考虑到检测点数,在train中加了padding;在检测流程中,考虑检测耗时,没有加pading。修改padding相关的代码,发现定位有很大偏移。 下面是检测不正常偏移的效果图:

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

meiqua avatar Feb 01 '21 03:02 meiqua

嗯,调整过来了,去掉padding,得到检测速率去到170ms左右。谢谢

wly2020-robot avatar Feb 01 '21 03:02 wly2020-robot

经过测试,被测试目标轮廓也复杂或者背景轮廓复杂,这个检测耗时会有大幅度提升,请问这是正常的吗?如果是正常,能否做优化?谢谢。

wly2020-robot avatar Feb 04 '21 02:02 wly2020-robot