Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用slide_match()时panic attempt to subtract with overflow #9

Closed
Amorter opened this issue Jun 12, 2024 · 22 comments
Closed

调用slide_match()时panic attempt to subtract with overflow #9

Amorter opened this issue Jun 12, 2024 · 22 comments

Comments

@Amorter
Copy link
Contributor

Amorter commented Jun 12, 2024

有些验证码图片不会panic有些会

bg
slice

@86maid
Copy link
Owner

86maid commented Jun 12, 2024 via email

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

attempt to subtract with overflow
thread 'tests::ddddocr_test' panicked at C:\Users\秦诗染.cargo\registry\src\rsproxy.cn-0dccff568467c15b\imageproc-0.23.0\src\edges.rs:63:17:
attempt to subtract with overflow
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\std\src\panicking.rs:645
1: core::panicking::panic_fmt
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\panicking.rs:72
2: core::panicking::panic
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library\core\src\panicking.rs:144
3: imageproc::edges::non_maximum_suppression
at C:\Users\秦诗染.cargo\registry\src\rsproxy.cn-0dccff568467c15b\imageproc-0.23.0\src\edges.rs:63
4: imageproc::edges::canny
at C:\Users\秦诗染.cargo\registry\src\rsproxy.cn-0dccff568467c15b\imageproc-0.23.0\src\edges.rs:49
5: ddddocr::slide_match<alloc::vec::Vec<u8,alloc::alloc::Global>,alloc::vec::Vec<u8,alloc::alloc::Global> >
at C:\Users\秦诗染.cargo\git\checkouts\ddddocr-9110ba4912ad61f7\01017dd\src\lib.rs:91
6: ddddocr::slide_match_with_path<ref$<str$>,ref$<str$> >
at C:\Users\秦诗染.cargo\git\checkouts\ddddocr-9110ba4912ad61f7\01017dd\src\lib.rs:117
7: biliTicker_gt::tests::ddddocr_test
at .\src\lib.rs:43
8: biliTicker_gt::tests::ddddocr_test::closure$0

没有搞反,因为我大部分样例都是能通过的,个别的会panic

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

python版本也有相同的错误

Traceback (most recent call last):
File "d:/Projects/reverse/gt3-python-sdk/demo/flask_demo/test.py", line 15, in
res = ocr.slide_match(slice, bg)
File "D:\DevEnvironment\anaconda3\envs\reverse\lib\site-packages\ddddocr_init_.py", line 2661, in slide_match
target = cv2.cvtColor(np.asarray(target), cv2.IMREAD_ANYCOLOR)
cv2.error: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:196: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

和rust的情况差不多有的就会这样,说明好像不是rust绑定的问题,看来我issue要提到原ddddocr那边了

@86maid
Copy link
Owner

86maid commented Jun 12, 2024 via email

@86maid
Copy link
Owner

86maid commented Jun 12, 2024 via email

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

我知道了,ddddocr的边缘检测会获取每一个像素的颜色,判断颜色的范围。python版本的判断之前有一个!src.empty()的断言,这个rust版本也加了一个unreachable!()的断言
image
我裁剪图片的时候不小心少裁剪了一行像素,导致有些图片缺口部分有透明像素,并且我是用PNG编码保存的,透明像素被保存下来了。然后ddddocr断言的时候就成空了.....话说png转换成Vec<8>居然tmd能变成空或者范围外的东西???

建议要不要加一层统一把图片变成JPG的转化或者过滤下异常像素?这样直接能解决原dddocr项目中的问题

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

image
这些条条是空白像素吗

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

我知道了,ddddocr的边缘检测会获取每一个像素的颜色,判断颜色的范围。python版本的判断之前有一个!src.empty()的断言,这个rust版本也加了一个unreachable!()的断言 image 我裁剪图片的时候不小心少裁剪了一行像素,导致有些图片缺口部分有透明像素,并且我是用PNG编码保存的,透明像素被保存下来了。然后ddddocr断言的时候就成空了.....话说png转换成Vec<8>居然tmd能变成空或者范围外的东西???

建议要不要加一层统一把图片变成JPG的转化或者过滤下异常像素?这样直接能解决原dddocr项目中的问题

好像不是这个问题。。。。我修复后在其他实例还是出现了相同的问题

@86maid
Copy link
Owner

86maid commented Jun 12, 2024 via email

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

image
你是对的

@86maid
Copy link
Owner

86maid commented Jun 12, 2024 via email

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

image
这一步的height还是正常的
image
进入到canny内就变成0了,这是什么原因?

@86maid
Copy link
Owner

86maid commented Jun 12, 2024 via email

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

且你调试的变

对不起,眼瞎了,我再跟踪下

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

这里是 0,而且你调试的变量错了。。。

------------------ 原始邮件 ------------------ 发件人: "86maid/ddddocr" @.>; 发送时间: 2024年6月13日(星期四) 凌晨0:01 @.>; @.@.>; 主题: Re: [86maid/ddddocr] 调用slide_match()时panic attempt to subtract with overflow (Issue #9) image.png (view on web) 这一步的height还是正常的 image.png (view on web) 进入到canny内就变成0了,这是什么原因? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

大佬,我这边用不panic的样例测试,进入到canny之后height就已经不是0了哇

@86maid
Copy link
Owner

86maid commented Jun 12, 2024 via email

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

你看看这个地方,这个是判断像素的透明通道的

------------------ 原始邮件 ------------------ 发件人: "86maid/ddddocr" @.>; 发送时间: 2024年6月13日(星期四) 凌晨0:11 @.>; @.@.>; 主题: Re: [86maid/ddddocr] 调用slide_match()时panic attempt to subtract with overflow (Issue #9) 这里是 0,而且你调试的变量错了。。。 … ------------------ 原始邮件 ------------------ 发件人: "86maid/ddddocr" @.>; 发送时间: 2024年6月13日(星期四) 凌晨0:01 @.>; @.@.>; 主题: Re: [86maid/ddddocr] 调用slide_match()时panic attempt to subtract with overflow (Issue #9) image.png (view on web) 这一步的height还是正常的 image.png (view on web) 进入到canny内就变成0了,这是什么原因? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 大佬,我这边用不panic的样例测试,进入到canny之后height就已经不是0了哇 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

好的,我理解您的意思了

@Amorter
Copy link
Contributor Author

Amorter commented Jun 12, 2024

您好,我debug了很久还是不清楚问题出在哪
于是我找到了有关ddddocr的一个issue,好像和这个问题有点关系
sml2h3/ddddocr#163

@86maid
Copy link
Owner

86maid commented Jun 13, 2024 via email

@86maid
Copy link
Owner

86maid commented Jun 13, 2024

试试

@Amorter
Copy link
Contributor Author

Amorter commented Jun 13, 2024

试试

好的

@Amorter
Copy link
Contributor Author

Amorter commented Jun 13, 2024

牛逼,神医

@Amorter Amorter closed this as completed Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants