chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
748 stars 127 forks source link

cv2.imread() returns slightly different value between real Android tablet devices and PC (Windows) or Android emulator #1127

Closed eldon922 closed 2 months ago

eldon922 commented 3 months ago

Chaquopy version

15.0.1

Devices or emulators where the issue happens

Real Android tablet devices

Relevant parts of your code

cv2.imread(join(os.environ["HOME"], imagePath))

Describe your issue

I write the array values to a text file and compare the results between them. However, they are slightly different, which affects our subsequent processes. Is there an alternative function that ensures consistent values regardless of the machine used?

mhsmith commented 3 months ago

What do you mean by "slightly different"? Could the difference be caused by different versions of NumPy or OpenCV? Check the build log to find which versions your app is using – you can force pip to run again by making any change to the pip block in your build.gradle file. Then try using those same versions on Windows.

eldon922 commented 3 months ago

What do you mean by "slightly different"? Could the difference be caused by different versions of NumPy or OpenCV? Check the build log to find which versions your app is using – you can force pip to run again by making any change to the pip block in your build.gradle file. Then try using those same versions on Windows.

image The difference lies in the numbers; they are only slightly different. I don't believe this discrepancy is caused by variations in dependencies, as the values differ between the real device and emulator, both of which are using the exact same build.

I believe this is caused by different codecs that used for reading image? Reference. Are there any ways to set what codecs used?

mhsmith commented 2 months ago

So you've tried 3 devices: Android emulator, Android table, and Windows. Are all 3 of them different, or are 2 of them the same? If the Android emulator is the same as Windows, but the Android tablet is different, then it could be an x86 vs ARM difference.

Can you attach an image file which shows the issue?

eldon922 commented 2 months ago

Sorry, it turns out the bitmap compress function that i use to copy the image caused this discrepancy issue. Thank you for the response image