1
opencv 2_4_9を使用してヒストグラムを計算しようとしていますが、このエラーはポップアップ表示されていますどこにでも誰かが私にそれを解決する方法を手伝ってもらえれば私の問題に特化した解決策は何も見つかりませんでした.. !!org.Opencv.core.Matはアンドロイドスタジオのjava.util.listにキャストすることはできません
private void GetResult()
{
try
{
// System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
img = BitmapFactory.decodeFile(outPutFile.toString());
image = new Mat(img.getHeight(), img.getWidth(), CvType.CV_8UC1);
Utils.bitmapToMat(img, image);
Imgproc.cvtColor(image, image, Imgproc.COLOR_RGB2HSV);
List<Mat> hsv_planes = new ArrayList<Mat>();
//splitting into 3 planes r,g,b
Core.split(image, hsv_planes);
//the number of bins
MatOfInt HistSize = new MatOfInt(256);
//set the ranges for r,g,b
final MatOfFloat HistRange = new MatOfFloat(0f, 256f);
boolean accumulate = false;
Mat h_hist = new Mat();
Mat s_hist = new Mat();
Mat v_hist = new Mat();
//Compute the histograms using calcHist function
Imgproc.calcHist((List<Mat>) hsv_planes.get(0), new MatOfInt(3), new Mat(), h_hist, HistSize, HistRange, accumulate);
Imgproc.calcHist((List<Mat>) hsv_planes.get(1), new MatOfInt(3), new Mat(), s_hist, HistSize, HistRange, accumulate);
Imgproc.calcHist((List<Mat>) hsv_planes.get(2), new MatOfInt(3), new Mat(), v_hist, HistSize, HistRange, accumulate);
int hist_w = 512;
int hist_h = 600;
long bin_w = Math.round((double) hist_w/256);
Mat HistImage = new Mat(hist_h, hist_w, CvType.CV_8UC1);
//Normalization
Core.normalize(h_hist, h_hist, 3, HistImage.rows(), Core.NORM_MINMAX);
Core.normalize(s_hist, s_hist, 3, HistImage.rows(), Core.NORM_MINMAX);
Core.normalize(v_hist, v_hist, 3, HistImage.rows(), Core.NORM_MINMAX);
for (int i = 1; i < 256; i++) {
Point p1 = new Point(bin_w * (i - 1), hist_h - Math.round(h_hist.get(i - 1, 0)[0]));
Point p2 = new Point(bin_w * (i), hist_h - Math.round(h_hist.get(i, 0)[0]));
Core.line(HistImage, p1, p2, new Scalar(255, 0, 0), 2, 8, 0);
Point p3 = new Point(bin_w * (i - 1), hist_h - Math.round(s_hist.get(i - 1, 0)[0]));
Point p4 = new Point(bin_w * (i), hist_h - Math.round(s_hist.get(i, 0)[0]));
Core.line(HistImage, p3, p4, new Scalar(255, 0, 0), 2, 8, 0);
Point p5 = new Point(bin_w * (i - 1), hist_h - Math.round(v_hist.get(i - 1, 0)[0]));
Point p6 = new Point(bin_w * (i), hist_h - Math.round(v_hist.get(i, 0)[0]));
Core.line(HistImage, p1, p2, new Scalar(255, 0, 0), 2, 8, 0);
}
Utils.matToBitmap(HistImage, photoo);
img_histogram.setImageBitmap(photoo);
}
catch (Exception e)
{
Toast.makeText(MainActivity.this, e.toString(),Toast.LENGTH_LONG).show();
}
}
}