Java Code Examples for org.opencv.core.Mat#release()
The following examples show how to use
org.opencv.core.Mat#release() .
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: ImageProcessor.java From Document-Scanner with GNU General Public License v3.0 | 7 votes |
private void enhanceDocument( Mat src ) { if (colorMode && filterMode) { src.convertTo(src,-1, colorGain , colorBias); Mat mask = new Mat(src.size(), CvType.CV_8UC1); Imgproc.cvtColor(src,mask,Imgproc.COLOR_RGBA2GRAY); Mat copy = new Mat(src.size(), CvType.CV_8UC3); src.copyTo(copy); Imgproc.adaptiveThreshold(mask,mask,255,Imgproc.ADAPTIVE_THRESH_MEAN_C,Imgproc.THRESH_BINARY_INV,15,15); src.setTo(new Scalar(255,255,255)); copy.copyTo(src,mask); copy.release(); mask.release(); // special color threshold algorithm colorThresh(src,colorThresh); } else if (!colorMode) { Imgproc.cvtColor(src,src,Imgproc.COLOR_RGBA2GRAY); if (filterMode) { Imgproc.adaptiveThreshold(src, src, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 15, 15); } } }
Example 2
Source File: Converters.java From sudokufx with Apache License 2.0 | 6 votes |
public static void Mat_to_vector_vector_char(Mat m, List<List<Byte>> llb) { if (llb == null) throw new IllegalArgumentException("Output List can't be null"); if (m == null) throw new IllegalArgumentException("Input Mat can't be null"); List<Mat> mats = new ArrayList<Mat>(m.rows()); Mat_to_vector_Mat(m, mats); for (Mat mi : mats) { List<Byte> lb = new ArrayList<Byte>(); Mat_to_vector_char(mi, lb); llb.add(lb); mi.release(); } mats.clear(); }
Example 3
Source File: Utils.java From MOAAP with MIT License | 6 votes |
public static Mat loadResource(Context context, int resourceId, int flags) throws IOException { InputStream is = context.getResources().openRawResource(resourceId); ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } is.close(); Mat encoded = new Mat(1, os.size(), CvType.CV_8U); encoded.put(0, 0, os.toByteArray()); os.close(); Mat decoded = Imgcodecs.imdecode(encoded, flags); encoded.release(); return decoded; }
Example 4
Source File: Converters.java From faceswap with Apache License 2.0 | 6 votes |
public static void Mat_to_vector_vector_KeyPoint(Mat m, List<MatOfKeyPoint> kps) { if (kps == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); if (m == null) throw new java.lang.IllegalArgumentException("Input Mat can't be null"); List<Mat> mats = new ArrayList<Mat>(m.rows()); Mat_to_vector_Mat(m, mats); for (Mat mi : mats) { MatOfKeyPoint vkp = new MatOfKeyPoint(mi); kps.add(vkp); mi.release(); } mats.clear(); }
Example 5
Source File: Converters.java From ml-authentication with Apache License 2.0 | 6 votes |
public static void Mat_to_vector_vector_Point3f(Mat m, List<MatOfPoint3f> pts) { if (pts == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); if (m == null) throw new java.lang.IllegalArgumentException("Input Mat can't be null"); List<Mat> mats = new ArrayList<Mat>(m.rows()); Mat_to_vector_Mat(m, mats); for (Mat mi : mats) { MatOfPoint3f pt = new MatOfPoint3f(mi); pts.add(pt); mi.release(); } mats.clear(); }
Example 6
Source File: Calib3d.java From MOAAP with MIT License | 5 votes |
public static double calibrateCamera(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, int flags, TermCriteria criteria) { Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints); Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints); Mat rvecs_mat = new Mat(); Mat tvecs_mat = new Mat(); double retVal = calibrateCamera_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon); Converters.Mat_to_vector_Mat(rvecs_mat, rvecs); rvecs_mat.release(); Converters.Mat_to_vector_Mat(tvecs_mat, tvecs); tvecs_mat.release(); return retVal; }
Example 7
Source File: Calib3d.java From OpenCV-AndroidSamples with MIT License | 5 votes |
public static double calibrate(List<Mat> objectPoints, List<Mat> imagePoints, Size image_size, Mat K, Mat D, List<Mat> rvecs, List<Mat> tvecs, int flags, TermCriteria criteria) { Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints); Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints); Mat rvecs_mat = new Mat(); Mat tvecs_mat = new Mat(); double retVal = calibrate_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, image_size.width, image_size.height, K.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon); Converters.Mat_to_vector_Mat(rvecs_mat, rvecs); rvecs_mat.release(); Converters.Mat_to_vector_Mat(tvecs_mat, tvecs); tvecs_mat.release(); return retVal; }
Example 8
Source File: DescriptorMatcher.java From FtcSamples with MIT License | 5 votes |
public void knnMatch(Mat queryDescriptors, List<MatOfDMatch> matches, int k, List<Mat> masks, boolean compactResult) { Mat matches_mat = new Mat(); Mat masks_mat = Converters.vector_Mat_to_Mat(masks); knnMatch_2(nativeObj, queryDescriptors.nativeObj, matches_mat.nativeObj, k, masks_mat.nativeObj, compactResult); Converters.Mat_to_vector_vector_DMatch(matches_mat, matches); matches_mat.release(); return; }
Example 9
Source File: FeatureDetector.java From FaceT with Mozilla Public License 2.0 | 5 votes |
public void detect(List<Mat> images, List<MatOfKeyPoint> keypoints, List<Mat> masks) { Mat images_mat = Converters.vector_Mat_to_Mat(images); Mat keypoints_mat = new Mat(); Mat masks_mat = Converters.vector_Mat_to_Mat(masks); detect_2(nativeObj, images_mat.nativeObj, keypoints_mat.nativeObj, masks_mat.nativeObj); Converters.Mat_to_vector_vector_KeyPoint(keypoints_mat, keypoints); keypoints_mat.release(); return; }
Example 10
Source File: Aruco.java From MOAAP with MIT License | 5 votes |
public static void detectCharucoDiamond(Mat image, List<Mat> markerCorners, Mat markerIds, float squareMarkerLengthRate, List<Mat> diamondCorners, Mat diamondIds, Mat cameraMatrix, Mat distCoeffs) { Mat markerCorners_mat = Converters.vector_Mat_to_Mat(markerCorners); Mat diamondCorners_mat = new Mat(); detectCharucoDiamond_0(image.nativeObj, markerCorners_mat.nativeObj, markerIds.nativeObj, squareMarkerLengthRate, diamondCorners_mat.nativeObj, diamondIds.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj); Converters.Mat_to_vector_Mat(diamondCorners_mat, diamondCorners); diamondCorners_mat.release(); return; }
Example 11
Source File: DescriptorExtractor.java From Chinese-number-gestures-recognition with BSD 2-Clause "Simplified" License | 5 votes |
public void compute(List<Mat> images, List<MatOfKeyPoint> keypoints, List<Mat> descriptors) { Mat images_mat = Converters.vector_Mat_to_Mat(images); List<Mat> keypoints_tmplm = new ArrayList<Mat>((keypoints != null) ? keypoints.size() : 0); Mat keypoints_mat = Converters.vector_vector_KeyPoint_to_Mat(keypoints, keypoints_tmplm); Mat descriptors_mat = new Mat(); compute_1(nativeObj, images_mat.nativeObj, keypoints_mat.nativeObj, descriptors_mat.nativeObj); Converters.Mat_to_vector_vector_KeyPoint(keypoints_mat, keypoints); keypoints_mat.release(); Converters.Mat_to_vector_Mat(descriptors_mat, descriptors); descriptors_mat.release(); return; }
Example 12
Source File: DescriptorMatcher.java From FaceDetectDemo with Apache License 2.0 | 5 votes |
public void radiusMatch(Mat queryDescriptors, List<MatOfDMatch> matches, float maxDistance, List<Mat> masks, boolean compactResult) { Mat matches_mat = new Mat(); Mat masks_mat = Converters.vector_Mat_to_Mat(masks); radiusMatch_2(nativeObj, queryDescriptors.nativeObj, matches_mat.nativeObj, maxDistance, masks_mat.nativeObj, compactResult); Converters.Mat_to_vector_vector_DMatch(matches_mat, matches); matches_mat.release(); return; }
Example 13
Source File: MSER.java From pasm-yolov3-Android with GNU General Public License v3.0 | 5 votes |
public void detectRegions(Mat image, List<MatOfPoint> msers, MatOfRect bboxes) { Mat msers_mat = new Mat(); Mat bboxes_mat = bboxes; detectRegions_0(nativeObj, image.nativeObj, msers_mat.nativeObj, bboxes_mat.nativeObj); Converters.Mat_to_vector_vector_Point(msers_mat, msers); msers_mat.release(); return; }
Example 14
Source File: Calib3d.java From VIA-AI with MIT License | 5 votes |
public static double fisheye_calibrate(List<Mat> objectPoints, List<Mat> imagePoints, Size image_size, Mat K, Mat D, List<Mat> rvecs, List<Mat> tvecs) { Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints); Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints); Mat rvecs_mat = new Mat(); Mat tvecs_mat = new Mat(); double retVal = fisheye_calibrate_2(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, image_size.width, image_size.height, K.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj); Converters.Mat_to_vector_Mat(rvecs_mat, rvecs); rvecs_mat.release(); Converters.Mat_to_vector_Mat(tvecs_mat, tvecs); tvecs_mat.release(); return retVal; }
Example 15
Source File: FeatureDetector.java From OpenCvFaceDetect with Apache License 2.0 | 5 votes |
public void detect(List<Mat> images, List<MatOfKeyPoint> keypoints) { Mat images_mat = Converters.vector_Mat_to_Mat(images); Mat keypoints_mat = new Mat(); detect_3(nativeObj, images_mat.nativeObj, keypoints_mat.nativeObj); Converters.Mat_to_vector_vector_KeyPoint(keypoints_mat, keypoints); keypoints_mat.release(); return; }
Example 16
Source File: Video.java From MOAAP with MIT License | 5 votes |
public static int buildOpticalFlowPyramid(Mat img, List<Mat> pyramid, Size winSize, int maxLevel) { Mat pyramid_mat = new Mat(); int retVal = buildOpticalFlowPyramid_1(img.nativeObj, pyramid_mat.nativeObj, winSize.width, winSize.height, maxLevel); Converters.Mat_to_vector_Mat(pyramid_mat, pyramid); pyramid_mat.release(); return retVal; }
Example 17
Source File: DescriptorMatcher.java From LicensePlateDiscern with MIT License | 5 votes |
public void radiusMatch(Mat queryDescriptors, Mat trainDescriptors, List<MatOfDMatch> matches, float maxDistance) { Mat matches_mat = new Mat(); radiusMatch_2(nativeObj, queryDescriptors.nativeObj, trainDescriptors.nativeObj, matches_mat.nativeObj, maxDistance); Converters.Mat_to_vector_vector_DMatch(matches_mat, matches); matches_mat.release(); return; }
Example 18
Source File: DescriptorMatcher.java From FTCVision with MIT License | 5 votes |
public void knnMatch(Mat queryDescriptors, Mat trainDescriptors, List<MatOfDMatch> matches, int k, Mat mask, boolean compactResult) { Mat matches_mat = new Mat(); knnMatch_0(nativeObj, queryDescriptors.nativeObj, trainDescriptors.nativeObj, matches_mat.nativeObj, k, mask.nativeObj, compactResult); Converters.Mat_to_vector_vector_DMatch(matches_mat, matches); matches_mat.release(); return; }
Example 19
Source File: Calib3d.java From Image-Detection-Samples with Apache License 2.0 | 5 votes |
public static double calibrateCameraExtended(List<Mat> objectPoints, List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List<Mat> rvecs, List<Mat> tvecs, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat perViewErrors, int flags) { Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints); Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints); Mat rvecs_mat = new Mat(); Mat tvecs_mat = new Mat(); double retVal = calibrateCameraExtended_1(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, perViewErrors.nativeObj, flags); Converters.Mat_to_vector_Mat(rvecs_mat, rvecs); rvecs_mat.release(); Converters.Mat_to_vector_Mat(tvecs_mat, tvecs); tvecs_mat.release(); return retVal; }
Example 20
Source File: ColorBlobDetectionActivity.java From OpenCV-AndroidSamples with MIT License | 2 votes |
public boolean onTouch(View v, MotionEvent event) { int cols = mRgba.cols(); int rows = mRgba.rows(); int xOffset = (mOpenCvCameraView.getWidth() - cols) / 2; int yOffset = (mOpenCvCameraView.getHeight() - rows) / 2; int x = (int)event.getX() - xOffset; int y = (int)event.getY() - yOffset; Log.i(TAG, "Touch image coordinates: (" + x + ", " + y + ")"); if ((x < 0) || (y < 0) || (x > cols) || (y > rows)) return false; Rect touchedRect = new Rect(); touchedRect.x = (x>4) ? x-4 : 0; touchedRect.y = (y>4) ? y-4 : 0; touchedRect.width = (x+4 < cols) ? x + 4 - touchedRect.x : cols - touchedRect.x; touchedRect.height = (y+4 < rows) ? y + 4 - touchedRect.y : rows - touchedRect.y; Mat touchedRegionRgba = mRgba.submat(touchedRect); Mat touchedRegionHsv = new Mat(); Imgproc.cvtColor(touchedRegionRgba, touchedRegionHsv, Imgproc.COLOR_RGB2HSV_FULL); // Calculate average color of touched region mBlobColorHsv = Core.sumElems(touchedRegionHsv); int pointCount = touchedRect.width*touchedRect.height; for (int i = 0; i < mBlobColorHsv.val.length; i++) mBlobColorHsv.val[i] /= pointCount; mBlobColorRgba = converScalarHsv2Rgba(mBlobColorHsv); Log.i(TAG, "Touched rgba color: (" + mBlobColorRgba.val[0] + ", " + mBlobColorRgba.val[1] + ", " + mBlobColorRgba.val[2] + ", " + mBlobColorRgba.val[3] + ")"); mDetector.setHsvColor(mBlobColorHsv); Imgproc.resize(mDetector.getSpectrum(), mSpectrum, SPECTRUM_SIZE); mIsColorSelected = true; touchedRegionRgba.release(); touchedRegionHsv.release(); return false; // don't need subsequent touch events }