Java Code Examples for org.opencv.core.CvType#CV_32FC1

The following examples show how to use org.opencv.core.CvType#CV_32FC1 . 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: Converters.java    From MOAAP with MIT License 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 2
Source File: Converters.java    From OpenCV-AndroidSamples with MIT License 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 3
Source File: Converters.java    From MOAAP with MIT License 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 4
Source File: Util.java    From OpenTLDAndroid with Apache License 2.0 5 votes vote down vote up
static float[] getFloatArray(final Mat mat){
	if(CvType.CV_32FC1 != mat.type()) throw new IllegalArgumentException("Expected type is CV_32FC1, we found: " + CvType.typeToString(mat.type()));
	
	final int size = (int) (mat.total() * mat.channels());
	if(_floatBuff.length != size){
		_floatBuff = new float[size];
	}
	mat.get(0, 0, _floatBuff); // 0 for row and col means the WHOLE Matrix
	return _floatBuff;
}
 
Example 5
Source File: Converters.java    From SmartPaperScan with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 6
Source File: Converters.java    From real_time_circle_detection_android with MIT License 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 7
Source File: Converters.java    From FaceDetectDemo with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 8
Source File: Converters.java    From Image-Detection-Samples with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 9
Source File: Converters.java    From sudokufx with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 10
Source File: Converters.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 11
Source File: Converters.java    From ml-authentication with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 12
Source File: Converters.java    From ml-authentication with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 13
Source File: Converters.java    From faceswap with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 14
Source File: Converters.java    From Form-N-Fun with MIT License 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 15
Source File: Converters.java    From android-object-distance with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 16
Source File: Converters.java    From pasm-yolov3-Android with GNU General Public License v3.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 17
Source File: Converters.java    From LicensePlateDiscern with MIT License 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 18
Source File: Converters.java    From SimpleDocumentScanner-Android with MIT License 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 19
Source File: Converters.java    From Camdroid with Apache License 2.0 5 votes vote down vote up
public static void Mat_to_vector_float(Mat m, List<Float> fs) {
    if (fs == null)
        throw new java.lang.IllegalArgumentException("fs == null");
    int count = m.rows();
    if (CvType.CV_32FC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32FC1 != m.type() ||  m.cols()!=1\n" + m);

    fs.clear();
    float[] buff = new float[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        fs.add(buff[i]);
    }
}
 
Example 20
Source File: ImageFinder.java    From opentest with MIT License 4 votes vote down vote up
/**
 * Finds a template image in a source image. Throws an exception when the
 * image wasn't found or the desired accuracy couldn't be met.
 *
 * @param sourceMat The source image.
 * @param templateMat The template image to find in the source image.
 * @param desiredAccuracy The desired accuracy of the find operation as a
 * number between 0 and 1.
 * @return An ImageFinderResult object that stores the rectangle of the
 * found image and desired accuracy.
 */
private ImageFinderResult findImage(Mat sourceMat, Mat templateMat, double desiredAccuracy) {
    if (sourceMat.width() < templateMat.width() || sourceMat.height() < templateMat.height()) {
        throw new UnsupportedOperationException("The template image is larger than the source image. Ensure that the width and/or height of the image you are trying to find do not exceed the dimensions of the source image.");
    }

    Mat result = new Mat(sourceMat.rows() - templateMat.rows() + 1, sourceMat.rows() - templateMat.rows() + 1, CvType.CV_32FC1);
    int intMatchingMethod;

    switch (this.matchingMethod) {
        case MM_CORELLATION_COEFF:
            intMatchingMethod = Imgproc.TM_CCOEFF_NORMED;
            break;
        case MM_CROSS_CORELLATION:
            intMatchingMethod = Imgproc.TM_CCORR_NORMED;
            break;
        default:
            intMatchingMethod = Imgproc.TM_SQDIFF_NORMED;
    }

    Imgproc.matchTemplate(sourceMat, templateMat, result, intMatchingMethod);
    MinMaxLocResult minMaxLocRes = Core.minMaxLoc(result);

    double accuracy = 0;
    Point location = null;

    if (this.matchingMethod == MatchingMethod.MM_SQUARE_DIFFERENCE) {
        accuracy = 1 - minMaxLocRes.minVal;
        location = minMaxLocRes.minLoc;
    } else {
        accuracy = minMaxLocRes.maxVal;
        location = minMaxLocRes.maxLoc;
    }

    if (accuracy < desiredAccuracy) {
        throw new ImageNotFoundException(
                String.format(
                        "Failed to find template image in the source image. The accuracy was %.2f and the desired accuracy was %.2f",
                        accuracy,
                        desiredAccuracy),
                new Rectangle((int) location.x, (int) location.y, templateMat.width(), templateMat.height()),
                accuracy);
    }

    if (!minMaxLocResultIsValid(minMaxLocRes)) {
        throw new ImageNotFoundException(
                "Image find result (MinMaxLocResult) was invalid. This usually happens when the source image is covered in one solid color.",
                null,
                null);
    }

    Rectangle foundRect = new Rectangle(
            (int) location.x,
            (int) location.y,
            templateMat.width(),
            templateMat.height());

    return new ImageFinderResult(foundRect, accuracy);
}