My test Android app has a single activity, LoadImage, with two methods: an onCreate method that processes images with OpenCV, and a Display method which displays the image on the screen for 5 seconds. Here is what I have so far for the Display method:
[convert OpenCV matrix to a bitmap using an OpenCV method]
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(bitmap, 0, 0, null);
try {
synchronized (this) {
wait(5000);
}
} catch (InterruptedException e) {
}
and here is the XML file for the single activity (it’s a blank screen):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
If I run the code as-is, I get… a blank screen. How do I get the bitmaps to show up?
Thanks so much.
Try this:
And do this in your java code:
You are sending the bitmap to the canvas right?
So do this there in your method where you are drawing into the bitmap.
You can not set the canvas directly to the imageView1.
Because as you know in real life, the canvas is just a brush. In the same way here also the canvas is only a brush. so dont worry about it.your edited image is now stored in the
bitmaponly. So thats why you can directly set the bitmap after editng by canvas.