reading your answer:
I have already executed the code that you had before. I was able to upload the image for parsing. but I donβt know how to switch the pushed source to be my camera / gallery image or image. - stanley santoso
to:
Abhishek Bansal
I understand that your problem does not analyze your image?
To answer your question:
I donβt know how to switch the drawing source to be my camera / gallery image or image.
1 - R.drawable.androidbegin seems to be your problem, but the fact is that you already have a bitmap for analysis in your code:
from gallery β
mImageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
from camera β
Bitmap photo = (Bitmap) data.getExtras().get("data");
2 - Therefore, I would suggest declaring a variable of type Bitmap at the beginning of your code
private Bitmap yourbitmap;
3 - then assign a bitmap image of the gallery and camera in your code and use it to analyze it.
... yourbitmap = BitmapFactory.decodeFile(picturePath); ... yourbitmap = (Bitmap) data.getExtras().get("data"); ...
4 - finally, you can use your bitmap like this:
// Bitmap bitmap = BitmapFactory.decodeResource(getResources(), // R.drawable.androidbegin); // Convert it to byte ByteArrayOutputStream stream = new ByteArrayOutputStream(); // Compress image to lower quality scale 1 - 100 yourbitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] image = stream.toByteArray(); ...
source share