[英]How to draw detected keypoints on an image in java/javacv?
Can anyone tell me that how can i detect keypoints of an image and draw that keypoints on that image in java? 谁能告诉我如何在Java中检测图像的关键点并在该图像上绘制这些关键点? I tried smt but i couldn't figure out how to draw them?
我尝试过smt,但我不知道如何绘制它们? Any ideas for how should i proceed or any ideas for drawing for my code?
关于如何进行代码的任何想法或为代码绘制代码的任何想法?
final IplImage image1 = cvLoadImage(
"C:/Users/Can/Desktop/panorama_image1.jpg",
CV_LOAD_IMAGE_GRAYSCALE);
final CanvasFrame canvas1 = new CanvasFrame("Image1");
canvas1.showImage(image1);
canvas1.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
SIFT sift = new SIFT();
KeyPoint keypoint1 = new KeyPoint();
sift.detect(image1, null, keypoint1);
System.out.println("Keypoints for image1: " + keypoint1.capacity());
If you or others still need an answer, I believe the possible way of doing that is 如果您或其他人仍需要答案,我相信这样做的可能方法是
opencv_features2d.drawKeypoints(_image1, keypoint1, Mat.EMPTY);
Then you may save your _image1
to file using 然后,您可以使用以下命令将
_image1
保存到文件中
ImageIO.write(_image1.getBufferedImage(), "png", new File("image1.png"));
But before that you'll have to open your image1
as a Mat object: Mat _image1 = new Mat(image1);
但是在此之前,您必须将
image1
作为Mat对象打开: Mat _image1 = new Mat(image1);
Assuming you or anyone else still requires this, you can do the following. 假设您或其他任何人仍然需要这样做,则可以执行以下操作。
Using Java, after you have computed your keypoints you can do the following using the Features2d
class in OpenCV. 使用Java,您已经计算的关键点后,你可以做以下使用
Features2d
OpenCV中类。
// draw keypoints on image
Mat outputImage = new Mat();
// Your image, keypoints, and output image
Features2d.drawKeypoints(image, keypoints, outputImage);
String filename = "keypoints.jpg";
System.out.println(String.format("Writing %s...", filename));
Highgui.imwrite(filename, outputImage);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.