Java Code Examples for org.opencv.core.Rect

The following examples show how to use org.opencv.core.Rect. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
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 2
Source Project: classchecks   Source File: DetectEyes.java    License: 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 3
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 4
Source Project: react-native-documentscanner-android   Source File: Video.java    License: 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 5
Source Project: super-cloudops   Source File: ContoursUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 寻找轮廓,并按照递增排序
 *
 * @param cannyMat
 * @return
 */
public static List<MatOfPoint> findContours(Mat cannyMat) {
	List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
	Mat hierarchy = new Mat();

	// 寻找轮廓
	Imgproc.findContours(cannyMat, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE, new Point(0, 0));

	if (contours.size() <= 0) {
		// throw new RuntimeException("未找到图像轮廓");
	} else {
		// 对contours进行了排序,按递增顺序
		contours.sort(new Comparator<MatOfPoint>() {
			@Override
			public int compare(MatOfPoint o1, MatOfPoint o2) {
				MatOfPoint2f mat1 = new MatOfPoint2f(o1.toArray());
				RotatedRect rect1 = Imgproc.minAreaRect(mat1);
				Rect r1 = rect1.boundingRect();

				MatOfPoint2f mat2 = new MatOfPoint2f(o2.toArray());
				RotatedRect rect2 = Imgproc.minAreaRect(mat2);
				Rect r2 = rect2.boundingRect();

				return (int) (r1.area() - r2.area());
			}
		});

	}
	return contours;
}
 
Example 6
Source Project: ml-authentication   Source File: Imgproc.java    License: 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 7
Source Project: sudokufx   Source File: Calib3d.java    License: 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 8
Source Project: MOAAP   Source File: Converters.java    License: 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 9
Source Project: sudokufx   Source File: Video.java    License: 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 10
Source Project: Form-N-Fun   Source File: Imgproc.java    License: 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 11
Source Project: StormCV   Source File: HaarCascadeOp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<CVParticle> execute(CVParticle input) throws Exception {
	ArrayList<CVParticle> result = new ArrayList<CVParticle>();
	Frame frame = (Frame)input;
	if(frame.getImageType().equals(Frame.NO_IMAGE)) return result;

	MatOfByte mob = new MatOfByte(frame.getImageBytes());
	Mat image = Highgui.imdecode(mob, Highgui.CV_LOAD_IMAGE_COLOR);
	
	/*
	mob = new MatOfByte();
	Highgui.imencode(".png", image, mob);
	BufferedImage bi = ImageUtils.bytesToImage(mob.toArray());
	ImageIO.write(bi, "png", new File("testOutput/"+sf.getStreamId()+"_"+sf.getSequenceNr()+".png"));
	*/
	
	MatOfRect haarDetections = new MatOfRect();
	haarDetector.detectMultiScale(image, haarDetections, scaleFactor, minNeighbors, flags, new Size(minSize[0], minSize[1]), new Size(maxSize[0], maxSize[1]));
	ArrayList<Descriptor> descriptors = new ArrayList<Descriptor>();
	for(Rect rect : haarDetections.toArray()){
		Rectangle box = new Rectangle(rect.x, rect.y, rect.width, rect.height);
		descriptors.add(new Descriptor(input.getStreamId(), input.getSequenceNr(), box, 0, new float[0]));
	}
	
	Feature feature = new Feature(input.getStreamId(), input.getSequenceNr(), name, 0, descriptors, null);
	if(outputFrame){
		frame.getFeatures().add(feature);
		result.add(frame);
	}else{
		result.add(feature);
	}
	return result;
}
 
Example 12
Source Project: MOAAP   Source File: Imgproc.java    License: MIT License 5 votes vote down vote up
public static Rect boundingRect(MatOfPoint points)
{
    Mat points_mat = points;
    Rect retVal = new Rect(boundingRect_0(points_mat.nativeObj));
    
    return retVal;
}
 
Example 13
Source Project: LPR   Source File: Imgproc.java    License: Apache License 2.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 14
Source Project: LPR   Source File: Imgproc.java    License: 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 15
Source Project: LPR   Source File: Imgproc.java    License: 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)
{
    double[] rect_out = new double[4];
    int retVal = floodFill_1(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]);
    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 16
public PreProcessor preprocessImage(PreProcessor preProcessor) {
    Mat img = preProcessor.getImages().get(0);
    List<Mat> processed = new ArrayList<Mat>();
    if (preProcessor.getFaces().length == 0){
        return null;
    } else {
        for (Rect rect : preProcessor.getFaces()){
            Mat subImg = img.submat(rect);
            processed.add(subImg);
        }
    }
    preProcessor.setImages(processed);
    return preProcessor;
}
 
Example 17
Source Project: FtcSamples   Source File: Calib3d.java    License: MIT License 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 18
Source Project: Document-Scanner   Source File: Video.java    License: 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;
}
 
Example 19
Source Project: FaceT   Source File: Video.java    License: 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 20
Source Project: MOAAP   Source File: Converters.java    License: 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 21
Source Project: FTCVision   Source File: Video.java    License: 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 22
Source Project: OpenCvFaceDetect   Source File: MainActivity.java    License: 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 23
Source Project: ml-authentication   Source File: Video.java    License: 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 24
Source Project: PixaToon   Source File: Calib3d.java    License: 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 25
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 26
Source Project: opencv-documentscanner-android   Source File: Calib3d.java    License: 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 27
Source Project: FtcSamples   Source File: Video.java    License: 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 28
Source Project: Form-N-Fun   Source File: Calib3d.java    License: 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 29
Source Project: OpenCvFaceDetect   Source File: Video.java    License: 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 30
Source Project: Image-Detection-Samples   Source File: Calib3d.java    License: 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;
}