Table of Contents
Example
Input picture
Output
Home Java javaTutorial How to draw markers on an image using Java OpenCV library?

How to draw markers on an image using Java OpenCV library?

Sep 07, 2023 pm 05:29 PM

You can draw markers on the image using the drawMarker() method of the org.opencv.imgproc.Imgproc class. This method accepts the following parameters:

  • img − Mat object representing the input image.

  • #position − An object of Point class used to specify the position of the mark.

  • color − An object of Scalar class used to specify the color of the marker.

  • markerType − An integer constant that specifies the type of marker.

  • #size − An integer value specifying the size of the marker.

  • thickness − An integer value that specifies the thickness of the mark.

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 DrawingMarkers {
   public static void main(String args[]) throws Exception {
      //Loading the OpenCV core library
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      //Reading the contents of the image
      String file ="D:\Images\elephant.jpg";
      Mat src = Imgcodecs.imread(file);
      //Preparing color and position of the marker
      Scalar color = new Scalar(0, 0, 125);
      Point point = new Point(150, 260);
      //Drawing marker
      Imgproc.drawMarker(src, point, color, Imgproc.MARKER_SQUARE, 150, 8, Imgproc.LINE_8);
      HighGui.imshow("Drawing Markers", src);
      HighGui.waitKey();
   }
}
Copy after login

Input picture

如何使用Java OpenCV库在图像上绘制标记?

Output

The following window is generated when executing the above program-

How to draw markers on an image using Java OpenCV library?

The above is the detailed content of How to draw markers on an image using Java OpenCV library?. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)