Hey everyone,

I have s small app which takes a picture and i want to threshold it.
for some reason the function Utils.matToBitmap crashes when I use it
after the threshold, any thoughts on how to solve this?

the Code:
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
            if (requestCode == CAMERA_PIC_REQUEST) {
                        try {
                                Bitmap bitmap = (Bitmap) 
data.getExtras().get("data");
                                this._Gray = Utils.bitmapToMat(bitmap);
                                Mat tMat = thresholdPicture();
                                Bitmap tOutBitmap =
Bitmap.createBitmap(tMat.cols(),tMat.rows(),Bitmap.Config.ARGB_8888);
                                if (Utils.matToBitmap(tMat, tOutBitmap))//Crash 
here
                                {
                                        
this.setContentView(R.layout.picture_display);
                                        Drawable drawable =new 
BitmapDrawable(getResources(),tOutBitmap);
                                        SurfaceView tSurfaceView = (SurfaceView)
findViewById(R.id.surfaceView1);
                                
tSurfaceView.setBackgroundDrawable(drawable);//TODO: not
working if we picture vertically
                                }
                                else{
                                        Log.i("OpenCV", "Failed convert mat to 
bitmap");
                                }
                        }
                        catch (Exception e) {
                                Log.i("OpenCV", "Failed to Use OpenCV" + 
e.getMessage());
                        }
            }
        }

        private Mat thresholdPicture(){
                Mat tMatThreshed = new Mat();
                Imgproc.cvtColor(this._Gray, this._Gray, 
Imgproc.COLOR_RGB2GRAY);
                Imgproc.threshold(this._Gray, tMatThreshed, 100,
100,Imgproc.THRESH_BINARY);
                return tMatThreshed;

        }

}

Thank you

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to