org.opencv.core.Rect Java Examples

The following examples show how to use org.opencv.core.Rect. 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: VideoMotionDetector.java    From video-stream-analytics with Apache License 2.0 6 votes vote down vote up
private static ArrayList<Rect> getContourArea(Mat mat) {
	Mat hierarchy = new Mat();
	Mat image = mat.clone();
	List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
	Imgproc.findContours(image, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
	Rect rect = null;
	double maxArea = 300;
	ArrayList<Rect> arr = new ArrayList<Rect>();
	for (int i = 0; i < contours.size(); i++) {
		Mat contour = contours.get(i);
		double contourArea = Imgproc.contourArea(contour);
		if (contourArea > maxArea) {
			rect = Imgproc.boundingRect(contours.get(i));
			arr.add(rect);
		}
	}
	return arr;
}
 
Example #2
Source File: RecognitionActivity.java    From Android-Face-Recognition-with-Deep-Learning-Test-Framework with Apache License 2.0 6 votes vote down vote up
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    Mat imgRgba = inputFrame.rgba();
    Mat img = new Mat();
    imgRgba.copyTo(img);
    List<Mat> images = ppF.getProcessedImage(img, PreProcessorFactory.PreprocessingMode.RECOGNITION);
    Rect[] faces = ppF.getFacesForRecognition();

    // Selfie / Mirror mode
    if(front_camera){
        Core.flip(imgRgba,imgRgba,1);
    }
    if(images == null || images.size() == 0 || faces == null || faces.length == 0 || ! (images.size() == faces.length)){
        // skip
        return imgRgba;
    } else {
        faces = MatOperation.rotateFaces(imgRgba, faces, ppF.getAngleForRecognition());
        for(int i = 0; i<faces.length; i++){
            MatOperation.drawRectangleAndLabelOnPreview(imgRgba, faces[i], rec.recognize(images.get(i), ""), front_camera);
        }
        return imgRgba;
    }
}
 
Example #3
Source File: DetectEyes.java    From classchecks with Apache License 2.0 6 votes vote down vote up
protected static void detectRightEye(Mat faceImg, Rect rightEyeRect, int scaledWidth) {
	CascadeClassifier cascade = new CascadeClassifier();
	cascade.load(DetectorXMLPath+HAARCASCADE_MCS_RIGHTEYE);
	// 第一次检测右眼
	if(!cascade.empty()) {
		DetectObject.detectLargestObject(faceImg, cascade, rightEyeRect, scaledWidth);
	}
	if(rightEyeRect.width <= 0) {
		cascade.load(DetectorXMLPath+HAARCASCADE_EYE_TREE_EYEGLASSES);
		if(!cascade.empty()) {
			DetectObject.detectLargestObject(faceImg, cascade, rightEyeRect, scaledWidth);
		}
	}
	if(rightEyeRect.width <= 0) {
		cascade.load(DetectorXMLPath+HAARCASCADE_EYE);
		if(!cascade.empty()) {
			DetectObject.detectLargestObject(faceImg, cascade, rightEyeRect, scaledWidth);
		}
	}
}
 
Example #4
Source File: Calib3d.java    From Document-Scanner with GNU General Public License v3.0 5 votes vote down vote up
public static float rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, List<Mat> imgpt1, List<Mat> imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat R1, Mat R2, Mat R3, Mat P1, Mat P2, Mat P3, Mat Q, double alpha, Size newImgSize, Rect roi1, Rect roi2, int flags)
{
    Mat imgpt1_mat = Converters.vector_Mat_to_Mat(imgpt1);
    Mat imgpt3_mat = Converters.vector_Mat_to_Mat(imgpt3);
    double[] roi1_out = new double[4];
    double[] roi2_out = new double[4];
    float retVal = rectify3Collinear_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, cameraMatrix3.nativeObj, distCoeffs3.nativeObj, imgpt1_mat.nativeObj, imgpt3_mat.nativeObj, imageSize.width, imageSize.height, R12.nativeObj, T12.nativeObj, R13.nativeObj, T13.nativeObj, R1.nativeObj, R2.nativeObj, R3.nativeObj, P1.nativeObj, P2.nativeObj, P3.nativeObj, Q.nativeObj, alpha, newImgSize.width, newImgSize.height, roi1_out, roi2_out, flags);
    if(roi1!=null){ roi1.x = (int)roi1_out[0]; roi1.y = (int)roi1_out[1]; roi1.width = (int)roi1_out[2]; roi1.height = (int)roi1_out[3]; } 
    if(roi2!=null){ roi2.x = (int)roi2_out[0]; roi2.y = (int)roi2_out[1]; roi2.width = (int)roi2_out[2]; roi2.height = (int)roi2_out[3]; } 
    return retVal;
}
 
Example #5
Source File: Video.java    From ml-authentication with Apache License 2.0 5 votes vote down vote up
public static int meanShift(Mat probImage, Rect window, TermCriteria criteria)
{
    double[] window_out = new double[4];
    int retVal = meanShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon);
    if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } 
    return retVal;
}
 
Example #6
Source File: Calib3d.java    From marvel with MIT License 5 votes vote down vote up
public static float rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, List<Mat> imgpt1, List<Mat> imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat R1, Mat R2, Mat R3, Mat P1, Mat P2, Mat P3, Mat Q, double alpha, Size newImgSize, Rect roi1, Rect roi2, int flags)
{
    Mat imgpt1_mat = Converters.vector_Mat_to_Mat(imgpt1);
    Mat imgpt3_mat = Converters.vector_Mat_to_Mat(imgpt3);
    double[] roi1_out = new double[4];
    double[] roi2_out = new double[4];
    float retVal = rectify3Collinear_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, cameraMatrix3.nativeObj, distCoeffs3.nativeObj, imgpt1_mat.nativeObj, imgpt3_mat.nativeObj, imageSize.width, imageSize.height, R12.nativeObj, T12.nativeObj, R13.nativeObj, T13.nativeObj, R1.nativeObj, R2.nativeObj, R3.nativeObj, P1.nativeObj, P2.nativeObj, P3.nativeObj, Q.nativeObj, alpha, newImgSize.width, newImgSize.height, roi1_out, roi2_out, flags);
    if(roi1!=null){ roi1.x = (int)roi1_out[0]; roi1.y = (int)roi1_out[1]; roi1.width = (int)roi1_out[2]; roi1.height = (int)roi1_out[3]; }
    if(roi2!=null){ roi2.x = (int)roi2_out[0]; roi2.y = (int)roi2_out[1]; roi2.width = (int)roi2_out[2]; roi2.height = (int)roi2_out[3]; }
    return retVal;
}
 
Example #7
Source File: Imgproc.java    From OpenCV-android with Apache License 2.0 5 votes vote down vote up
public static int floodFill(Mat image, Mat mask, Point seedPoint, Scalar newVal, Rect rect, Scalar loDiff, Scalar upDiff, int flags)
{
    double[] rect_out = new double[4];
    int retVal = floodFill_0(image.nativeObj, mask.nativeObj, seedPoint.x, seedPoint.y, newVal.val[0], newVal.val[1], newVal.val[2], newVal.val[3], rect_out, loDiff.val[0], loDiff.val[1], loDiff.val[2], loDiff.val[3], upDiff.val[0], upDiff.val[1], upDiff.val[2], upDiff.val[3], flags);
    if(rect!=null){ rect.x = (int)rect_out[0]; rect.y = (int)rect_out[1]; rect.width = (int)rect_out[2]; rect.height = (int)rect_out[3]; } 
    return retVal;
}
 
Example #8
Source File: Calib3d.java    From MOAAP with MIT License 5 votes vote down vote up
public static float rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, List<Mat> imgpt1, List<Mat> imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat R1, Mat R2, Mat R3, Mat P1, Mat P2, Mat P3, Mat Q, double alpha, Size newImgSize, Rect roi1, Rect roi2, int flags)
{
    Mat imgpt1_mat = Converters.vector_Mat_to_Mat(imgpt1);
    Mat imgpt3_mat = Converters.vector_Mat_to_Mat(imgpt3);
    double[] roi1_out = new double[4];
    double[] roi2_out = new double[4];
    float retVal = rectify3Collinear_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, cameraMatrix3.nativeObj, distCoeffs3.nativeObj, imgpt1_mat.nativeObj, imgpt3_mat.nativeObj, imageSize.width, imageSize.height, R12.nativeObj, T12.nativeObj, R13.nativeObj, T13.nativeObj, R1.nativeObj, R2.nativeObj, R3.nativeObj, P1.nativeObj, P2.nativeObj, P3.nativeObj, Q.nativeObj, alpha, newImgSize.width, newImgSize.height, roi1_out, roi2_out, flags);
    if(roi1!=null){ roi1.x = (int)roi1_out[0]; roi1.y = (int)roi1_out[1]; roi1.width = (int)roi1_out[2]; roi1.height = (int)roi1_out[3]; } 
    if(roi2!=null){ roi2.x = (int)roi2_out[0]; roi2.y = (int)roi2_out[1]; roi2.width = (int)roi2_out[2]; roi2.height = (int)roi2_out[3]; } 
    return retVal;
}
 
Example #9
Source File: Imgproc.java    From pasm-yolov3-Android with GNU General Public License v3.0 5 votes vote down vote up
public static boolean clipLine(Rect imgRect, Point pt1, Point pt2)
{
    double[] pt1_out = new double[2];
    double[] pt2_out = new double[2];
    boolean retVal = clipLine_0(imgRect.x, imgRect.y, imgRect.width, imgRect.height, pt1.x, pt1.y, pt1_out, pt2.x, pt2.y, pt2_out);
    if(pt1!=null){ pt1.x = pt1_out[0]; pt1.y = pt1_out[1]; } 
    if(pt2!=null){ pt2.x = pt2_out[0]; pt2.y = pt2_out[1]; } 
    return retVal;
}
 
Example #10
Source File: Imgproc.java    From MOAAP with MIT License 5 votes vote down vote up
public static int floodFill(Mat image, Mat mask, Point seedPoint, Scalar newVal, Rect rect, Scalar loDiff, Scalar upDiff, int flags)
{
    double[] rect_out = new double[4];
    int retVal = floodFill_0(image.nativeObj, mask.nativeObj, seedPoint.x, seedPoint.y, newVal.val[0], newVal.val[1], newVal.val[2], newVal.val[3], rect_out, loDiff.val[0], loDiff.val[1], loDiff.val[2], loDiff.val[3], upDiff.val[0], upDiff.val[1], upDiff.val[2], upDiff.val[3], flags);
    if(rect!=null){ rect.x = (int)rect_out[0]; rect.y = (int)rect_out[1]; rect.width = (int)rect_out[2]; rect.height = (int)rect_out[3]; } 
    return retVal;
}
 
Example #11
Source File: Calib3d.java    From Image-Detection-Samples with Apache License 2.0 5 votes vote down vote up
public static float rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, List<Mat> imgpt1, List<Mat> imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat R1, Mat R2, Mat R3, Mat P1, Mat P2, Mat P3, Mat Q, double alpha, Size newImgSize, Rect roi1, Rect roi2, int flags)
{
    Mat imgpt1_mat = Converters.vector_Mat_to_Mat(imgpt1);
    Mat imgpt3_mat = Converters.vector_Mat_to_Mat(imgpt3);
    double[] roi1_out = new double[4];
    double[] roi2_out = new double[4];
    float retVal = rectify3Collinear_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, cameraMatrix3.nativeObj, distCoeffs3.nativeObj, imgpt1_mat.nativeObj, imgpt3_mat.nativeObj, imageSize.width, imageSize.height, R12.nativeObj, T12.nativeObj, R13.nativeObj, T13.nativeObj, R1.nativeObj, R2.nativeObj, R3.nativeObj, P1.nativeObj, P2.nativeObj, P3.nativeObj, Q.nativeObj, alpha, newImgSize.width, newImgSize.height, roi1_out, roi2_out, flags);
    if(roi1!=null){ roi1.x = (int)roi1_out[0]; roi1.y = (int)roi1_out[1]; roi1.width = (int)roi1_out[2]; roi1.height = (int)roi1_out[3]; } 
    if(roi2!=null){ roi2.x = (int)roi2_out[0]; roi2.y = (int)roi2_out[1]; roi2.width = (int)roi2_out[2]; roi2.height = (int)roi2_out[3]; } 
    return retVal;
}
 
Example #12
Source File: Imgproc.java    From MOAAP with MIT License 5 votes vote down vote up
public static boolean clipLine(Rect imgRect, Point pt1, Point pt2)
{
    double[] pt1_out = new double[2];
    double[] pt2_out = new double[2];
    boolean retVal = clipLine_0(imgRect.x, imgRect.y, imgRect.width, imgRect.height, pt1.x, pt1.y, pt1_out, pt2.x, pt2.y, pt2_out);
    if(pt1!=null){ pt1.x = pt1_out[0]; pt1.y = pt1_out[1]; } 
    if(pt2!=null){ pt2.x = pt2_out[0]; pt2.y = pt2_out[1]; } 
    return retVal;
}
 
Example #13
Source File: Converters.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public static void Mat_to_vector_Rect(Mat m, List<Rect> rs) {
    if (rs == null)
        throw new java.lang.IllegalArgumentException("rs == null");
    int count = m.rows();
    if (CvType.CV_32SC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC4 != m.type() ||  m.rows()!=1\n" + m);

    rs.clear();
    int[] buff = new int[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        rs.add(new Rect(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
    }
}
 
Example #14
Source File: Video.java    From Camdroid with Apache License 2.0 5 votes vote down vote up
public static RotatedRect CamShift(Mat probImage, Rect window, TermCriteria criteria)
{
    double[] window_out = new double[4];
    RotatedRect retVal = new RotatedRect(CamShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon));
    if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } 
    return retVal;
}
 
Example #15
Source File: Video.java    From ml-authentication with Apache License 2.0 5 votes vote down vote up
public static RotatedRect CamShift(Mat probImage, Rect window, TermCriteria criteria)
{
    double[] window_out = new double[4];
    RotatedRect retVal = new RotatedRect(CamShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon));
    if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } 
    return retVal;
}
 
Example #16
Source File: Converters.java    From Android-Car-duino with GNU General Public License v2.0 5 votes vote down vote up
public static void Mat_to_vector_Rect(Mat m, List<Rect> rs) {
    if (rs == null)
        throw new java.lang.IllegalArgumentException("rs == null");
    int count = m.rows();
    if (CvType.CV_32SC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC4 != m.type() ||  m.rows()!=1\n" + m);

    rs.clear();
    int[] buff = new int[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        rs.add(new Rect(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
    }
}
 
Example #17
Source File: Calib3d.java    From FaceDetectDemo with Apache License 2.0 5 votes vote down vote up
public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize, Rect validPixROI, boolean centerPrincipalPoint)
{
    double[] validPixROI_out = new double[4];
    Mat retVal = new Mat(getOptimalNewCameraMatrix_0(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha, newImgSize.width, newImgSize.height, validPixROI_out, centerPrincipalPoint));
    if(validPixROI!=null){ validPixROI.x = (int)validPixROI_out[0]; validPixROI.y = (int)validPixROI_out[1]; validPixROI.width = (int)validPixROI_out[2]; validPixROI.height = (int)validPixROI_out[3]; } 
    return retVal;
}
 
Example #18
Source File: Video.java    From LicensePlateDiscern with MIT License 5 votes vote down vote up
public static int meanShift(Mat probImage, Rect window, TermCriteria criteria)
{
    double[] window_out = new double[4];
    int retVal = meanShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon);
    if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } 
    return retVal;
}
 
Example #19
Source File: Imgproc.java    From FaceDetectDemo with Apache License 2.0 5 votes vote down vote up
public static int floodFill(Mat image, Mat mask, Point seedPoint, Scalar newVal, Rect rect, Scalar loDiff, Scalar upDiff, int flags)
{
    double[] rect_out = new double[4];
    int retVal = floodFill_0(image.nativeObj, mask.nativeObj, seedPoint.x, seedPoint.y, newVal.val[0], newVal.val[1], newVal.val[2], newVal.val[3], rect_out, loDiff.val[0], loDiff.val[1], loDiff.val[2], loDiff.val[3], upDiff.val[0], upDiff.val[1], upDiff.val[2], upDiff.val[3], flags);
    if(rect!=null){ rect.x = (int)rect_out[0]; rect.y = (int)rect_out[1]; rect.width = (int)rect_out[2]; rect.height = (int)rect_out[3]; } 
    return retVal;
}
 
Example #20
Source File: Video.java    From OpenCvFaceDetect with Apache License 2.0 5 votes vote down vote up
public static RotatedRect CamShift(Mat probImage, Rect window, TermCriteria criteria)
{
    double[] window_out = new double[4];
    RotatedRect retVal = new RotatedRect(CamShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon));
    if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } 
    return retVal;
}
 
Example #21
Source File: Calib3d.java    From Form-N-Fun with MIT License 5 votes vote down vote up
public static float rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, List<Mat> imgpt1, List<Mat> imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat R1, Mat R2, Mat R3, Mat P1, Mat P2, Mat P3, Mat Q, double alpha, Size newImgSize, Rect roi1, Rect roi2, int flags)
{
    Mat imgpt1_mat = Converters.vector_Mat_to_Mat(imgpt1);
    Mat imgpt3_mat = Converters.vector_Mat_to_Mat(imgpt3);
    double[] roi1_out = new double[4];
    double[] roi2_out = new double[4];
    float retVal = rectify3Collinear_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, cameraMatrix3.nativeObj, distCoeffs3.nativeObj, imgpt1_mat.nativeObj, imgpt3_mat.nativeObj, imageSize.width, imageSize.height, R12.nativeObj, T12.nativeObj, R13.nativeObj, T13.nativeObj, R1.nativeObj, R2.nativeObj, R3.nativeObj, P1.nativeObj, P2.nativeObj, P3.nativeObj, Q.nativeObj, alpha, newImgSize.width, newImgSize.height, roi1_out, roi2_out, flags);
    if(roi1!=null){ roi1.x = (int)roi1_out[0]; roi1.y = (int)roi1_out[1]; roi1.width = (int)roi1_out[2]; roi1.height = (int)roi1_out[3]; } 
    if(roi2!=null){ roi2.x = (int)roi2_out[0]; roi2.y = (int)roi2_out[1]; roi2.width = (int)roi2_out[2]; roi2.height = (int)roi2_out[3]; } 
    return retVal;
}
 
Example #22
Source File: Video.java    From FtcSamples with MIT License 5 votes vote down vote up
public static int meanShift(Mat probImage, Rect window, TermCriteria criteria)
{
    double[] window_out = new double[4];
    int retVal = meanShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon);
    if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } 
    return retVal;
}
 
Example #23
Source File: Calib3d.java    From opencv-documentscanner-android with Apache License 2.0 5 votes vote down vote up
public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1, Rect validPixROI2)
{
    double[] validPixROI1_out = new double[4];
    double[] validPixROI2_out = new double[4];
    stereoRectify_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha, newImageSize.width, newImageSize.height, validPixROI1_out, validPixROI2_out);
    if(validPixROI1!=null){ validPixROI1.x = (int)validPixROI1_out[0]; validPixROI1.y = (int)validPixROI1_out[1]; validPixROI1.width = (int)validPixROI1_out[2]; validPixROI1.height = (int)validPixROI1_out[3]; } 
    if(validPixROI2!=null){ validPixROI2.x = (int)validPixROI2_out[0]; validPixROI2.y = (int)validPixROI2_out[1]; validPixROI2.width = (int)validPixROI2_out[2]; validPixROI2.height = (int)validPixROI2_out[3]; } 
    return;
}
 
Example #24
Source File: Converters.java    From Chinese-number-gestures-recognition with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void Mat_to_vector_Rect(Mat m, List<Rect> rs) {
    if (rs == null)
        throw new java.lang.IllegalArgumentException("rs == null");
    int count = m.rows();
    if (CvType.CV_32SC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC4 != m.type() ||  m.rows()!=1\n" + m);

    rs.clear();
    int[] buff = new int[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        rs.add(new Rect(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
    }
}
 
Example #25
Source File: Calib3d.java    From PixaToon with GNU General Public License v3.0 5 votes vote down vote up
public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1, Rect validPixROI2)
{
    double[] validPixROI1_out = new double[4];
    double[] validPixROI2_out = new double[4];
    stereoRectify_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha, newImageSize.width, newImageSize.height, validPixROI1_out, validPixROI2_out);
    if(validPixROI1!=null){ validPixROI1.x = (int)validPixROI1_out[0]; validPixROI1.y = (int)validPixROI1_out[1]; validPixROI1.width = (int)validPixROI1_out[2]; validPixROI1.height = (int)validPixROI1_out[3]; } 
    if(validPixROI2!=null){ validPixROI2.x = (int)validPixROI2_out[0]; validPixROI2.y = (int)validPixROI2_out[1]; validPixROI2.width = (int)validPixROI2_out[2]; validPixROI2.height = (int)validPixROI2_out[3]; } 
    return;
}
 
Example #26
Source File: MainActivity.java    From OpenCvFaceDetect with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    super.run();
    while (isStart && isLoadSuccess) {
        synchronized (mLock) {
            try {
                mCameraRawData = mFrameQueue.poll(20, TimeUnit.MILLISECONDS);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            if (mCameraRawData == null) {
                continue;
            }
            frameDatas = mCameraRawData.getRawData();
            mSrcMat.put(0, 0, frameDatas);
            Imgproc.cvtColor(mSrcMat, mDesMat, Imgproc.COLOR_YUV2GRAY_420);
            mFaceCascade.detectMultiScale(mDesMat, matOfRect, 1.1, 5
                    , 2, mMinSize, mMaxSize);
            if (matOfRect.toArray().length != 0) {
                Rect rect = getBiggestFace(matOfRect.toArray());
                mResultView.showFace(rect);
            } else {
                mResultView.clear();
            }
            mFreeQueue.offer(mCameraRawData);
            mCamera.addCallbackBuffer(frameDatas);
        }

    }
}
 
Example #27
Source File: Video.java    From FTCVision with MIT License 5 votes vote down vote up
public static RotatedRect CamShift(Mat probImage, Rect window, TermCriteria criteria)
{
    double[] window_out = new double[4];
    RotatedRect retVal = new RotatedRect(CamShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon));
    if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } 
    return retVal;
}
 
Example #28
Source File: Converters.java    From MOAAP with MIT License 5 votes vote down vote up
public static void Mat_to_vector_Rect(Mat m, List<Rect> rs) {
    if (rs == null)
        throw new java.lang.IllegalArgumentException("rs == null");
    int count = m.rows();
    if (CvType.CV_32SC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_32SC4 != m.type() ||  m.rows()!=1\n" + m);

    rs.clear();
    int[] buff = new int[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        rs.add(new Rect(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
    }
}
 
Example #29
Source File: Video.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public static int meanShift(Mat probImage, Rect window, TermCriteria criteria)
{
    double[] window_out = new double[4];
    int retVal = meanShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon);
    if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } 
    return retVal;
}
 
Example #30
Source File: Video.java    From Document-Scanner with GNU General Public License v3.0 5 votes vote down vote up
public static RotatedRect CamShift(Mat probImage, Rect window, TermCriteria criteria)
{
    double[] window_out = new double[4];
    RotatedRect retVal = new RotatedRect(CamShift_0(probImage.nativeObj, window.x, window.y, window.width, window.height, window_out, criteria.type, criteria.maxCount, criteria.epsilon));
    if(window!=null){ window.x = (int)window_out[0]; window.y = (int)window_out[1]; window.width = (int)window_out[2]; window.height = (int)window_out[3]; } 
    return retVal;
}