當前位置: 首頁>>代碼示例>>Java>>正文


Java Imgproc.circle方法代碼示例

本文整理匯總了Java中org.opencv.imgproc.Imgproc.circle方法的典型用法代碼示例。如果您正苦於以下問題:Java Imgproc.circle方法的具體用法?Java Imgproc.circle怎麽用?Java Imgproc.circle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.opencv.imgproc.Imgproc的用法示例。


在下文中一共展示了Imgproc.circle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCameraFrame

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
        final int viewMode = mViewMode;
        switch (viewMode) {
            case VIEW_MODE_OPTICAL_FLOW:
                mGray = inputFrame.gray();
                if(features.toArray().length==0){
                    int rowStep = 50, colStep = 100;
                    int nRows = mGray.rows()/rowStep, nCols = mGray.cols()/colStep;

//                    Log.d(TAG, "\nRows: "+nRows+"\nCols: "+nCols+"\n");

                    Point points[] = new Point[nRows*nCols];
                    for(int i=0; i<nRows; i++){
                        for(int j=0; j<nCols; j++){
                            points[i*nCols+j]=new Point(j*colStep, i*rowStep);
//                            Log.d(TAG, "\nRow: "+i*rowStep+"\nCol: "+j*colStep+"\n: ");
                        }
                    }

                    features.fromArray(points);

                    prevFeatures.fromList(features.toList());
                    mPrevGray = mGray.clone();
                    break;
                }

                nextFeatures.fromArray(prevFeatures.toArray());
                Video.calcOpticalFlowPyrLK(mPrevGray, mGray, prevFeatures, nextFeatures, status, err);

                List<Point> prevList=features.toList(), nextList=nextFeatures.toList();
                Scalar color = new Scalar(255);

                for(int i = 0; i<prevList.size(); i++){
//                    Core.circle(mGray, prevList.get(i), 5, color);
                    Imgproc.line(mGray, prevList.get(i), nextList.get(i), color);
                }

                mPrevGray = mGray.clone();
                break;
            case VIEW_MODE_KLT_TRACKER:
                mGray = inputFrame.gray();

                if(features.toArray().length==0){
                    Imgproc.goodFeaturesToTrack(mGray, features, 10, 0.01, 10);
                    Log.d(TAG, features.toList().size()+"");
                    prevFeatures.fromList(features.toList());
                    mPrevGray = mGray.clone();
//                    prevFeatures.fromList(nextFeatures.toList());
                    break;
                }

//                OpticalFlow(mPrevGray.getNativeObjAddr(), mGray.getNativeObjAddr(), prevFeatures.getNativeObjAddr(), nextFeatures.getNativeObjAddr());
                Video.calcOpticalFlowPyrLK(mPrevGray, mGray, prevFeatures, nextFeatures, status, err);
                List<Point> drawFeature = nextFeatures.toList();
//                Log.d(TAG, drawFeature.size()+"");
                for(int i = 0; i<drawFeature.size(); i++){
                    Point p = drawFeature.get(i);
                    Imgproc.circle(mGray, p, 5, new Scalar(255));
                }
                mPrevGray = mGray.clone();
                prevFeatures.fromList(nextFeatures.toList());
                break;
            default: mViewMode = VIEW_MODE_KLT_TRACKER;
        }

        return mGray;
    }
 
開發者ID:johnhany,項目名稱:MOAAP,代碼行數:68,代碼來源:MainActivity.java

示例2: displayResults

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public Mat displayResults(Mat frame) {
	//draw boxes and centroids
    if (tracks != null) {	
		for (int i=0; i<tracks.length; i++) {
    		if (tracks[i].totalVisibleCount > 20) {
    			Imgproc.rectangle(frame, new Point(tracks[i].bbox.x, tracks[i].bbox.y), 
    					new Point(tracks[i].bbox.x + tracks[i].bbox.width, tracks[i].bbox.y + tracks[i].bbox.height), new Scalar(255, 0, 0));
    			Imgproc.putText(frame, Integer.toString(tracks[i].id), 
    					new Point(tracks[i].bbox.x, tracks[i].bbox.y), 
    					Core.FONT_HERSHEY_PLAIN, 1.0, new Scalar(255,0,0));
    			Imgproc.circle(frame, new Point(tracks[i].kalmanPredict()[0], tracks[i].kalmanPredict()[1]), 4, new Scalar(255,100,100));
    		}
    	}
    }
    
    return frame;
}
 
開發者ID:TheoreticallyNick,項目名稱:Face-Detection-and-Tracking,代碼行數:18,代碼來源:FaceTrackMain.java

示例3: pointMapList

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static void pointMapList(Mat input, List<Map<Point, Double>> list, int radiusRatio, int thickness,
			int mosaicLength) {
		for (int i = 0; i < list.size(); i++) {
			Map dataMap = new HashMap<>();
			dataMap = list.get(i);

			final Set<Map.Entry<Point, Double>> entryseSet = dataMap.entrySet();
			for (final Map.Entry<Point, Double> entry : entryseSet) {
				final Point p = entry.getKey();
				double v = entry.getValue();
				if (Double.isInfinite(entry.getValue())) {
					v = 1;
				}
				final int radius = (new Double(radiusRatio * v)).intValue();
				Imgproc.circle(input, new Point(p.x * mosaicLength, p.y * mosaicLength), radius,
						new Scalar(255, 0, 255), thickness);
			}
		}
//		System.out.println("Done Drawing");
	}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:21,代碼來源:Draw.java

示例4: trackLaser

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
private void trackLaser()
{

    Imgproc.cvtColor(frame,hsv , Imgproc.COLOR_BGR2HSV);
    //shiny RED Color
    Scalar lowerScale = new Scalar(0, 0, 255);
    Scalar upperScale = new Scalar(255, 255, 255);

    Core.inRange(hsv, lowerScale, upperScale, mask);
    matOfPoints.clear();
    Imgproc.findContours(mask, matOfPoints, heir , Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
    if (matOfPoints.size() > 0) {

        float[] radius = new float[1];

        Point[] matOfPoint = matOfPoints.get(maxPoint(matOfPoints)).toArray();
        Imgproc.minEnclosingCircle(new MatOfPoint2f(matOfPoint), laserCenter,radius);
        //Trigger Listener up here
        Imgproc.circle(frame, laserCenter, 7, new Scalar(255, 0, 0), 2);
        Imgproc.circle(mask, laserCenter, 7, new Scalar(255, 0, 0), 2);
        triggerLaserDetectionFrame(laserCenter);

    }
    triggerProcessingListeners(onFrameProcessedListeners, frame);
    triggerProcessingListeners(onMaskProcessedListeners, mask);

}
 
開發者ID:kareem2048,項目名稱:Asteroids-Laser-Controller,代碼行數:28,代碼來源:LaserDetector.java

示例5: drawFaceShapes

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static void drawFaceShapes(Rect face, Mat matrixRGBA) {
    Point start = face.tl();
    int h = (int) start.y + (face.height / 2);
    int w = (int) start.x + (face.width / 2);
    Imgproc.rectangle(matrixRGBA, start, face.br(),
            FACE_RECT_COLOR, 3);
    Point center = new Point(w, h);
    Imgproc.circle(matrixRGBA, center, 10, new Scalar(255, 0, 0, 255), 3);
}
 
開發者ID:raulh82vlc,項目名稱:Image-Detection-Samples,代碼行數:10,代碼來源:FaceDrawerOpenCV.java

示例6: Circle

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static Mat Circle(Mat circularInput, Point cc, int radius) {
	final Mat maskCopyTo = Mat.zeros(circularInput.size(), CvType.CV_8UC1); // ����copyTo������mask����С��ԭͼ����һ��
	// floodFill��mask��width��height�����������ͼ��������������أ��������ᱨ��
	final Mat maskFloodFill = Mat.zeros(new Size(circularInput.cols() + 2, circularInput.rows() + 2),
			CvType.CV_8UC1); // ����floodFill������mask���ߴ��ԭͼ��һЩ
	Imgproc.circle(maskCopyTo, new Point(cc.x, cc.y), radius, Scalar.all(255), 2, 8, 0); // ����Բ������
	Imgproc.floodFill(maskCopyTo, maskFloodFill, new Point(207, 290), Scalar.all(255), null, Scalar.all(20),
			Scalar.all(20), 4); // ��ˮ��䷨���Բ���ڲ�
	// MatView.imshow(maskFloodFill, "Mask of floodFill"); // ����floodFill������mask
	// MatView.imshow(maskCopyTo, "Mask of copyTo"); // ����copyTo������mask
	final Mat imgCircularROI = new Mat();
	circularInput.copyTo(imgCircularROI, maskCopyTo); // ��ȡԲ�ε�ROI
	// MatView.imshow(imgCircularROI, "Circular ROI"); // ��ʾԲ�ε�ROI
	return imgCircularROI;
}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:16,代碼來源:ROI_Irregular.java

示例7: pointList

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static void pointList(Mat input, List<Point> list, int radius, int size) {
	for (int i = 0; i < list.size(); i++) {
		final Point p = list.get(i);
		Imgproc.circle(input, p, radius, new Scalar(255, 0, 255), size);
	}
	System.out.println("Done Drawing");
}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:8,代碼來源:Draw.java

示例8: onCameraFrame

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    Mat input = inputFrame.gray();
    Mat circles = new Mat();
    Imgproc.blur(input, input, new Size(7, 7), new Point(2, 2));
    Imgproc.HoughCircles(input, circles, Imgproc.CV_HOUGH_GRADIENT, 2, 100, 100, 90, 0, 1000);

    Log.i(TAG, String.valueOf("size: " + circles.cols()) + ", " + String.valueOf(circles.rows()));

    if (circles.cols() > 0) {
        for (int x=0; x < Math.min(circles.cols(), 5); x++ ) {
            double circleVec[] = circles.get(0, x);

            if (circleVec == null) {
                break;
            }

            Point center = new Point((int) circleVec[0], (int) circleVec[1]);
            int radius = (int) circleVec[2];

            Imgproc.circle(input, center, 3, new Scalar(255, 255, 255), 5);
            Imgproc.circle(input, center, radius, new Scalar(255, 255, 255), 2);
        }
    }

    circles.release();
    input.release();
    return inputFrame.rgba();
}
 
開發者ID:ahmetozlu,項目名稱:real_time_circle_detection_android,代碼行數:30,代碼來源:MainActivity.java

示例9: drawPostProcessing

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
/**
 * Draws an array of analysis objects unto a mat.
 * 
 * @param feed mat to draw on
 * @param color color to draw with
 * @param an array of analysis to draw
 * @see Imgproc#circle(Mat, Point, int, Scalar)
 */
public static void drawPostProcessing(Mat feed, Scalar color, Analysis... an){
	for (int i = 0; i < an.length; i++) {
		Analysis analysis = an[i];
		Imgproc.circle(feed, 
				new Point(analysis.getDouble(Analysis.PROP_CENTER_X), analysis.getDouble(Analysis.PROP_CENTER_Y)), 
				3, color, 2);
	}
	Imgproc.line(feed, new Point(feed.width()/2, 0), new Point(feed.width()/2, feed.height()), new Scalar(0, 51, 255));
}
 
開發者ID:Flash3388,項目名稱:FlashLib,代碼行數:18,代碼來源:CvProcessing.java

示例10: HoughCircles

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
void HoughCircles() {
    Mat grayMat = new Mat();
    Mat cannyEdges = new Mat();
    Mat circles = new Mat();

    //Converting the image to grayscale
    Imgproc.cvtColor(originalMat, grayMat, Imgproc.COLOR_BGR2GRAY);

    Imgproc.Canny(grayMat, cannyEdges, 10, 100);

    Imgproc.HoughCircles(cannyEdges, circles, Imgproc.CV_HOUGH_GRADIENT, 1, cannyEdges.rows() / 15);//, grayMat.rows() / 8);

    Mat houghCircles = new Mat();
    houghCircles.create(cannyEdges.rows(), cannyEdges.cols(), CvType.CV_8UC1);

    //Drawing lines on the image
    for (int i = 0; i < circles.cols(); i++) {
        double[] parameters = circles.get(0, i);
        double x, y;
        int r;

        x = parameters[0];
        y = parameters[1];
        r = (int) parameters[2];

        Point center = new Point(x, y);

        //Drawing circles on an image
        Imgproc.circle(houghCircles, center, r, new Scalar(255, 0, 0), 1);
    }

    //Converting Mat back to Bitmap
    Utils.matToBitmap(houghCircles, currentBitmap);
    imageView.setImageBitmap(currentBitmap);
}
 
開發者ID:johnhany,項目名稱:MOAAP,代碼行數:36,代碼來源:MainActivity.java

示例11: HarrisCorner

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
void HarrisCorner() {
    Mat grayMat = new Mat();
    Mat corners = new Mat();

    //Converting the image to grayscale
    Imgproc.cvtColor(originalMat, grayMat, Imgproc.COLOR_BGR2GRAY);

    Mat tempDst = new Mat();
    //finding contours
    Imgproc.cornerHarris(grayMat, tempDst, 2, 3, 0.04);

    //Normalizing harris corner's output
    Mat tempDstNorm = new Mat();
    Core.normalize(tempDst, tempDstNorm, 0, 255, Core.NORM_MINMAX);
    Core.convertScaleAbs(tempDstNorm, corners);

    //Drawing corners on a new image
    Random r = new Random();
    for (int i = 0; i < tempDstNorm.cols(); i++) {
        for (int j = 0; j < tempDstNorm.rows(); j++) {
            double[] value = tempDstNorm.get(j, i);
            if (value[0] > 150)
                Imgproc.circle(corners, new Point(i, j), 5, new Scalar(r.nextInt(255)), 2);
        }
    }

    //Converting Mat back to Bitmap
    Utils.matToBitmap(corners, currentBitmap);
    imageView.setImageBitmap(currentBitmap);
}
 
開發者ID:johnhany,項目名稱:MOAAP,代碼行數:31,代碼來源:MainActivity.java

示例12: drawCircle

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
private static void drawCircle(Mat img, Point center, int diameter, Color color, int thickness) {
    Imgproc.circle(img, center, diameter, color.getScalarRGBA(), thickness);
}
 
開發者ID:ykarim,項目名稱:FTC2016,代碼行數:4,代碼來源:Drawing.java

示例13: drawIrisCircle

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static void drawIrisCircle(Mat matrixRgba, Core.MinMaxLocResult minMaxLocResult) {
    Imgproc.circle(matrixRgba, minMaxLocResult.minLoc, 2, new Scalar(255, 255, 255, 255), 2);
}
 
開發者ID:raulh82vlc,項目名稱:Image-Detection-Samples,代碼行數:4,代碼來源:FaceDrawerOpenCV.java

示例14: point

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static void point(Mat input, Point p, int radius, int size) {
	Imgproc.circle(input, p, radius, new Scalar(255, 0, 255), size);
}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:4,代碼來源:Draw.java

示例15: drawPoints

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static void drawPoints(Mat im, List<Point> points, Scalar color) {
    for (Point point : points) {
        Imgproc.circle(im, point, 0, color, 3);  // radius=0, thickness=3
    }
}
 
開發者ID:hgs1217,項目名稱:Paper-Melody,代碼行數:6,代碼來源:Util.java


注:本文中的org.opencv.imgproc.Imgproc.circle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。