Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
openCV:创建功能匹配、输出数组的含义、java_Java_Opencv_Image Processing - Fatal编程技术网

openCV:创建功能匹配、输出数组的含义、java

openCV:创建功能匹配、输出数组的含义、java,java,opencv,image-processing,Java,Opencv,Image Processing,以下代码(使用openCV-图像处理库,用Java编写)生成类MatOfDMatch的输出。问题是我不明白数组中的值告诉了我关于匹配的信息: FeatureDetector fastFeatureDetector = FeatureDetector .create(FeatureDetector.FAST); DescriptorExtractor surfDescriptorExtractor = DescriptorExtractor .create(DescriptorEx

以下代码(使用openCV-图像处理库,用Java编写)生成类MatOfDMatch的输出。问题是我不明白数组中的值告诉了我关于匹配的信息:

FeatureDetector fastFeatureDetector = FeatureDetector
    .create(FeatureDetector.FAST);
DescriptorExtractor surfDescriptorExtractor = DescriptorExtractor
    .create(DescriptorExtractor.SURF); 
DescriptorMatcher flannDescriptorMatcher = DescriptorMatcher
    .create(DescriptorMatcher.FLANNBASED);

Mat image1 = Highgui.imread(myPicPath);
Mat image2 = Highgui.imread(myPicPath2);

ArrayList<MatOfKeyPoint> keypoints1 = new ArrayList<MatOfKeyPoint>();
    keypoints1.add(new MatOfKeyPoint());
ArrayList<MatOfKeyPoint> keypoints2 = new ArrayList<MatOfKeyPoint>();
    keypoints2.add(new MatOfKeyPoint());

fastFeatureDetector.detect(image1, keypoints1.get(0));
fastFeatureDetector.detect(image2, keypoints2.get(0));

Mat descriptor1 = new Mat();
Mat descriptor2 = new Mat();

surfDescriptorExtractor.compute(image1, keypoints1.get(0),
    descriptor1);
surfDescriptorExtractor.compute(image2, keypoints2.get(0),
    descriptor2);

ArrayList<MatOfDMatch> matches = new ArrayList<MatOfDMatch>();
matches.add(new MatOfDMatch());

flannDescriptorMatcher.match(descriptor1,
    descriptor2, matches.get(0));

Mat outImg = new Mat();
Features2d.drawMatches(image1, keypoints1.get(0), image2,
        keypoints2.get(0), matches.get(0), outImg,
        new Scalar(0, 255, 0), new Scalar(0, 0, 255), new MatOfByte(),
        Features2d.NOT_DRAW_SINGLE_POINTS);

Highgui.imwrite(myOutpuPicPath,
            outImg);

//The following code part is not part of the Matching process (which is above part), 
//I include it here because it prints the MatOfDMatchvalues in a readable fashion
ArrayList<Double> matchChannel_0 = new ArrayList<Double>();
ArrayList<Double> matchChannel_1 = new ArrayList<Double>();
ArrayList<Double> matchChannel_2 = new ArrayList<Double>();
ArrayList<Double> matchChannel_3 = new ArrayList<Double>();

for (int j = 0; j < matches.get(0).size().height; j++) {
matchChannel_0.add(matches.get(0).get(j, 0)[0]);
matchChannel_1.add(matches.get(0).get(j, 0)[1]);
    matchChannel_2.add(matches.get(0).get(j, 0)[2]);
matchChannel_3.add(matches.get(0).get(j, 0)[3]);
}

System.out.println(matchChannel_0 + "\n" + matchChannel_1 + "\n"
    + matchChannel_2 + "\n" + matchChannel_3);
FeatureDetector fastFeatureDetector=FeatureDetector
.创建(FeatureDetector.FAST);
描述符牵引器冲浪描述符牵引器=描述符牵引器
.创建(描述符rextractor.SURF);
DescriptorMatcher法兰描述器匹配器=DescriptorMatcher
.create(DescriptorMatcher.flannbase);
Mat image1=Highgui.imread(myPicPath);
Mat image2=Highgui.imread(myPicPath2);
ArrayList keypoints1=新的ArrayList();
添加(新的MatOfKeyPoint());
ArrayList keypoints2=新的ArrayList();
添加(新的MatOfKeyPoint());
fastFeatureDetector.detect(图像1,关键点1.get(0));
fastFeatureDetector.detect(图像2,关键点2.get(0));
材料描述符1=新材料();
材料描述符2=新材料();
surfDescriptorExtractor.compute(图像1,关键点1.get(0)),
描述符1);
surfDescriptorExtractor.compute(图像2,关键点2.get(0)),
描述符2);
ArrayList matches=新的ArrayList();
matches.add(new MatOfDMatch());
法兰描述器匹配(描述符1,
描述符2,matches.get(0));
Mat outImg=新Mat();
特征2D.绘图匹配(图像1,关键点1.获取(0),图像2,
keypoints2.get(0),matches.get(0),outImg,
新标量(0,255,0),新标量(0,0,255),新MatOfByte(),
特征2d.非绘制(单点);
Highgui.imwrite(myOutpuPicPath,
outImg);
//下面的代码部分不是匹配过程的一部分(在上面的部分),
//我把它包括在这里是因为它以可读的方式打印匹配值
ArrayList matchChannel_0=新的ArrayList();
ArrayList matchChannel_1=新的ArrayList();
ArrayList matchChannel_2=新的ArrayList();
ArrayList matchChannel_3=新的ArrayList();
for(int j=0;j

image1image2设置到相同的pic,使
matchChannel\u 1
中的所有值变为
matchChannel\u 0
,而
matchChannel\u 3
中的所有值变为0

image1image2设置为不同的图片,值会变得不同


这些值意味着什么?他们肯定必须告诉关于比赛的一些事情,但我不知道具体是什么以及如何告诉他们。我需要一个答案,比如“该通道中的值越大意味着这个,而另一个通道中的值越大”。有人能澄清一下吗,因为openCV教程没有解释这一点。

请在否决之前解释一下这篇文章的错误。我想你的问题很模糊(我没有否决)。我建议您研究
MatOfDMatch
的源代码和/或应用更多的测试(不同的图片、相同的图片、相似的图片、不太相似的图片)来含蓄地理解代码。@kiltek我对MatOfDMatch也很困惑。我在谷歌上搜索了很多,但没有找到任何东西来描述我们如何使用它来分析训练和查询图像之间的匹配。如果您有任何更新,请分享。