Home > Java > javaTutorial > body text

How to draw a filled circle in OpenCV using Java?

王林
Release: 2023-09-18 20:17:01
forward
964 people have browsed it

The org.opencv.imgproc package of the Java OpenCV library contains a class called Imgproc. This class provides a method named circle(), which can be used to draw a Draw circles on the image. This method provides the following parameters:

  • Mat object representing the image of the circle to be drawn.

  • Represents the Point object at the center of the circle.

  • An integer variable representing the radius of the circle.

  • A Scalar object representing the circle color (BGR).

  • An integer representing the thickness of the circle (default is 1).

If the line type parameter is set to Imgproc.FILLED, this method will generate/draw a filled circle.

Example

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class DrawingFilledCircle {
   public static void main(String args[]) {
      //Loading the OpenCV core library
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      //Loading the OpenCV core library
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      //Reading the source image in to a Mat object
      Mat src = Imgcodecs.imread("D:\images\blank.jpg");
      //Drawing a Circle
      Point center = new Point(300, 200);
      int radius =100;
      Scalar color = new Scalar(64, 64, 64);
      int thickness = Imgproc.FILLED;
      Imgproc.circle (src, center, radius, color, thickness);
      //Saving and displaying the image
      Imgcodecs.imwrite("arrowed_line.jpg", src);
      HighGui.imshow("Drawing a circle", src);
      HighGui.waitKey();
   }
}
Copy after login

Output

When executing the above program, it will be generated The following window −

How to draw a filled circle in OpenCV using Java?

The above is the detailed content of How to draw a filled circle in OpenCV using Java?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!