org.opencv.core.MatOfFloat Java Examples

The following examples show how to use org.opencv.core.MatOfFloat. 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: OpenCVoperation.java    From Human-hair-detection with Apache License 2.0 6 votes vote down vote up
public void predict_hair_color()
{
    Mat hsv_input = matrix9_finalOutput.clone();
    List<Mat> channels= new ArrayList<>();
    Mat hsv_histogram = new Mat();
    MatOfFloat  ranges = new MatOfFloat(0,180);
    MatOfInt histSize = new MatOfInt(255);
    Imgproc.cvtColor(hsv_input, hsv_input, Imgproc.COLOR_BGR2HSV);
    Core.split(hsv_input, channels);
    Imgproc.calcHist(channels.subList(0,1), new MatOfInt(0), new Mat(), hsv_histogram, histSize, ranges);
    int hist_w =256;
    int hist_h = 150;
    
    int bin_w =(int)Math.round(hist_w/histSize.get(0,0)[0]);
    Mat histImage= new Mat(hist_h,hist_w,CvType.CV_8UC3,new Scalar(0,0,0));
    
    for(int i=1;i < histSize.get(0,0)[0];i++)
    {
        Imgproc.line(histImage, new Point(bin_w * (i - 1), hist_h - Math.round(hsv_histogram.get(i - 1, 0)[0])), new Point(bin_w * (i), hist_h - Math.round(hsv_histogram.get(i, 0)[0])), new Scalar(255,0,0),2);			    
    }
    Imgcodecs.imwrite(resultDirectory+"histogram_image.png",histImage);
}
 
Example #2
Source File: Video.java    From Machine-Learning-Projects-for-Mobile-Applications with MIT License 5 votes vote down vote up
public static void calcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, MatOfPoint2f prevPts, MatOfPoint2f nextPts, MatOfByte status, MatOfFloat err)
{
    Mat prevPts_mat = prevPts;
    Mat nextPts_mat = nextPts;
    Mat status_mat = status;
    Mat err_mat = err;
    calcOpticalFlowPyrLK_2(prevImg.nativeObj, nextImg.nativeObj, prevPts_mat.nativeObj, nextPts_mat.nativeObj, status_mat.nativeObj, err_mat.nativeObj);
    
    return;
}
 
Example #3
Source File: HOGDescriptor.java    From OpenCV-android with Apache License 2.0 5 votes vote down vote up
public  void compute(Mat img, MatOfFloat descriptors)
{
    Mat descriptors_mat = descriptors;
    compute_1(nativeObj, img.nativeObj, descriptors_mat.nativeObj);
    
    return;
}
 
Example #4
Source File: BRISK.java    From pasm-yolov3-Android with GNU General Public License v3.0 5 votes vote down vote up
public static BRISK create(MatOfFloat radiusList, MatOfInt numberList, float dMax)
{
    Mat radiusList_mat = radiusList;
    Mat numberList_mat = numberList;
    BRISK retVal = BRISK.__fromPtr__(create_10(radiusList_mat.nativeObj, numberList_mat.nativeObj, dMax));
    
    return retVal;
}
 
Example #5
Source File: HOGDescriptor.java    From marvel with MIT License 5 votes vote down vote up
public  void compute(Mat img, MatOfFloat descriptors)
{
    Mat descriptors_mat = descriptors;
    compute_1(nativeObj, img.nativeObj, descriptors_mat.nativeObj);

    return;
}
 
Example #6
Source File: Imgproc.java    From opencv-documentscanner-android with Apache License 2.0 5 votes vote down vote up
public static void calcHist(List<Mat> images, MatOfInt channels, Mat mask, Mat hist, MatOfInt histSize, MatOfFloat ranges, boolean accumulate)
{
    Mat images_mat = Converters.vector_Mat_to_Mat(images);
    Mat channels_mat = channels;
    Mat histSize_mat = histSize;
    Mat ranges_mat = ranges;
    calcHist_0(images_mat.nativeObj, channels_mat.nativeObj, mask.nativeObj, hist.nativeObj, histSize_mat.nativeObj, ranges_mat.nativeObj, accumulate);
    
    return;
}
 
Example #7
Source File: Photo.java    From MOAAP with MIT License 5 votes vote down vote up
public static void fastNlMeansDenoising(Mat src, Mat dst, MatOfFloat h, int templateWindowSize, int searchWindowSize, int normType)
{
    Mat h_mat = h;
    fastNlMeansDenoising_2(src.nativeObj, dst.nativeObj, h_mat.nativeObj, templateWindowSize, searchWindowSize, normType);
    
    return;
}
 
Example #8
Source File: Imgproc.java    From OpenCV-android with Apache License 2.0 5 votes vote down vote up
public static void calcBackProject(List<Mat> images, MatOfInt channels, Mat hist, Mat dst, MatOfFloat ranges, double scale)
{
    Mat images_mat = Converters.vector_Mat_to_Mat(images);
    Mat channels_mat = channels;
    Mat ranges_mat = ranges;
    calcBackProject_0(images_mat.nativeObj, channels_mat.nativeObj, hist.nativeObj, dst.nativeObj, ranges_mat.nativeObj, scale);
    
    return;
}
 
Example #9
Source File: Photo.java    From FaceDetectDemo with Apache License 2.0 5 votes vote down vote up
public static void fastNlMeansDenoisingMulti(List<Mat> srcImgs, Mat dst, int imgToDenoiseIndex, int temporalWindowSize, MatOfFloat h)
{
    Mat srcImgs_mat = Converters.vector_Mat_to_Mat(srcImgs);
    Mat h_mat = h;
    fastNlMeansDenoisingMulti_3(srcImgs_mat.nativeObj, dst.nativeObj, imgToDenoiseIndex, temporalWindowSize, h_mat.nativeObj);
    
    return;
}
 
Example #10
Source File: Video.java    From LPR with Apache License 2.0 5 votes vote down vote up
public static void calcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, MatOfPoint2f prevPts, MatOfPoint2f nextPts, MatOfByte status, MatOfFloat err, Size winSize, int maxLevel, TermCriteria criteria)
{
    Mat prevPts_mat = prevPts;
    Mat nextPts_mat = nextPts;
    Mat status_mat = status;
    Mat err_mat = err;
    calcOpticalFlowPyrLK_2(prevImg.nativeObj, nextImg.nativeObj, prevPts_mat.nativeObj, nextPts_mat.nativeObj, status_mat.nativeObj, err_mat.nativeObj, winSize.width, winSize.height, maxLevel, criteria.type, criteria.maxCount, criteria.epsilon);
    
    return;
}
 
Example #11
Source File: HOGDescriptor.java    From LPR with Apache License 2.0 5 votes vote down vote up
public  void compute(Mat img, MatOfFloat descriptors, Size winStride, Size padding, MatOfPoint locations)
{
    Mat descriptors_mat = descriptors;
    Mat locations_mat = locations;
    compute_0(nativeObj, img.nativeObj, descriptors_mat.nativeObj, winStride.width, winStride.height, padding.width, padding.height, locations_mat.nativeObj);
    
    return;
}
 
Example #12
Source File: Contrib.java    From Android-Car-duino with GNU General Public License v2.0 5 votes vote down vote up
public static int chamerMatching(Mat img, Mat templ, List<MatOfPoint> results, MatOfFloat cost, double templScale, int maxMatches, double minMatchDistance, int padX, int padY, int scales, double minScale, double maxScale, double orientationWeight, double truncate)
{
    Mat results_mat = new Mat();
    Mat cost_mat = cost;
    int retVal = chamerMatching_0(img.nativeObj, templ.nativeObj, results_mat.nativeObj, cost_mat.nativeObj, templScale, maxMatches, minMatchDistance, padX, padY, scales, minScale, maxScale, orientationWeight, truncate);
    Converters.Mat_to_vector_vector_Point(results_mat, results);
    return retVal;
}
 
Example #13
Source File: Video.java    From OpenCV-android with Apache License 2.0 5 votes vote down vote up
public static void calcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, MatOfPoint2f prevPts, MatOfPoint2f nextPts, MatOfByte status, MatOfFloat err, Size winSize, int maxLevel)
{
    Mat prevPts_mat = prevPts;
    Mat nextPts_mat = nextPts;
    Mat status_mat = status;
    Mat err_mat = err;
    calcOpticalFlowPyrLK_1(prevImg.nativeObj, nextImg.nativeObj, prevPts_mat.nativeObj, nextPts_mat.nativeObj, status_mat.nativeObj, err_mat.nativeObj, winSize.width, winSize.height, maxLevel);
    
    return;
}
 
Example #14
Source File: Imgproc.java    From ml-authentication with Apache License 2.0 5 votes vote down vote up
public static void calcHist(List<Mat> images, MatOfInt channels, Mat mask, Mat hist, MatOfInt histSize, MatOfFloat ranges, boolean accumulate)
{
    Mat images_mat = Converters.vector_Mat_to_Mat(images);
    Mat channels_mat = channels;
    Mat histSize_mat = histSize;
    Mat ranges_mat = ranges;
    calcHist_0(images_mat.nativeObj, channels_mat.nativeObj, mask.nativeObj, hist.nativeObj, histSize_mat.nativeObj, ranges_mat.nativeObj, accumulate);
    
    return;
}
 
Example #15
Source File: LKTracker.java    From OpenTLDAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * @return Pair of new, FILTERED, last and current POINTS, or null if it hasn't managed to track anything.
 */
Pair<Point[], Point[]> track(final Mat lastImg, final Mat currentImg, Point[] lastPoints){
	final int size = lastPoints.length;
	final MatOfPoint2f currentPointsMat = new MatOfPoint2f();
	final MatOfPoint2f pointsFBMat = new MatOfPoint2f();
	final MatOfByte statusMat = new MatOfByte();
	final MatOfFloat errSimilarityMat = new MatOfFloat();
	final MatOfByte statusFBMat = new MatOfByte();
	final MatOfFloat errSimilarityFBMat = new MatOfFloat();
	
	//Forward-Backward tracking
	Video.calcOpticalFlowPyrLK(lastImg, currentImg, new MatOfPoint2f(lastPoints), currentPointsMat, 
			statusMat, errSimilarityMat, WINDOW_SIZE, MAX_LEVEL, termCriteria, 0, LAMBDA);
	Video.calcOpticalFlowPyrLK(currentImg, lastImg, currentPointsMat, pointsFBMat, 
			statusFBMat, errSimilarityFBMat, WINDOW_SIZE, MAX_LEVEL, termCriteria, 0, LAMBDA);
	
	final byte[] status = statusMat.toArray();
	float[] errSimilarity = new float[lastPoints.length]; 
	//final byte[] statusFB = statusFBMat.toArray();
	final float[] errSimilarityFB = errSimilarityFBMat.toArray();	
	
	// compute the real FB error (relative to LAST points not the current ones...
	final Point[] pointsFB = pointsFBMat.toArray();
	for(int i = 0; i < size; i++){
		errSimilarityFB[i] = Util.norm(pointsFB[i], lastPoints[i]);
	}
	
	final Point[] currPoints = currentPointsMat.toArray();
	// compute real similarity error
	errSimilarity = normCrossCorrelation(lastImg, currentImg, lastPoints, currPoints, status);
	
	
	//TODO  errSimilarityFB has problem != from C++
	// filter out points with fwd-back error > the median AND points with similarity error > median
	return filterPts(lastPoints, currPoints, errSimilarity, errSimilarityFB, status);
}
 
Example #16
Source File: BRISK.java    From OpenCvFaceDetect with Apache License 2.0 5 votes vote down vote up
public static BRISK create(MatOfFloat radiusList, MatOfInt numberList)
{
    Mat radiusList_mat = radiusList;
    Mat numberList_mat = numberList;
    BRISK retVal = BRISK.__fromPtr__(create_11(radiusList_mat.nativeObj, numberList_mat.nativeObj));
    
    return retVal;
}
 
Example #17
Source File: Photo.java    From LicensePlateDiscern with MIT License 5 votes vote down vote up
public static void fastNlMeansDenoisingMulti(List<Mat> srcImgs, Mat dst, int imgToDenoiseIndex, int temporalWindowSize, MatOfFloat h, int templateWindowSize, int searchWindowSize, int normType)
{
    Mat srcImgs_mat = Converters.vector_Mat_to_Mat(srcImgs);
    Mat h_mat = h;
    fastNlMeansDenoisingMulti_4(srcImgs_mat.nativeObj, dst.nativeObj, imgToDenoiseIndex, temporalWindowSize, h_mat.nativeObj, templateWindowSize, searchWindowSize, normType);
    
    return;
}
 
Example #18
Source File: Photo.java    From MOAAP with MIT License 5 votes vote down vote up
public static void fastNlMeansDenoisingMulti(List<Mat> srcImgs, Mat dst, int imgToDenoiseIndex, int temporalWindowSize, MatOfFloat h)
{
    Mat srcImgs_mat = Converters.vector_Mat_to_Mat(srcImgs);
    Mat h_mat = h;
    fastNlMeansDenoisingMulti_3(srcImgs_mat.nativeObj, dst.nativeObj, imgToDenoiseIndex, temporalWindowSize, h_mat.nativeObj);
    
    return;
}
 
Example #19
Source File: BRISK.java    From Chinese-number-gestures-recognition with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static BRISK create(MatOfFloat radiusList, MatOfInt numberList)
{
    Mat radiusList_mat = radiusList;
    Mat numberList_mat = numberList;
    BRISK retVal = new BRISK(create_5(radiusList_mat.nativeObj, numberList_mat.nativeObj));
    
    return retVal;
}
 
Example #20
Source File: Imgproc.java    From Chinese-number-gestures-recognition with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void calcHist(List<Mat> images, MatOfInt channels, Mat mask, Mat hist, MatOfInt histSize, MatOfFloat ranges)
{
    Mat images_mat = Converters.vector_Mat_to_Mat(images);
    Mat channels_mat = channels;
    Mat histSize_mat = histSize;
    Mat ranges_mat = ranges;
    calcHist_1(images_mat.nativeObj, channels_mat.nativeObj, mask.nativeObj, hist.nativeObj, histSize_mat.nativeObj, ranges_mat.nativeObj);
    
    return;
}
 
Example #21
Source File: Imgproc.java    From Machine-Learning-Projects-for-Mobile-Applications with MIT License 5 votes vote down vote up
public static void calcHist(List<Mat> images, MatOfInt channels, Mat mask, Mat hist, MatOfInt histSize, MatOfFloat ranges, boolean accumulate)
{
    Mat images_mat = Converters.vector_Mat_to_Mat(images);
    Mat channels_mat = channels;
    Mat histSize_mat = histSize;
    Mat ranges_mat = ranges;
    calcHist_0(images_mat.nativeObj, channels_mat.nativeObj, mask.nativeObj, hist.nativeObj, histSize_mat.nativeObj, ranges_mat.nativeObj, accumulate);
    
    return;
}
 
Example #22
Source File: Photo.java    From faceswap with Apache License 2.0 5 votes vote down vote up
public static void fastNlMeansDenoisingMulti(List<Mat> srcImgs, Mat dst, int imgToDenoiseIndex, int temporalWindowSize, MatOfFloat h)
{
    Mat srcImgs_mat = Converters.vector_Mat_to_Mat(srcImgs);
    Mat h_mat = h;
    fastNlMeansDenoisingMulti_3(srcImgs_mat.nativeObj, dst.nativeObj, imgToDenoiseIndex, temporalWindowSize, h_mat.nativeObj);
    
    return;
}
 
Example #23
Source File: Imgproc.java    From Form-N-Fun with MIT License 5 votes vote down vote up
public static void calcHist(List<Mat> images, MatOfInt channels, Mat mask, Mat hist, MatOfInt histSize, MatOfFloat ranges)
{
    Mat images_mat = Converters.vector_Mat_to_Mat(images);
    Mat channels_mat = channels;
    Mat histSize_mat = histSize;
    Mat ranges_mat = ranges;
    calcHist_1(images_mat.nativeObj, channels_mat.nativeObj, mask.nativeObj, hist.nativeObj, histSize_mat.nativeObj, ranges_mat.nativeObj);
    
    return;
}
 
Example #24
Source File: Photo.java    From sudokufx with Apache License 2.0 5 votes vote down vote up
public static void fastNlMeansDenoisingMulti(List<Mat> srcImgs, Mat dst, int imgToDenoiseIndex, int temporalWindowSize, MatOfFloat h, int templateWindowSize, int searchWindowSize, int normType)
{
    Mat srcImgs_mat = Converters.vector_Mat_to_Mat(srcImgs);
    Mat h_mat = h;
    fastNlMeansDenoisingMulti_2(srcImgs_mat.nativeObj, dst.nativeObj, imgToDenoiseIndex, temporalWindowSize, h_mat.nativeObj, templateWindowSize, searchWindowSize, normType);
    
    return;
}
 
Example #25
Source File: HOGDescriptor.java    From LPR with Apache License 2.0 5 votes vote down vote up
public  void compute(Mat img, MatOfFloat descriptors, Size winStride)
{
    Mat descriptors_mat = descriptors;
    compute_2(nativeObj, img.nativeObj, descriptors_mat.nativeObj, winStride.width, winStride.height);
    
    return;
}
 
Example #26
Source File: Video.java    From SmartPaperScan with Apache License 2.0 5 votes vote down vote up
public static void calcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, MatOfPoint2f prevPts, MatOfPoint2f nextPts, MatOfByte status, MatOfFloat err, Size winSize, int maxLevel, TermCriteria criteria, int flags, double minEigThreshold)
{
    Mat prevPts_mat = prevPts;
    Mat nextPts_mat = nextPts;
    Mat status_mat = status;
    Mat err_mat = err;
    calcOpticalFlowPyrLK_0(prevImg.nativeObj, nextImg.nativeObj, prevPts_mat.nativeObj, nextPts_mat.nativeObj, status_mat.nativeObj, err_mat.nativeObj, winSize.width, winSize.height, maxLevel, criteria.type, criteria.maxCount, criteria.epsilon, flags, minEigThreshold);
    
    return;
}
 
Example #27
Source File: Photo.java    From SimpleDocumentScanner-Android with MIT License 5 votes vote down vote up
public static void fastNlMeansDenoising(Mat src, Mat dst, MatOfFloat h, int templateWindowSize, int searchWindowSize, int normType)
{
    Mat h_mat = h;
    fastNlMeansDenoising_2(src.nativeObj, dst.nativeObj, h_mat.nativeObj, templateWindowSize, searchWindowSize, normType);
    
    return;
}
 
Example #28
Source File: BRISK.java    From pasm-yolov3-Android with GNU General Public License v3.0 5 votes vote down vote up
public static BRISK create(MatOfFloat radiusList, MatOfInt numberList, float dMax, float dMin)
{
    Mat radiusList_mat = radiusList;
    Mat numberList_mat = numberList;
    BRISK retVal = BRISK.__fromPtr__(create_9(radiusList_mat.nativeObj, numberList_mat.nativeObj, dMax, dMin));
    
    return retVal;
}
 
Example #29
Source File: Video.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public static void calcOpticalFlowPyrLK(Mat prevImg, Mat nextImg, MatOfPoint2f prevPts, MatOfPoint2f nextPts, MatOfByte status, MatOfFloat err, Size winSize, int maxLevel)
{
    Mat prevPts_mat = prevPts;
    Mat nextPts_mat = nextPts;
    Mat status_mat = status;
    Mat err_mat = err;
    calcOpticalFlowPyrLK_1(prevImg.nativeObj, nextImg.nativeObj, prevPts_mat.nativeObj, nextPts_mat.nativeObj, status_mat.nativeObj, err_mat.nativeObj, winSize.width, winSize.height, maxLevel);
    
    return;
}
 
Example #30
Source File: HOGDescriptor.java    From SoftwarePilot with MIT License 5 votes vote down vote up
public  void compute(Mat img, MatOfFloat descriptors)
{
    Mat descriptors_mat = descriptors;
    compute_1(nativeObj, img.nativeObj, descriptors_mat.nativeObj);

    return;
}