org.opencv.features2d.Feature2D (एब्स्ट्रैक्ट) क्लास का detect() मेथड दी गई इमेज के की-पॉइंट्स का पता लगाता है। इस मेथड को आपको स्रोत इमेज का प्रतिनिधित्व करने वाला एक Mat ऑब्जेक्ट और पढ़े गए की-पॉइंट्स को रखने के लिए एक खाली MatOfKeyPoint ऑब्जेक्ट पास करना होगा।
आप org.opencv.features2d.Features2d क्लास के drawKeypoints() मेथड का उपयोग करके इमेज पर की-पॉइंट्स ड्रा कर सकते हैं।
नोट
चूंकि 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;
import org.opencv.imgcodecs.Imgcodecs;
public class DetectingKeyPoints {
public static void main(String args[]) throws Exception {
// OpenCV कोर लाइब्रेरी लोड करना
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
// इमेज की सामग्री पढ़ना
String file = "D:\\Images\\javafx_graphical.jpg";
Mat src = Imgcodecs.imread(file);
// इमेज के की-पॉइंट्स पढ़ना
Mat dst = new Mat();
MatOfKeyPoint matOfKeyPoints = new MatOfKeyPoint();
FastFeatureDetector featureDetector = FastFeatureDetector.create();
featureDetector.detect(src, matOfKeyPoints);
// डिटेक्टेड की-पॉइंट्स ड्रा करना
Features2d.drawKeypoints(src, matOfKeyPoints, dst, new Scalar(0, 0, 255));
HighGui.imshow("फीचर डिटेक्शन", dst);
HighGui.waitKey();
}
}
इनपुट इमेज

आउटपुट
