Java Code Examples for org.opencv.core.Mat

The following are top voted examples for showing how to use org.opencv.core.Mat. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Image-Detection-Samples   File: Converters.java   View source code 6 votes vote down vote up
public static void Mat_to_vector_KeyPoint(Mat m, List<KeyPoint> kps) {
    if (kps == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_64FC(7) != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_64FC(7) != m.type() ||  m.cols()!=1\n" + m);

    kps.clear();
    double[] buff = new double[7 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        kps.add(new KeyPoint((float) buff[7 * i], (float) buff[7 * i + 1], (float) buff[7 * i + 2], (float) buff[7 * i + 3],
                (float) buff[7 * i + 4], (int) buff[7 * i + 5], (int) buff[7 * i + 6]));
    }
}
 
Example 2
Project: MOAAP   File: Calib3d.java   View source code 5 votes vote down vote up
public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold, Mat mask, int maxIters, double confidence)
{
    Mat srcPoints_mat = srcPoints;
    Mat dstPoints_mat = dstPoints;
    Mat retVal = new Mat(findHomography_0(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method, ransacReprojThreshold, mask.nativeObj, maxIters, confidence));
    
    return retVal;
}
 
Example 3
Project: EyeShopping   File: Features2d.java   View source code 5 votes vote down vote up
public static void drawMatchesKnn(Mat img1, MatOfKeyPoint keypoints1, Mat img2, MatOfKeyPoint keypoints2, List<MatOfDMatch> matches1to2, Mat outImg)
{
    Mat keypoints1_mat = keypoints1;
    Mat keypoints2_mat = keypoints2;
    List<Mat> matches1to2_tmplm = new ArrayList<Mat>((matches1to2 != null) ? matches1to2.size() : 0);
    Mat matches1to2_mat = Converters.vector_vector_DMatch_to_Mat(matches1to2, matches1to2_tmplm);
    drawMatchesKnn_1(img1.nativeObj, keypoints1_mat.nativeObj, img2.nativeObj, keypoints2_mat.nativeObj, matches1to2_mat.nativeObj, outImg.nativeObj);
    
    return;
}
 
Example 4
Project: MOAAP   File: Imgcodecs.java   View source code 5 votes vote down vote up
public static boolean imencode(String ext, Mat img, MatOfByte buf)
{
    Mat buf_mat = buf;
    boolean retVal = imencode_1(ext, img.nativeObj, buf_mat.nativeObj);
    
    return retVal;
}
 
Example 5
Project: react-native-scan-doc   File: Feature2D.java   View source code 5 votes vote down vote up
public  void detectAndCompute(Mat image, Mat mask, MatOfKeyPoint keypoints, Mat descriptors)
{
    Mat keypoints_mat = keypoints;
    detectAndCompute_1(nativeObj, image.nativeObj, mask.nativeObj, keypoints_mat.nativeObj, descriptors.nativeObj);
    
    return;
}
 
Example 6
Project: MOAAP   File: Photo.java   View source code 5 votes vote down vote up
public static void fastNlMeansDenoisingMulti(List<Mat> srcImgs, Mat dst, int imgToDenoiseIndex, int temporalWindowSize, float h, int templateWindowSize, int searchWindowSize)
{
    Mat srcImgs_mat = Converters.vector_Mat_to_Mat(srcImgs);
    fastNlMeansDenoisingMulti_0(srcImgs_mat.nativeObj, dst.nativeObj, imgToDenoiseIndex, temporalWindowSize, h, templateWindowSize, searchWindowSize);
    
    return;
}
 
Example 7
Project: Microsphere   File: BOWImgDescriptorExtractor.java   View source code 5 votes vote down vote up
public  void compute(Mat image, MatOfKeyPoint keypoints, Mat imgDescriptor)
{
    Mat keypoints_mat = keypoints;
    compute_0(nativeObj, image.nativeObj, keypoints_mat.nativeObj, imgDescriptor.nativeObj);
    
    return;
}
 
Example 8
Project: MOAAP   File: FeatureDetector.java   View source code 5 votes vote down vote up
public  void detect(Mat image, MatOfKeyPoint keypoints, Mat mask)
{
    Mat keypoints_mat = keypoints;
    detect_0(nativeObj, image.nativeObj, keypoints_mat.nativeObj, mask.nativeObj);
    
    return;
}
 
Example 9
Project: Team9261-2017-2018   File: Features2d.java   View source code 5 votes vote down vote up
public static void drawMatchesKnn(Mat img1, MatOfKeyPoint keypoints1, Mat img2, MatOfKeyPoint keypoints2, List<MatOfDMatch> matches1to2, Mat outImg, Scalar matchColor, Scalar singlePointColor, List<MatOfByte> matchesMask, int flags)
{
    Mat keypoints1_mat = keypoints1;
    Mat keypoints2_mat = keypoints2;
    List<Mat> matches1to2_tmplm = new ArrayList<Mat>((matches1to2 != null) ? matches1to2.size() : 0);
    Mat matches1to2_mat = Converters.vector_vector_DMatch_to_Mat(matches1to2, matches1to2_tmplm);
    List<Mat> matchesMask_tmplm = new ArrayList<Mat>((matchesMask != null) ? matchesMask.size() : 0);
    Mat matchesMask_mat = Converters.vector_vector_char_to_Mat(matchesMask, matchesMask_tmplm);
    drawMatchesKnn_0(img1.nativeObj, keypoints1_mat.nativeObj, img2.nativeObj, keypoints2_mat.nativeObj, matches1to2_mat.nativeObj, outImg.nativeObj, matchColor.val[0], matchColor.val[1], matchColor.val[2], matchColor.val[3], singlePointColor.val[0], singlePointColor.val[1], singlePointColor.val[2], singlePointColor.val[3], matchesMask_mat.nativeObj, flags);
    
    return;
}
 
Example 10
Project: MOAAP   File: Calib3d.java   View source code 5 votes vote down vote up
public static boolean solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence, Mat inliers, int flags)
{
    Mat objectPoints_mat = objectPoints;
    Mat imagePoints_mat = imagePoints;
    Mat distCoeffs_mat = distCoeffs;
    boolean retVal = solvePnPRansac_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount, reprojectionError, confidence, inliers.nativeObj, flags);
    
    return retVal;
}
 
Example 11
Project: react-native-scan-doc   File: DescriptorMatcher.java   View source code 5 votes vote down vote up
public  void match(Mat queryDescriptors, MatOfDMatch matches)
{
    Mat matches_mat = matches;
    match_3(nativeObj, queryDescriptors.nativeObj, matches_mat.nativeObj);
    
    return;
}
 
Example 12
Project: DNNLibrary   File: Imgproc.java   View source code 5 votes vote down vote up
public static void polylines(Mat img, List<MatOfPoint> pts, boolean isClosed, Scalar color, int thickness)
{
    List<Mat> pts_tmplm = new ArrayList<Mat>((pts != null) ? pts.size() : 0);
    Mat pts_mat = Converters.vector_vector_Point_to_Mat(pts, pts_tmplm);
    polylines_1(img.nativeObj, pts_mat.nativeObj, isClosed, color.val[0], color.val[1], color.val[2], color.val[3], thickness);
    
    return;
}
 
Example 13
Project: EyeShopping   File: Imgproc.java   View source code 5 votes vote down vote up
public static void cornerSubPix(Mat image, MatOfPoint2f corners, Size winSize, Size zeroZone, TermCriteria criteria)
{
    Mat corners_mat = corners;
    cornerSubPix_0(image.nativeObj, corners_mat.nativeObj, winSize.width, winSize.height, zeroZone.width, zeroZone.height, criteria.type, criteria.maxCount, criteria.epsilon);
    
    return;
}
 
Example 14
Project: TinyPlanetMaker   File: HOGDescriptor.java   View source code 5 votes vote down vote up
public  void detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights)
{
    Mat foundLocations_mat = foundLocations;
    Mat weights_mat = weights;
    detect_1(nativeObj, img.nativeObj, foundLocations_mat.nativeObj, weights_mat.nativeObj);

    return;
}
 
Example 15
Project: FTC2016   File: Imgproc.java   View source code 5 votes vote down vote up
public static Point phaseCorrelate(Mat src1, Mat src2, Mat window, double[] response)
{
    double[] response_out = new double[1];
    Point retVal = new Point(phaseCorrelate_0(src1.nativeObj, src2.nativeObj, window.nativeObj, response_out));
    if(response!=null) response[0] = (double)response_out[0];
    return retVal;
}
 
Example 16
Project: DogeCV   File: Calib3d.java   View source code 5 votes vote down vote up
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 17
Project: mao-android   File: Calib3d.java   View source code 5 votes vote down vote up
public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, int flags)
{
    Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
    Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
    Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
    double retVal = stereoCalibrate_1(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, flags);
    
    return retVal;
}
 
Example 18
Project: android-imaging-utils   File: AlignMTB.java   View source code 5 votes vote down vote up
public  void process(List<Mat> src, List<Mat> dst, Mat times, Mat response)
{
    Mat src_mat = Converters.vector_Mat_to_Mat(src);
    Mat dst_mat = Converters.vector_Mat_to_Mat(dst);
    process_0(nativeObj, src_mat.nativeObj, dst_mat.nativeObj, times.nativeObj, response.nativeObj);
    
    return;
}
 
Example 19
Project: Checkerboard-IMU-Comparator   File: Imgcodecs.java   View source code 5 votes vote down vote up
public static boolean imwrite(String filename, Mat img, MatOfInt params)
{
    Mat params_mat = params;
    boolean retVal = imwrite_0(filename, img.nativeObj, params_mat.nativeObj);
    
    return retVal;
}
 
Example 20
Project: fingerblox   File: Imgproc.java   View source code 5 votes vote down vote up
public static void cornerSubPix(Mat image, MatOfPoint2f corners, Size winSize, Size zeroZone, TermCriteria criteria)
{
    Mat corners_mat = corners;
    cornerSubPix_0(image.nativeObj, corners_mat.nativeObj, winSize.width, winSize.height, zeroZone.width, zeroZone.height, criteria.type, criteria.maxCount, criteria.epsilon);
    
    return;
}
 
Example 21
Project: FTC2016   File: Imgproc.java   View source code 5 votes vote down vote up
public static void undistortPoints(MatOfPoint2f src, MatOfPoint2f dst, Mat cameraMatrix, Mat distCoeffs)
{
    Mat src_mat = src;
    Mat dst_mat = dst;
    undistortPoints_1(src_mat.nativeObj, dst_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj);
    
    return;
}
 
Example 22
Project: Android-Code-Demos   File: Core.java   View source code 5 votes vote down vote up
public static void mixChannels(List<Mat> src, List<Mat> dst, MatOfInt fromTo)
{
    Mat src_mat = Converters.vector_Mat_to_Mat(src);
    Mat dst_mat = Converters.vector_Mat_to_Mat(dst);
    Mat fromTo_mat = fromTo;
    mixChannels_0(src_mat.nativeObj, dst_mat.nativeObj, fromTo_mat.nativeObj);
    
    return;
}
 
Example 23
Project: MOAAP   File: DescriptorMatcher.java   View source code 5 votes vote down vote up
public  void radiusMatch(Mat queryDescriptors, Mat trainDescriptors, List<MatOfDMatch> matches, float maxDistance, Mat mask, boolean compactResult)
{
    Mat matches_mat = new Mat();
    radiusMatch_0(nativeObj, queryDescriptors.nativeObj, trainDescriptors.nativeObj, matches_mat.nativeObj, maxDistance, mask.nativeObj, compactResult);
    Converters.Mat_to_vector_vector_DMatch(matches_mat, matches);
    matches_mat.release();
    return;
}
 
Example 24
Project: MOAAP   File: Converters.java   View source code 5 votes vote down vote up
public static void Mat_to_vector_DMatch(Mat m, List<DMatch> matches) {
    if (matches == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_64FC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_64FC4 != m.type() ||  m.cols()!=1\n" + m);

    matches.clear();
    double[] buff = new double[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        matches.add(new DMatch((int) buff[4 * i], (int) buff[4 * i + 1], (int) buff[4 * i + 2], (float) buff[4 * i + 3]));
    }
}
 
Example 25
Project: MOAAP   File: Features2d.java   View source code 5 votes vote down vote up
public static void drawKeypoints(Mat image, MatOfKeyPoint keypoints, Mat outImage, Scalar color, int flags)
{
    Mat keypoints_mat = keypoints;
    drawKeypoints_0(image.nativeObj, keypoints_mat.nativeObj, outImage.nativeObj, color.val[0], color.val[1], color.val[2], color.val[3], flags);
    
    return;
}
 
Example 26
Project: DNNLibrary   File: Calib3d.java   View source code 5 votes vote down vote up
public static void projectPoints(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat rvec, Mat tvec, Mat K, Mat D)
{
    Mat objectPoints_mat = objectPoints;
    Mat imagePoints_mat = imagePoints;
    projectPoints_3(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, K.nativeObj, D.nativeObj);
    
    return;
}
 
Example 27
Project: cc-unespar   File: Rotacao.java   View source code 4 votes vote down vote up
public Rotacao (Mat imagem){
	this.original = imagem;
}
 
Example 28
Project: android-age-estimator   File: Converters.java   View source code 4 votes vote down vote up
public static Mat vector_Point3f_to_Mat(List<Point3> pts) {
    return vector_Point3_to_Mat(pts, CvType.CV_32F);
}
 
Example 29
Project: OpenCV   File: Converters.java   View source code 4 votes vote down vote up
public static Mat vector_Point3d_to_Mat(List<Point3> pts) {
    return vector_Point3_to_Mat(pts, CvType.CV_64F);
}
 
Example 30
Project: react-native-scan-doc   File: CameraBridgeViewBase.java   View source code 4 votes vote down vote up
/**
 * This method shall be called by the subclasses when they have valid
 * object and want it to be delivered to external client (via callback) and
 * then displayed on the screen.
 * @param frame - the current frame to be delivered
 */
protected void deliverAndDrawFrame(CvCameraViewFrame frame) {
    Mat modified;

    if (mListener != null) {
        modified = mListener.onCameraFrame(frame);
    } else {
        modified = frame.rgba();
    }

    boolean bmpValid = true;
    if (modified != null) {
        try {
            Utils.matToBitmap(modified, mCacheBitmap);
        } catch(Exception e) {
            Log.e(TAG, "Mat type: " + modified);
            Log.e(TAG, "Bitmap type: " + mCacheBitmap.getWidth() + "*" + mCacheBitmap.getHeight());
            Log.e(TAG, "Utils.matToBitmap() throws an exception: " + e.getMessage());
            bmpValid = false;
        }
    }

    if (bmpValid && mCacheBitmap != null) {
        Canvas canvas = getHolder().lockCanvas();
        if (canvas != null) {
            canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
            if (BuildConfig.DEBUG)
                Log.d(TAG, "mStretch value: " + mScale);

            if (mScale != 0) {
                canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
                     new Rect((int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2),
                     (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2),
                     (int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2 + mScale*mCacheBitmap.getWidth()),
                     (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2 + mScale*mCacheBitmap.getHeight())), null);
            } else {
                 canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
                     new Rect((canvas.getWidth() - mCacheBitmap.getWidth()) / 2,
                     (canvas.getHeight() - mCacheBitmap.getHeight()) / 2,
                     (canvas.getWidth() - mCacheBitmap.getWidth()) / 2 + mCacheBitmap.getWidth(),
                     (canvas.getHeight() - mCacheBitmap.getHeight()) / 2 + mCacheBitmap.getHeight()), null);
            }

            if (mFpsMeter != null) {
                mFpsMeter.measure();
                mFpsMeter.draw(canvas, 20, 30);
            }
            getHolder().unlockCanvasAndPost(canvas);
        }
    }
}
 
Example 31
Project: MOAAP   File: Converters.java   View source code 4 votes vote down vote up
public static void Mat_to_vector_Point3i(Mat m, List<Point3> pts) {
    Mat_to_vector_Point3(m, pts);
}
 
Example 32
Project: MOAAP   File: Converters.java   View source code 4 votes vote down vote up
public static void Mat_to_vector_Point2f(Mat m, List<Point> pts) {
    Mat_to_vector_Point(m, pts);
}
 
Example 33
Project: cc-unespar   File: Main.java   View source code 4 votes vote down vote up
public static Mat abrirImagem(String path) {
	System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
	return Imgcodecs.imread(path, IMREAD_COLOR);
}
 
Example 34
Project: tttclass   File: StudentService.java   View source code 4 votes vote down vote up
public Mat findStudentPhotoByID(String sID)
{
	// return this.StudentDaoImptOfService.findPhotoByID(sID);
	return Highgui.imread(" ");
}
 
Example 35
Project: MOAAP   File: Converters.java   View source code 4 votes vote down vote up
public static void Mat_to_vector_Point3i(Mat m, List<Point3> pts) {
    Mat_to_vector_Point3(m, pts);
}
 
Example 36
Project: FaceDetectDemo   File: Converters.java   View source code 4 votes vote down vote up
public static void Mat_to_vector_Point3d(Mat m, List<Point3> pts) {
    Mat_to_vector_Point3(m, pts);
}
 
Example 37
Project: renderscript_examples   File: TrainData.java   View source code 3 votes vote down vote up
public  Mat getTrainNormCatResponses()
{
    
    Mat retVal = new Mat(getTrainNormCatResponses_0(nativeObj));
    
    return retVal;
}
 
Example 38
Project: OpenCV   File: Photo.java   View source code 3 votes vote down vote up
public static void stylization(Mat src, Mat dst)
{
    
    stylization_1(src.nativeObj, dst.nativeObj);
    
    return;
}
 
Example 39
Project: MOAAP   File: Imgproc.java   View source code 3 votes vote down vote up
public static void preCornerDetect(Mat src, Mat dst, int ksize, int borderType)
{
    
    preCornerDetect_0(src.nativeObj, dst.nativeObj, ksize, borderType);
    
    return;
}
 
Example 40
Project: FTC2016   File: Core.java   View source code 3 votes vote down vote up
public static void LUT(Mat src, Mat lut, Mat dst)
{
    
    LUT_0(src.nativeObj, lut.nativeObj, dst.nativeObj);
    
    return;
}