Opencv java匹配查找器
我想知道如何找到比赛距离,但过了一段时间,我的比赛没有比赛。我用Haar检测器检测人脸,接下来我要做的是将一个新的检测与模板图像匹配,如果距离足够小,它会附加新的检测图像。问题是,经过几次迭代后,匹配列表为空Opencv java匹配查找器,java,opencv,matching,orb,Java,Opencv,Matching,Orb,我想知道如何找到比赛距离,但过了一段时间,我的比赛没有比赛。我用Haar检测器检测人脸,接下来我要做的是将一个新的检测与模板图像匹配,如果距离足够小,它会附加新的检测图像。问题是,经过几次迭代后,匹配列表为空 @Override public void match(List<Template> listOfTemplates, List<Template> listOfDetections) { FeatureDetector Fdetector = Featur
@Override
public void match(List<Template> listOfTemplates, List<Template> listOfDetections) {
FeatureDetector Fdetector = FeatureDetector.create(FeatureDetector.ORB);
DescriptorExtractor Fdescriptor = DescriptorExtractor.create(DescriptorExtractor.ORB);
DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
for (Template template : listOfTemplates) {
MatOfKeyPoint templateKeyPoints=new MatOfKeyPoint();
Mat templateDescriptors=new Mat();
Fdetector.detect(template.image, templateKeyPoints);
Fdescriptor.compute(template.image, templateKeyPoints, templateDescriptors);
for (Template detection : listOfDetections) {
MatOfKeyPoint detectionKeyPoints=new MatOfKeyPoint();
Mat detectionDescriptors=new Mat();
Fdetector.detect(detection.image, detectionKeyPoints);
Fdescriptor.compute(detection.image, detectionKeyPoints, detectionDescriptors);
MatOfDMatch matches=new MatOfDMatch();
if (detectionDescriptors.cols() <= templateDescriptors.cols()) {
matcher.match(detectionDescriptors,templateDescriptors , matches);
} else {
matcher.match(templateDescriptors, detectionDescriptors, matches);
}
List<DMatch> matchlist=matches.toList();
for (DMatch dMatch : matchlist) {
if (dMatch.distance<80) {
template.IdOfContourMatcher =listOfDetections.indexOf(detection);
}
System.out.println(dMatch.distance);
}
}
}
}
@覆盖
公共无效匹配(模板列表、检测列表){
FeatureDetector Fdetector=FeatureDetector.create(FeatureDetector.ORB);
DescriptorExtractor fddescriptor=DescriptorExtractor.create(DescriptorExtractor.ORB);
DescriptorMatcher matcher=DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
用于(模板:listOfTemplates){
MatOfKeyPoint templateKeyPoints=新的MatOfKeyPoint();
Mat templateDescriptors=新Mat();
Fdetector.detect(template.image,templateKeyPoints);
计算(template.image、templateKeyPoints、templateDescriptor);
用于(模板检测:listOfDetections){
MatOfKeyPoint DETECTION KEYPOINTS=新的MatOfKeyPoint();
Mat检测描述符=新Mat();
Fdetector.detect(detection.image,detectionKeyPoints);
Fdescriptor.compute(detection.image、detectionKeyPoints、detectionDescriptor);
MatOfDMatch matches=新的MatOfDMatch();
if(detectionDescriptors.cols()