我正在取出画廊图像,并对其进行了一定范围的处理,然后又将图像返回到imageview中,但是我想要的是,当图像超出范围时,它将向我发送消息。
public void processImage(){
String[] partes=vector.toString().split("external_files/");
String part=partes[1];
String dato = "/" + part;
try{
Mat img = imread(Environment.getExternalStorageDirectory().getAbsolutePath() + dato);
Mat oImg = detectColor(img);
// converting image from Mat to bitmap to display in ImageView:
Bitmap bm = Bitmap.createBitmap(oImg.cols(), oImg.rows(),Bitmap.Config.ARGB_8888);
Utils.matToBitmap(oImg,bm);
imgView.setImageBitmap(bm);
Bitmap bitmap=((BitmapDrawable)imgView.getDrawable()).getBitmap();
}catch (Exception xs){
Log.v(TAG,"no maduro" + xs.getMessage());
texto.setText("no maduro");
leer1();
}
}
Mat detectColor(Mat srcImg) {
Mat blurImg = new Mat();
Mat hsvImage = new Mat();
Mat color_range = new Mat();
Mat sin_rango =new Mat();
//bluring image to filter small noises.
Imgproc.GaussianBlur(srcImg, blurImg, new Size(5,5),0);
//converting blured image from BGR to HSV
Imgproc.cvtColor(blurImg, hsvImage, Imgproc.COLOR_BGR2HSV);
//filtering pixels based on given HSV color range
Core.inRange(hsvImage, new Scalar(0,50,50), new Scalar(5,255,255), color_range);
return color_range;
}