detect() org.opencv.features2d.Feature2D 메소드 (추상) 클래스는 주어진 이미지의 핵심 포인트를 감지합니다. 이 방법을 사용하려면 Mat 소스 이미지와 빈 MatOfKeyPoint를 나타내는 개체 읽기 키 포인트를 유지하는 개체입니다.
drawKeypoints()를 사용하여 이미지에 키 포인트를 그릴 수 있습니다. org.opencv.features2d.Features2d 메소드 수업.
참고
-
Feature2D는 추상 클래스이므로 하위 클래스 중 하나를 인스턴스화하여 detect() 메서드를 호출해야 합니다. 여기서는 FastFeatureDetector 클래스를 사용했습니다.
-
Features2D 및 Features2d 패키지의 두 가지 다른 클래스는 features2d 혼동하지 마세요...
예시
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.core.Scalar;
import org.opencv.features2d.FastFeatureDetector;
import org.opencv.features2d.Features2d;
import org.opencv.highgui.HighGui;z
import org.opencv.imgcodecs.Imgcodecs;
public class DetectingKeyPoints{
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\\javafx_graphical.jpg";
Mat src = Imgcodecs.imread(file);
//Reading the key points of the image
Mat dst = new Mat();
MatOfKeyPoint matOfKeyPoints = new MatOfKeyPoint();
FastFeatureDetector featureDetector = FastFeatureDetector.create();
featureDetector.detect(src, matOfKeyPoints);
//Drawing the detected key points
Features2d.drawKeypoints(src, matOfKeyPoints, dst, new Scalar(0, 0, 255));
HighGui.imshow("Feature Detection", dst);
HighGui.waitKey();
}
} 입력 이미지

출력
