opencv difference between android and pc

asked 2014-07-02 05:14:54 -0600

Croc gravatar image

I am writing an android application which is doing image processing- I am using same jpg image for Android and PC. My code consists of library code with JNI access which accepts Mat object and returns the mean values for RGB Code in library is

cv::Scalar Lum_Y, stDEV_Y, Lum_BGR, stDEV_BGR;
double  Lum_Y_orig, stDEV_Y_orig, Slope_orig;

meanStdDev(ROIImage,Lum_Y,stDEV_Y);

Logger::getInstance()->log("Origin_Mean_R",Lum_Y.val[2]);

Logger::getInstance()->log("Origin_Mean_G",Lum_Y.val[1]); Logger::getInstance()->log("Origin_Mean_B",Lum_Y.val[0]);

When I am running this method from my PC i get results which are correspondant to Photoshop and ImageJ. When i am running the same exact code from android the results are diffrent - how much ? by +- 1. This different in crucial to my algorithm.

I verified both images are loaded as BGR , in the Android part i do this:

Bitmap bim = BitmapFactory.decodeStream(imageStream);

Mat ImageMat = new Mat ( bim.getHeight(), bim.getWidth(), CvType.CV_8UC4, new Scalar(4));
Bitmap myBitmap32 = bim.copy(Bitmap.Config.ARGB_8888, true);
Utils.bitmapToMat(myBitmap32,ImageMat);

//ImageMat.convertTo(m, rtype);.
Mat mat2 = new Mat();
Imgproc.cvtColor(ImageMat, mat2, Imgproc.COLOR_RGBA2BGR);

I even tried running opencv mean calc directly from android and the results were exactly the same as running from JNI.

Can someone help on this issue ? it seems to me as this is way big of a difference to originate from truncation.

Thanks in advance.

edit retag flag offensive close merge delete