0

I Have to detect an existing image in the android project from a camera preview without taking an image I look every where and I discover that I have to use opencv but I didn't find a good example (The solution must look like barcode detection) please if any have an idea tell me thank you.

plum 0
  • 652
  • 9
  • 21
  • Please take your time to write an understandable question. See [How to Ask](http://stackoverflow.com/questions/ask/advice) – Miki Dec 13 '15 at 16:18

1 Answers1

1

What do you mean by "Existing Image"? Do you have the physical address of the image? If so, you can load image with opencv android wrapper. For instance, if you know the physical address of the image, then you can load it and send it to ImageView using the following codes:

BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();

Mat m = Imgcodecs.imread(picturePath);

Bitmap bm = Bitmap.createBitmap(m.cols(), m.rows(),  Bitmap.Config.ARGB_8888);
Imgproc.cvtColor(m, m, Imgproc.COLOR_BGR2RGB); // Images are natively in BGR color space in opencv. To show it properly in android project, convert the color space to RGB
Utils.matToBitmap(b, bm);
image_view.setImageBitmap(bm);

You can show an image wherever it is.

Davood Falahati
  • 1,474
  • 16
  • 34
  • please can you give me the class where i use your method @Davood Falahati – MohamedAmine Souiden Dec 13 '15 at 20:36
  • there are many methods to to implement opencv in your Android project. I myself, prefer static implementation. You can follow #TGMCLans instruction in [Here](http://stackoverflow.com/questions/17767557/how-to-use-opencv-in-android-studio-using-gradle-build-tool) – Davood Falahati Dec 14 '15 at 05:53