Different result between Python and Android

asked 2020-01-23 07:22:01 -0500

ThomasRy gravatar image

Hi everyone,

I am trying to use a Pytorch model on Android and to do so, I am using OpenCv to do the pre processing.

My pre processing is composed of 3 steps: - greyscaling - resizing - normalize images [-1,1] (not with OpenCv)

However when I do the resizing on Android, i got different values compared to Python. I have checked that the input data are exactly the same. I have tried the official version and javacv one. They give exactly the same output (different from python). The images have the same dimension in both languages.

First values in python 122 121 125 125 124 129 125 126 130 132 130 131 131 130 127 127 130 129

First values in java 120 124 128 127 133 131 131 128 132 131 130 138 131

Python snippet : https://pastebin.com/vd7NWD4P Android snippet: https://pastebin.com/zgqsW4SV

edit retag flag offensive close merge delete


The thing to do is to figure out which one is correct and then find the problem in the other. Mske a test image with which you can manually calculate what numbers it should produce.

Note that you are now comparing a programming language with an operating system... OpenCV programs on Android can be written in languages other than Java

mvuori gravatar imagemvuori ( 2020-01-23 13:03:29 -0500 )edit