Cool
Cool
Published on 2022-03-16 / 25 Visits
0
0

opencv 基础用法

   //画圆
       // Imgproc.circle(mat, new Point(mat.cols() / 2, mat.rows() / 2), mat.cols() / 2 - 10, new Scalar(0, 0, 2),10);
        //画线
//        Imgproc.line(mat, new Point(0,mat.cols()/2),new Point(mat.cols(),mat.cols()/2) , new Scalar(0, 0, 2),10);
        //画矩形 pont1 和 pont2 为左上定点 和 右下定点的值
      /*  Imgproc.rectangle(
                mat,
                new Point(mat.rows()/4,mat.cols()/4),
                new Point(mat.cols(),0),
                new Scalar(0, 0, 256),
                10
        );*/
        //画椭圆
     /*   Imgproc.ellipse(
                mat,
                //RotatedRect 中的 Point 实际为中心点 而不是定点
                new RotatedRect(new Point(mat.cols()/2,mat.rows()/2),new Size(mat.rows()/2,mat.cols()/4),180),
                new Scalar(0, 0, 256),
                10
        );
*/
//        画折线
        /*Imgproc.polylines(
                mat,
                new ArrayList<MatOfPoint>() {{
                    add(new MatOfPoint(
                            new Point(75, 100), new Point(350, 100),
                            new Point(800, 150), new Point(350, 150),
                            new Point(75, 200), new Point(350, 200),
                            new Point(75, 250), new Point(350, 250)));
                }},
                false, //最后一个点是否连回来
                new Scalar(0, 0, 256),
                10);*/
        //添加文字
        /*Imgproc.putText(
                mat,
                "Im,111",
                new Point(mat.cols()/2,mat.rows()/2 ),
                1,1.00, new Scalar(0, 0, 256),
                1
        );*/


Comment