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


Java Imgproc.line方法代碼示例

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


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

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

        Mat grayMat = new Mat();
        Mat cannyEdges = new Mat();
        Mat lines = new Mat();

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

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

        Imgproc.HoughLinesP(cannyEdges, lines, 1, Math.PI / 180, 50, 20, 20);

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

        //Drawing lines on the image
        for (int i = 0; i < lines.cols(); i++) {
            double[] points = lines.get(0, i);
            double x1, y1, x2, y2;

            x1 = points[0];
            y1 = points[1];
            x2 = points[2];
            y2 = points[3];

            Point pt1 = new Point(x1, y1);
            Point pt2 = new Point(x2, y2);

            //Drawing lines on an image
            Imgproc.line(houghLines, pt1, pt2, new Scalar(255, 0, 0), 1);
        }

        //Converting Mat back to Bitmap
        Utils.matToBitmap(houghLines, currentBitmap);
        imageView.setImageBitmap(currentBitmap);

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

示例3: drawContourByPoints

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static void drawContourByPoints(Mat im, List<List<Point>> contours, Scalar color) {
    for (List<Point> contour : contours) {
        int len = contour.size();
        for (int i = 0; i < len; ++i) {
            int next_i = (i + 1) % len;
            Imgproc.line(im, contour.get(i), contour.get(next_i), color, 2);
        }
    }
}
 
開發者ID:hgs1217,項目名稱:Paper-Melody,代碼行數:10,代碼來源:Util.java

示例4: fillContour

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static void fillContour(Mat im, List<Point> contour, Point seed) {
    Mat mask = Mat.zeros(new Size(im.width() + 2, im.height() + 2), CvType.CV_8UC1);

    int len = contour.size();
    for (int i = 0; i < len; ++i) {
        int next_i = (i + 1) % len;
        Imgproc.line(im, contour.get(i), contour.get(next_i), Util.SCALAR_WHITE, 2);
    }
    Imgproc.floodFill(im, mask, seed, Util.SCALAR_WHITE);
}
 
開發者ID:hgs1217,項目名稱:Paper-Melody,代碼行數:11,代碼來源:Util.java

示例5: 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

示例6: drawLine

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

示例7: line_P2P

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static void line_P2P(Mat inputmat, Point startP, Point endP) {
	Imgproc.line(inputmat, startP, endP, new Scalar(128, 200, 255), 8);
}
 
開發者ID:zylo117,項目名稱:SpotSpotter,代碼行數:4,代碼來源:Draw.java


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