org.opencv.core.Range Java Examples
The following examples show how to use
org.opencv.core.Range.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ComparisonFrameRender.java From OpenCV-AndroidSamples with MIT License | 6 votes |
@Override public Mat render(CameraBridgeViewBase.CvCameraViewFrame inputFrame) { Mat undistortedFrame = new Mat(inputFrame.rgba().size(), inputFrame.rgba().type()); Imgproc.undistort(inputFrame.rgba(), undistortedFrame, mCalibrator.getCameraMatrix(), mCalibrator.getDistortionCoefficients()); Mat comparisonFrame = inputFrame.rgba(); undistortedFrame.colRange(new Range(0, mWidth / 2)).copyTo(comparisonFrame.colRange(new Range(mWidth / 2, mWidth))); List<MatOfPoint> border = new ArrayList<MatOfPoint>(); final int shift = (int)(mWidth * 0.005); border.add(new MatOfPoint(new Point(mWidth / 2 - shift, 0), new Point(mWidth / 2 + shift, 0), new Point(mWidth / 2 + shift, mHeight), new Point(mWidth / 2 - shift, mHeight))); Imgproc.fillPoly(comparisonFrame, border, new Scalar(255, 255, 255)); Imgproc.putText(comparisonFrame, mResources.getString(R.string.original), new Point(mWidth * 0.1, mHeight * 0.1), Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0)); Imgproc.putText(comparisonFrame, mResources.getString(R.string.undistorted), new Point(mWidth * 0.6, mHeight * 0.1), Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0)); return comparisonFrame; }
Example #2
Source File: Match.java From SikuliX1 with MIT License | 5 votes |
@Override public Match next() { Match match = null; if (hasNext()) { match = new Match(currentX, currentY, targetW, targetH, currentScore, null); matchCount++; lastScore = currentScore; //int margin = getPurgeMargin(); Range rangeX = new Range(Math.max(currentX - marginX, 0), Math.min(currentX + marginX, result.width())); Range rangeY = new Range(Math.max(currentY - marginY, 0), Math.min(currentY + marginY, result.height())); result.colRange(rangeX).rowRange(rangeY).setTo(new Scalar(0f)); } return match; }
Example #3
Source File: ImgprocessUtils.java From classchecks with Apache License 2.0 | 5 votes |
/** * 其主要思路为: 1、求取源图I的平均灰度,并记录rows和cols; 2、按照一定大小,分为N*M个方块,求出每块的平均值,得到子块的亮度矩阵D; 3、用矩阵D的每个元素减去源图的平均灰度,得到子块的亮度差值矩阵E; 4、用双立方差值法,将矩阵E差值成与源图一样大小的亮度分布矩阵R; 5、得到矫正后的图像result=I-R; * @Title: unevenLightCompensate * @Description: 光线补偿 * @param image * @param blockSize * void * @throws */ public static void unevenLightCompensate(Mat image, int blockSize) { if(image.channels() == 3) { Imgproc.cvtColor(image, image, 7); } double average = Core.mean(image).val[0]; Scalar scalar = new Scalar(average); int rowsNew = (int) Math.ceil((double)image.rows() / (double)blockSize); int colsNew = (int) Math.ceil((double)image.cols() / (double)blockSize); Mat blockImage = new Mat(); blockImage = Mat.zeros(rowsNew, colsNew, CvType.CV_32FC1); for(int i = 0; i < rowsNew; i ++) { for(int j = 0; j < colsNew; j ++) { int rowmin = i * blockSize; int rowmax = (i + 1) * blockSize; if(rowmax > image.rows()) rowmax = image.rows(); int colmin = j * blockSize; int colmax = (j +1) * blockSize; if(colmax > image.cols()) colmax = image.cols(); Range rangeRow = new Range(rowmin, rowmax); Range rangeCol = new Range(colmin, colmax); Mat imageROI = new Mat(image, rangeRow, rangeCol); double temaver = Core.mean(imageROI).val[0]; blockImage.put(i, j, temaver); } } Core.subtract(blockImage, scalar, blockImage); Mat blockImage2 = new Mat(); int INTER_CUBIC = 2; Imgproc.resize(blockImage, blockImage2, image.size(), 0, 0, INTER_CUBIC); Mat image2 = new Mat(); image.convertTo(image2, CvType.CV_32FC1); Mat dst = new Mat(); Core.subtract(image2, blockImage2, dst); dst.convertTo(image, CvType.CV_8UC1); }
Example #4
Source File: CVProcessor.java From CVScanner with GNU General Public License v3.0 | 5 votes |
public static Rect detectBorder(Mat original){ Mat src = original.clone(); Log.d(TAG, "1 original: " + src.toString()); Imgproc.GaussianBlur(src, src, new Size(3, 3), 0); Log.d(TAG, "2.1 --> Gaussian blur done\n blur: " + src.toString()); Imgproc.cvtColor(src, src, Imgproc.COLOR_RGBA2GRAY); Log.d(TAG, "2.2 --> Grayscaling done\n gray: " + src.toString()); Mat sobelX = new Mat(); Mat sobelY = new Mat(); Imgproc.Sobel(src, sobelX, CvType.CV_32FC1, 2, 0, 5, 1, 0); Log.d(TAG, "3.1 --> Sobel done.\n X: " + sobelX.toString()); Imgproc.Sobel(src, sobelY, CvType.CV_32FC1, 0, 2, 5, 1, 0); Log.d(TAG, "3.2 --> Sobel done.\n Y: " + sobelY.toString()); Mat sum_img = new Mat(); Core.addWeighted(sobelX, 0.5, sobelY, 0.5, 0.5, sum_img); //Core.add(sobelX, sobelY, sum_img); Log.d(TAG, "4 --> Addition done. sum: " + sum_img.toString()); sobelX.release(); sobelY.release(); Mat gray = new Mat(); Core.normalize(sum_img, gray, 0, 255, Core.NORM_MINMAX, CvType.CV_8UC1); Log.d(TAG, "5 --> Normalization done. gray: " + gray.toString()); sum_img.release(); Mat row_proj = new Mat(); Mat col_proj = new Mat(); Core.reduce(gray, row_proj, 1, Core.REDUCE_AVG, CvType.CV_8UC1); Log.d(TAG, "6.1 --> Reduce done. row: " + row_proj.toString()); Core.reduce(gray, col_proj, 0, Core.REDUCE_AVG, CvType.CV_8UC1); Log.d(TAG, "6.2 --> Reduce done. col: " + col_proj.toString()); gray.release(); Imgproc.Sobel(row_proj, row_proj, CvType.CV_8UC1, 0, 2); Log.d(TAG, "7.1 --> Sobel done. row: " + row_proj.toString()); Imgproc.Sobel(col_proj, col_proj, CvType.CV_8UC1, 2, 0); Log.d(TAG, "7.2 --> Sobel done. col: " + col_proj.toString()); Rect result = new Rect(); int half_pos = (int) (row_proj.total()/2); Mat row_sub = new Mat(row_proj, new Range(0, half_pos), new Range(0, 1)); Log.d(TAG, "8.1 --> Copy sub matrix done. row: " + row_sub.toString()); result.y = (int) Core.minMaxLoc(row_sub).maxLoc.y; Log.d(TAG, "8.2 --> Minmax done. Y: " + result.y); row_sub.release(); Mat row_sub2 = new Mat(row_proj, new Range(half_pos, (int) row_proj.total()), new Range(0, 1)); Log.d(TAG, "8.3 --> Copy sub matrix done. row: " + row_sub2.toString()); result.height = (int) (Core.minMaxLoc(row_sub2).maxLoc.y + half_pos - result.y); Log.d(TAG, "8.4 --> Minmax done. Height: " + result.height); row_sub2.release(); half_pos = (int) (col_proj.total()/2); Mat col_sub = new Mat(col_proj, new Range(0, 1), new Range(0, half_pos)); Log.d(TAG, "9.1 --> Copy sub matrix done. col: " + col_sub.toString()); result.x = (int) Core.minMaxLoc(col_sub).maxLoc.x; Log.d(TAG, "9.2 --> Minmax done. X: " + result.x); col_sub.release(); Mat col_sub2 = new Mat(col_proj, new Range(0, 1), new Range(half_pos, (int) col_proj.total())); Log.d(TAG, "9.3 --> Copy sub matrix done. col: " + col_sub2.toString()); result.width = (int) (Core.minMaxLoc(col_sub2).maxLoc.x + half_pos - result.x); Log.d(TAG, "9.4 --> Minmax done. Width: " + result.width); col_sub2.release(); row_proj.release(); col_proj.release(); src.release(); return result; }
Example #5
Source File: CvBoost.java From effective_android_sample with Apache License 2.0 | 3 votes |
/** * <p>Removes the specified weak classifiers.</p> * * <p>The method removes the specified weak classifiers from the sequence.</p> * * <p>Note: Do not confuse this method with the pruning of individual decision * trees, which is currently not supported.</p> * * @param slice Continuous subset of the sequence of weak classifiers to be * removed. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-prune">org.opencv.ml.CvBoost.prune</a> */ public void prune(Range slice) { prune_0(nativeObj, slice.start, slice.end); return; }
Example #6
Source File: CvGBTrees.java From SoftwarePilot with MIT License | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method predicts the response corresponding to the given sample (see * "Predicting with GBT"). * The result is either the class label or the estimated function value. The * "CvGBTrees.predict" method enables using the parallel version of the GBT * model prediction if the OpenCV is built with the TBB library. In this case, * predictions of single trees are computed in a parallel fashion.</p> * * @param sample Input feature vector that has the same format as every training * set element. If not all the variables were actually used during training, * <code>sample</code> contains forged values at the appropriate places. * @param missing Missing values mask, which is a dimensional matrix of the same * size as <code>sample</code> having the <code>CV_8U</code> type. * <code>1</code> corresponds to the missing value in the same position in the * <code>sample</code> vector. If there are no missing values in the feature * vector, an empty matrix can be passed instead of the missing mask. * @param slice Parameter defining the part of the ensemble used for prediction. * <p>If <code>slice = Range.all()</code>, all trees are used. Use this parameter * to get predictions of the GBT models with different ensemble sizes learning * only one model.</p> * @param k Number of tree ensembles built in case of the classification problem * (see "Training GBT"). Use this parameter to change the output to sum of the * trees' predictions in the <code>k</code>-th ensemble only. To get the total * GBT model prediction, <code>k</code> value must be -1. For regression * problems, <code>k</code> is also equal to -1. * * @see <a href="http://docs.opencv.org/modules/ml/doc/gradient_boosted_trees.html#cvgbtrees-predict">org.opencv.ml.CvGBTrees.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, int k) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, k); return retVal; }
Example #7
Source File: CvBoost.java From effective_android_sample with Apache License 2.0 | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method runs the sample through the trees in the ensemble and returns the * output class label based on the weighted voting.</p> * * @param sample Input sample. * @param missing Optional mask of missing measurements. To handle missing * measurements, the weak classifiers must include surrogate splits (see * <code>CvDTreeParams.use_surrogates</code>). * @param slice Continuous subset of the sequence of weak classifiers to be used * for prediction. By default, all the weak classifiers are used. * @param rawMode Normally, it should be set to <code>false</code>. * @param returnSum If <code>true</code> then return sum of votes instead of the * class label. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-predict">org.opencv.ml.CvBoost.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, boolean rawMode, boolean returnSum) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, rawMode, returnSum); return retVal; }
Example #8
Source File: CvGBTrees.java From effective_android_sample with Apache License 2.0 | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method predicts the response corresponding to the given sample (see * "Predicting with GBT"). * The result is either the class label or the estimated function value. The * "CvGBTrees.predict" method enables using the parallel version of the GBT * model prediction if the OpenCV is built with the TBB library. In this case, * predictions of single trees are computed in a parallel fashion.</p> * * @param sample Input feature vector that has the same format as every training * set element. If not all the variables were actually used during training, * <code>sample</code> contains forged values at the appropriate places. * @param missing Missing values mask, which is a dimensional matrix of the same * size as <code>sample</code> having the <code>CV_8U</code> type. * <code>1</code> corresponds to the missing value in the same position in the * <code>sample</code> vector. If there are no missing values in the feature * vector, an empty matrix can be passed instead of the missing mask. * @param slice Parameter defining the part of the ensemble used for prediction. * <p>If <code>slice = Range.all()</code>, all trees are used. Use this parameter * to get predictions of the GBT models with different ensemble sizes learning * only one model.</p> * @param k Number of tree ensembles built in case of the classification problem * (see "Training GBT"). Use this parameter to change the output to sum of the * trees' predictions in the <code>k</code>-th ensemble only. To get the total * GBT model prediction, <code>k</code> value must be -1. For regression * problems, <code>k</code> is also equal to -1. * * @see <a href="http://docs.opencv.org/modules/ml/doc/gradient_boosted_trees.html#cvgbtrees-predict">org.opencv.ml.CvGBTrees.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, int k) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, k); return retVal; }
Example #9
Source File: CvBoost.java From ResistorScanner with MIT License | 3 votes |
/** * <p>Removes the specified weak classifiers.</p> * * <p>The method removes the specified weak classifiers from the sequence.</p> * * <p>Note: Do not confuse this method with the pruning of individual decision * trees, which is currently not supported.</p> * * @param slice Continuous subset of the sequence of weak classifiers to be * removed. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-prune">org.opencv.ml.CvBoost.prune</a> */ public void prune(Range slice) { prune_0(nativeObj, slice.start, slice.end); return; }
Example #10
Source File: CvBoost.java From ResistorScanner with MIT License | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method runs the sample through the trees in the ensemble and returns the * output class label based on the weighted voting.</p> * * @param sample Input sample. * @param missing Optional mask of missing measurements. To handle missing * measurements, the weak classifiers must include surrogate splits (see * <code>CvDTreeParams.use_surrogates</code>). * @param slice Continuous subset of the sequence of weak classifiers to be used * for prediction. By default, all the weak classifiers are used. * @param rawMode Normally, it should be set to <code>false</code>. * @param returnSum If <code>true</code> then return sum of votes instead of the * class label. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-predict">org.opencv.ml.CvBoost.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, boolean rawMode, boolean returnSum) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, rawMode, returnSum); return retVal; }
Example #11
Source File: CvGBTrees.java From ResistorScanner with MIT License | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method predicts the response corresponding to the given sample (see * "Predicting with GBT"). * The result is either the class label or the estimated function value. The * "CvGBTrees.predict" method enables using the parallel version of the GBT * model prediction if the OpenCV is built with the TBB library. In this case, * predictions of single trees are computed in a parallel fashion.</p> * * @param sample Input feature vector that has the same format as every training * set element. If not all the variables were actually used during training, * <code>sample</code> contains forged values at the appropriate places. * @param missing Missing values mask, which is a dimensional matrix of the same * size as <code>sample</code> having the <code>CV_8U</code> type. * <code>1</code> corresponds to the missing value in the same position in the * <code>sample</code> vector. If there are no missing values in the feature * vector, an empty matrix can be passed instead of the missing mask. * @param slice Parameter defining the part of the ensemble used for prediction. * <p>If <code>slice = Range.all()</code>, all trees are used. Use this parameter * to get predictions of the GBT models with different ensemble sizes learning * only one model.</p> * @param k Number of tree ensembles built in case of the classification problem * (see "Training GBT"). Use this parameter to change the output to sum of the * trees' predictions in the <code>k</code>-th ensemble only. To get the total * GBT model prediction, <code>k</code> value must be -1. For regression * problems, <code>k</code> is also equal to -1. * * @see <a href="http://docs.opencv.org/modules/ml/doc/gradient_boosted_trees.html#cvgbtrees-predict">org.opencv.ml.CvGBTrees.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, int k) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, k); return retVal; }
Example #12
Source File: CvBoost.java From Android-Car-duino with GNU General Public License v2.0 | 3 votes |
/** * <p>Removes the specified weak classifiers.</p> * * <p>The method removes the specified weak classifiers from the sequence.</p> * * <p>Note: Do not confuse this method with the pruning of individual decision * trees, which is currently not supported.</p> * * @param slice Continuous subset of the sequence of weak classifiers to be * removed. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-prune">org.opencv.ml.CvBoost.prune</a> */ public void prune(Range slice) { prune_0(nativeObj, slice.start, slice.end); return; }
Example #13
Source File: CvBoost.java From Android-Car-duino with GNU General Public License v2.0 | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method runs the sample through the trees in the ensemble and returns the * output class label based on the weighted voting.</p> * * @param sample Input sample. * @param missing Optional mask of missing measurements. To handle missing * measurements, the weak classifiers must include surrogate splits (see * <code>CvDTreeParams.use_surrogates</code>). * @param slice Continuous subset of the sequence of weak classifiers to be used * for prediction. By default, all the weak classifiers are used. * @param rawMode Normally, it should be set to <code>false</code>. * @param returnSum If <code>true</code> then return sum of votes instead of the * class label. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-predict">org.opencv.ml.CvBoost.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, boolean rawMode, boolean returnSum) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, rawMode, returnSum); return retVal; }
Example #14
Source File: CvGBTrees.java From Android-Car-duino with GNU General Public License v2.0 | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method predicts the response corresponding to the given sample (see * "Predicting with GBT"). * The result is either the class label or the estimated function value. The * "CvGBTrees.predict" method enables using the parallel version of the GBT * model prediction if the OpenCV is built with the TBB library. In this case, * predictions of single trees are computed in a parallel fashion.</p> * * @param sample Input feature vector that has the same format as every training * set element. If not all the variables were actually used during training, * <code>sample</code> contains forged values at the appropriate places. * @param missing Missing values mask, which is a dimensional matrix of the same * size as <code>sample</code> having the <code>CV_8U</code> type. * <code>1</code> corresponds to the missing value in the same position in the * <code>sample</code> vector. If there are no missing values in the feature * vector, an empty matrix can be passed instead of the missing mask. * @param slice Parameter defining the part of the ensemble used for prediction. * <p>If <code>slice = Range.all()</code>, all trees are used. Use this parameter * to get predictions of the GBT models with different ensemble sizes learning * only one model.</p> * @param k Number of tree ensembles built in case of the classification problem * (see "Training GBT"). Use this parameter to change the output to sum of the * trees' predictions in the <code>k</code>-th ensemble only. To get the total * GBT model prediction, <code>k</code> value must be -1. For regression * problems, <code>k</code> is also equal to -1. * * @see <a href="http://docs.opencv.org/modules/ml/doc/gradient_boosted_trees.html#cvgbtrees-predict">org.opencv.ml.CvGBTrees.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, int k) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, k); return retVal; }
Example #15
Source File: CvBoost.java From marvel with MIT License | 3 votes |
/** * <p>Removes the specified weak classifiers.</p> * * <p>The method removes the specified weak classifiers from the sequence.</p> * * <p>Note: Do not confuse this method with the pruning of individual decision * trees, which is currently not supported.</p> * * @param slice Continuous subset of the sequence of weak classifiers to be * removed. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-prune">org.opencv.ml.CvBoost.prune</a> */ public void prune(Range slice) { prune_0(nativeObj, slice.start, slice.end); return; }
Example #16
Source File: CvBoost.java From marvel with MIT License | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method runs the sample through the trees in the ensemble and returns the * output class label based on the weighted voting.</p> * * @param sample Input sample. * @param missing Optional mask of missing measurements. To handle missing * measurements, the weak classifiers must include surrogate splits (see * <code>CvDTreeParams.use_surrogates</code>). * @param slice Continuous subset of the sequence of weak classifiers to be used * for prediction. By default, all the weak classifiers are used. * @param rawMode Normally, it should be set to <code>false</code>. * @param returnSum If <code>true</code> then return sum of votes instead of the * class label. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-predict">org.opencv.ml.CvBoost.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, boolean rawMode, boolean returnSum) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, rawMode, returnSum); return retVal; }
Example #17
Source File: CvGBTrees.java From marvel with MIT License | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method predicts the response corresponding to the given sample (see * "Predicting with GBT"). * The result is either the class label or the estimated function value. The * "CvGBTrees.predict" method enables using the parallel version of the GBT * model prediction if the OpenCV is built with the TBB library. In this case, * predictions of single trees are computed in a parallel fashion.</p> * * @param sample Input feature vector that has the same format as every training * set element. If not all the variables were actually used during training, * <code>sample</code> contains forged values at the appropriate places. * @param missing Missing values mask, which is a dimensional matrix of the same * size as <code>sample</code> having the <code>CV_8U</code> type. * <code>1</code> corresponds to the missing value in the same position in the * <code>sample</code> vector. If there are no missing values in the feature * vector, an empty matrix can be passed instead of the missing mask. * @param slice Parameter defining the part of the ensemble used for prediction. * <p>If <code>slice = Range.all()</code>, all trees are used. Use this parameter * to get predictions of the GBT models with different ensemble sizes learning * only one model.</p> * @param k Number of tree ensembles built in case of the classification problem * (see "Training GBT"). Use this parameter to change the output to sum of the * trees' predictions in the <code>k</code>-th ensemble only. To get the total * GBT model prediction, <code>k</code> value must be -1. For regression * problems, <code>k</code> is also equal to -1. * * @see <a href="http://docs.opencv.org/modules/ml/doc/gradient_boosted_trees.html#cvgbtrees-predict">org.opencv.ml.CvGBTrees.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, int k) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, k); return retVal; }
Example #18
Source File: CvBoost.java From android-object-distance with Apache License 2.0 | 3 votes |
/** * <p>Removes the specified weak classifiers.</p> * * <p>The method removes the specified weak classifiers from the sequence.</p> * * <p>Note: Do not confuse this method with the pruning of individual decision * trees, which is currently not supported.</p> * * @param slice Continuous subset of the sequence of weak classifiers to be * removed. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-prune">org.opencv.ml.CvBoost.prune</a> */ public void prune(Range slice) { prune_0(nativeObj, slice.start, slice.end); return; }
Example #19
Source File: CvBoost.java From android-object-distance with Apache License 2.0 | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method runs the sample through the trees in the ensemble and returns the * output class label based on the weighted voting.</p> * * @param sample Input sample. * @param missing Optional mask of missing measurements. To handle missing * measurements, the weak classifiers must include surrogate splits (see * <code>CvDTreeParams.use_surrogates</code>). * @param slice Continuous subset of the sequence of weak classifiers to be used * for prediction. By default, all the weak classifiers are used. * @param rawMode Normally, it should be set to <code>false</code>. * @param returnSum If <code>true</code> then return sum of votes instead of the * class label. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-predict">org.opencv.ml.CvBoost.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, boolean rawMode, boolean returnSum) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, rawMode, returnSum); return retVal; }
Example #20
Source File: CvGBTrees.java From android-object-distance with Apache License 2.0 | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method predicts the response corresponding to the given sample (see * "Predicting with GBT"). * The result is either the class label or the estimated function value. The * "CvGBTrees.predict" method enables using the parallel version of the GBT * model prediction if the OpenCV is built with the TBB library. In this case, * predictions of single trees are computed in a parallel fashion.</p> * * @param sample Input feature vector that has the same format as every training * set element. If not all the variables were actually used during training, * <code>sample</code> contains forged values at the appropriate places. * @param missing Missing values mask, which is a dimensional matrix of the same * size as <code>sample</code> having the <code>CV_8U</code> type. * <code>1</code> corresponds to the missing value in the same position in the * <code>sample</code> vector. If there are no missing values in the feature * vector, an empty matrix can be passed instead of the missing mask. * @param slice Parameter defining the part of the ensemble used for prediction. * <p>If <code>slice = Range.all()</code>, all trees are used. Use this parameter * to get predictions of the GBT models with different ensemble sizes learning * only one model.</p> * @param k Number of tree ensembles built in case of the classification problem * (see "Training GBT"). Use this parameter to change the output to sum of the * trees' predictions in the <code>k</code>-th ensemble only. To get the total * GBT model prediction, <code>k</code> value must be -1. For regression * problems, <code>k</code> is also equal to -1. * * @see <a href="http://docs.opencv.org/modules/ml/doc/gradient_boosted_trees.html#cvgbtrees-predict">org.opencv.ml.CvGBTrees.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, int k) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, k); return retVal; }
Example #21
Source File: CvBoost.java From SoftwarePilot with MIT License | 3 votes |
/** * <p>Removes the specified weak classifiers.</p> * * <p>The method removes the specified weak classifiers from the sequence.</p> * * <p>Note: Do not confuse this method with the pruning of individual decision * trees, which is currently not supported.</p> * * @param slice Continuous subset of the sequence of weak classifiers to be * removed. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-prune">org.opencv.ml.CvBoost.prune</a> */ public void prune(Range slice) { prune_0(nativeObj, slice.start, slice.end); return; }
Example #22
Source File: CvBoost.java From SoftwarePilot with MIT License | 3 votes |
/** * <p>Predicts a response for an input sample.</p> * * <p>The method runs the sample through the trees in the ensemble and returns the * output class label based on the weighted voting.</p> * * @param sample Input sample. * @param missing Optional mask of missing measurements. To handle missing * measurements, the weak classifiers must include surrogate splits (see * <code>CvDTreeParams.use_surrogates</code>). * @param slice Continuous subset of the sequence of weak classifiers to be used * for prediction. By default, all the weak classifiers are used. * @param rawMode Normally, it should be set to <code>false</code>. * @param returnSum If <code>true</code> then return sum of votes instead of the * class label. * * @see <a href="http://docs.opencv.org/modules/ml/doc/boosting.html#cvboost-predict">org.opencv.ml.CvBoost.predict</a> */ public float predict(Mat sample, Mat missing, Range slice, boolean rawMode, boolean returnSum) { float retVal = predict_0(nativeObj, sample.nativeObj, missing.nativeObj, slice.start, slice.end, rawMode, returnSum); return retVal; }