Lớp Imgproc cung cấp phương thức circle() để vẽ hình tròn. Truyền Imgproc.FILLED cho tham số thickness để vẽ tròn tô đặc.
Tham số:
Mat– hình ảnh đích.Point– tâm đường tròn.- Integer
radius– bán kính. Scalar– màu (BGR).- Integer
thickness– độ dày, dùngImgproc.FILLEDđể tô đặc.
Ví dụ
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[]) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat src = Imgcodecs.imread("D:\\images\\blank.jpg");
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);
Imgcodecs.imwrite("arrowed_line.jpg", src);
HighGui.imshow("Drawing a circle", src);
HighGui.waitKey();
}
}
Kết quả
Hiển thị hình tròn tô đặc:
