当前位置: 首页>>代码示例>>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;未经允许,请勿转载。