java.util.List<Mat> mixOut = new ArrayList<Mat>(Arrays.asList(new Mat[]{oMatA, oMatBGR})); Core.mixChannels(mixIn, mixOut, new MatOfInt(0, 0, 1, 3, 2, 2, 3, 1)); return oMatBGR; } else if (bImg.getType() == BufferedImage.TYPE_3BYTE_BGR) {
MatOfInt digitsHullIdx = new MatOfInt(); MatOfPoint hullPoints = new MatOfPoint(); hullPoints.fromList(digits);
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
public static MatOfInt fromNativeAddr(long addr) { return new MatOfInt(addr); }
List<Mat> hList = new ArrayList<>(); hList.add(hsv_planes.get(0)); List<Mat> sList = new ArrayList<>(); sList.add(hsv_planes.get(1)); List<Mat> vList = new ArrayList<>(); vList.add(hsv_planes.get(2)); //Compute the histograms using calcHist function Imgproc.calcHist(hList, new MatOfInt(3), new Mat(), h_hist, HistSize, HistRange, accumulate); Imgproc.calcHist(sList, new MatOfInt(3), new Mat(), s_hist, HistSize, HistRange, accumulate); Imgproc.calcHist(vList, new MatOfInt(3), new Mat(), v_hist, HistSize, HistRange, accumulate);
Mat image0 = ...; // Mat image1 = ...; Mat hist0 = new Mat(); Mat hist1 = new Mat(); int hist_bins = 30; //number of histogram bins int hist_range[]= {0,180};//histogram range MatOfFloat ranges = new MatOfFloat(0f, 256f); MatOfInt histSize = new MatOfInt(25); Imgproc.calcHist(Arrays.asList(image0), new MatOfInt(0), new Mat(), hist0, histSize, ranges); Imgproc.calcHist(Arrays.asList(image1), new MatOfInt(0), new Mat(), hist1, histSize, ranges); double res = Imgproc.compareHist(image0, image01, Imgproc.CV_COMP_CORREL);
Mat image0 = ...; // Mat image1 = ...; Mat hist0 = new Mat(); Mat hist1 = new Mat(); int hist_bins = 30; //number of histogram bins int hist_range[]= {0,180};//histogram range MatOfFloat ranges = new MatOfFloat(0f, 256f); MatOfInt histSize = new MatOfInt(25); Imgproc.calcHist(Arrays.asList(image0), new MatOfInt(0), new Mat(), hist0, histSize, ranges); Imgproc.calcHist(Arrays.asList(image1), new MatOfInt(0), new Mat(), hist1, histSize, ranges); double res = Imgproc.compareHist(hist0, hist1, Imgproc.CV_COMP_CORREL);
private void updateHueImage() { hsvList.clear(); hsvList.add(hsv); // hue初始化为与hsv大小深度一样的矩阵,色调的度量是用角度表示的,红绿蓝之间相差120度,反色相差180度 hue.create(hsv.size(), hsv.depth()); hueList.clear(); hueList.add(hue); MatOfInt from_to = new MatOfInt(0, 0); // 将hsv第一个通道(也就是色调)的数复制到hue中,0索引数组 Core.mixChannels(hsvList, hueList, from_to); }
MatOfInt hull = new MatOfInt(); MatOfPoint tempContour = contours.get(i); Imgproc.convexHull(tempContour, hull, false); // O(N*Log(N)) //System.out.println("hull size: " + hull.size() + " x" + hull.get(0,0).length); //System.out.println("Contour matrix size: " + tempContour.size() + " x" + tempContour.get(0,0).length); int index = (int) hull.get(((int) hull.size().height)-1, 0)[0]; Point pt, pt0 = new Point(tempContour.get(index, 0)[0], tempContour.get(index, 0)[1]); for(int j = 0; j < hull.size().height -1 ; j++){ index = (int) hull.get(j, 0)[0]; pt = new Point(tempContour.get(index, 0)[0], tempContour.get(index, 0)[1]); Core.line(frame, pt0, pt, new Scalar(255, 0, 100), 8); pt0 = pt; }
MatOfPoint mopIn = ... MatOfInt hull = new MatOfInt(); Imgproc.convexHull(mopIn, hull, false); MatOfPoint mopOut = new MatOfPoint(); mopOut.create((int)hull.size().height,1,CvType.CV_32SC2); for(int i = 0; i < hull.size().height ; i++) { int index = (int)hull.get(i, 0)[0]; double[] point = new double[] { mopIn.get(index, 0)[0], mopIn.get(index, 0)[1] }; mopOut.put(i, 0, point); } // do something interesting with mopOut