-
-
Notifications
You must be signed in to change notification settings - Fork 25
Crash when using Mat.atNum traverse pixel for a jpeg image #321
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
Comments
@cuishijie1991 Sorry for the late reply. I have just tested your code and there are some errors. First of all, always use For better performance, these methods do not have bound check, and will operate native pointer directly, which means, if you do not check the bound manually, there will be a risk of pointer invalid access issue. Now, for your app, check for (var y = 0; y < h; y++) {
for (var x = 0; x < w; x++) {
pixelCache.add(im.atNum(x, y) as int); // here, you should use atNum(y, x)
}
} and for (var y = 0; y < h; y++) {
for (var x = 0; x < w; x++) {
im.setNum(x, y, pixelCache[y * w + x]); // you should use setNum(y, x)
}
} Now, it works, However, your code could be improved.
Hope it helps. |
@rainyl |
Hi,
I use opencv_dart to traverse the image pixels, use the Floyd-Steinberg algorithm to process the value of each pixel, and reassign the value to use the dithering effect.
Everything was fine at the beginning of the test, but when I tested a jpeg image, I found that the Mat.atNum method started to throw an exception when it executed a certain pixel point.
I tested iOS and Android platforms, and this problem occurred for this image. I will provide the test code and images. If possible, please help me find the reason, thank you!
image file

test sample
Build fingerprint: 'Xiaomi/fuxi/fuxi:15/AQ3A.240912.001/OS2.0.3.0.VMCCNXM:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2025-01-18 14:38:10.513210568+0800
Process uptime: 17s
Cmdline: com.example.test
pid: 24553, tid: 24712, name: 1.ui >>> com.example.test <<<
uid: 10417
tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
pac_enabled_keys: 000000000000000f (PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY, PR_PAC_APDBKEY)
signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xb40000706ee7f000
x0 0000006f006db4c1 x1 0000006f06e586a9 x2 0000000000000000 x3 b40000706ee7f000
x4 0000006f0000a431 x5 0000006f06dde861 x6 0000006f06dde8b0 x7 0000000000001682
x8 0000000000000007 x9 0000000000000047 x10 000000709ac3bbb8 x11 0000000000000001
x12 000000000003c020 x13 0000000000000000 x14 0000000000000001 x15 00000070a38ce618
x16 00000070a36eb000 x17 0000006f06dde8c1 x18 0000007091474000 x19 000000706ee90e20
x20 b400007181334c60 x21 b40000721138f990 x22 0000006f00008081 x23 0000006f0043d779
x24 0000006f06da7391 x25 00000070a36ea000 x26 b40000721138f990 x27 0000006f00009c70
x28 000000080000006f x29 00000070a38ce628
lr 000000706ee910a8 sp 00000070a36ea000 pc 000000706ee877b0 pst 0000000000001000
1 total frames
backtrace:
#00 pc 00000000000077b0 [anon:dart-code]
frame #0: 0x0000000138116524
-> 0x138116524: ldrb w1, [x0]
0x138116528: mov x0, x1
0x13811652c: lsl x1, x0, Support macOS apple silicon #1
0x138116530: mov x0, x1
Target 0: (Runner) stopped.
The text was updated successfully, but these errors were encountered: