Ask Your Question

aguys91's profile - activity

2016-08-29 04:44:43 -0600 commented question Image processing in Android and in Java (Eclipse) has different results

Thanks! I'm actually trying to figure out how to follow the suggestion, as I can only find Utils.bitmapToMat() and no implementations with png. I hope to solve this soon :)

2016-08-28 09:02:05 -0600 commented question Image processing in Android and in Java (Eclipse) has different results

The real problem is that in Android I got wrong results, so I guess that in my particular case, the photo stored as jpeg let me do better processing (I can't understand why and how). I need to compare colors. For one specific pixel, I have to choose from 5 different colors which one is more similar. In Android, just to say, when I have light pink, the chosen color is dark brown (and in Eclipse light pink).

2016-08-28 08:50:05 -0600 asked a question Image processing in Android and in Java (Eclipse) has different results

I'm having a strange problem trying to do some image processing. I've developed a script in Eclipse that does some processing with an image and returns a list of values about color comparing between fixed pixels of the image. In the processing I do these actions in the following order:

  • Resizing
  • Contours detection
  • Warp transformation
  • Conversion from BGR to Lab
  • Fixed pixels value comparison using Delta

I've implemented the exact same code in Android.

In Android I take a photo with the native camera, save it in the gallery, and pass the path of the photo in an intent, like this:

Intent intent = new Intent(this, ElaborationActivity.class);
intent.setData(Uri.parse(mCurrentPhotoPath));
startActivity(intent);

Then, in the new activity (the one that does the elaboration), I load the image and start the processing doing so:

String photoPath = getIntent().getData().toString();
Bitmap intentPhoto = BitmapFactory.decodeFile(photoPath);
Mat imgOr = new Mat();
Utils.bitmapToMat(intentPhoto, imgOr);
Elaboration ImElab = new Elaboration(imgOr.height(), imgOr.width());

In Eclipse I start the processing in this way:

Mat imgOr = Imgcodecs.imread(fileName);
ImageElaboration ImElab = new ImageElaboration(imgOr.height(), imgOr.width());

The rest of the code is exactly the same. The problem is that the elaboration done in Eclipse is way more precise and if I load in Eclipse the photo captured with the phone - photo that has been saved in .jpg in the gallery - and I try to use it to launch the script, the output I get in Eclipse is different from what I've got in Android.

Does anyone know why I get different results with the same photo? Could it be because in Android the photo is decoded in bitmap and in Eclipse I use the jpeg version? If so I'd like to know if there's a way to load in Android the jpeg version stored in the gallery.

Thanks

2016-07-30 14:06:36 -0600 asked a question Add values to MatOfPoint variable in Java

I'm trying to convert a double[][] into a MatOfPoint. pointsOrdered is a double[4][2] with coordinates of four points in it. I've tried with:

MatOfPoint sourceMat =  new MatOfPoint();
for (int idx = 0; idx < 4; idx++) {
(sourceMat.get(idx, 0))[0] = pointsOrdered[idx][0];
(sourceMat.get(idx, 0))[1] = pointsOrdered[idx][1];}

but sourceMat values stay the same. I'm trying to add values one by one as I haven't found other options.

What can I do? Is there a simple way to access and modify a MatOfPoint variable values?

Thanks