gpt4 book ai didi

android - FeatureDetector.detect()函数错误

转载 作者:行者123 更新时间:2023-12-02 17:53:07 29 4
gpt4 key购买 nike

我正在尝试使用FAST FeatureDetector来检测手机摄像头拍摄的视频的关键点。当我尝试运行matcher.match(descriptor1,descriptor2,matches)时,出现错误。

这是我的代码:

private Mat bgMat; //contains the first frame taken by the camera
private Mat fgMat; //contains the second frame
private MatOfKeyPoint keypoints1;
private MatOfKeyPoint keypoints2;
private Mat descriptor1;
private Mat descriptor2;

FeatureDetector FAST = FeatureDetector.create(FeatureDetector.FAST);

keypoints1 = new MatOfKeyPoint();
keypoints2 = new MatOfKeyPoint();
descriptor1 =new Mat();
descriptor2 =new Mat();
matches= new MatOfDMatch();

FAST.detect(bgMat, keypoints1);
FAST.detect(fgMat, keypoints2);
DescriptorExtractor Extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
Extractor.compute(bgMat, keypoints1, descriptor1);
Extractor.compute(fgMat, keypoints2,descriptor2);

DescriptorMatcher matcher =DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
matcher.match(descriptor1,descriptor2, matches);
Features2d.drawMatches(bgMat, keypoints1, fgMat, keypoints2, matches, inputFrame);

这是我发布的日志:
02-11 13:00:25.926: E/cv::error()(16153): OpenCV Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)) in void cv::batchDistance(cv::InputArray, cv::InputArray, cv::OutputArray, int, cv::OutputArray, int, int, cv::InputArray, int, bool), file /home/oleg/sources/opencv/modules/core/src/stat.cpp, line 1803
02-11 13:00:25.926: W/dalvikvm(16153): threadid=11: thread exiting with uncaught exception (group=0x415eb2a0)
02-11 13:00:25.926: E/AndroidRuntime(16153): FATAL EXCEPTION: Thread-3281
02-11 13:00:25.926: E/AndroidRuntime(16153): CvException [org.opencv.core.CvException: /home/oleg/sources/opencv/modules/core/src/stat.cpp:1803: error: (-215) type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U) in function void cv::batchDistance(cv::InputArray, cv::InputArray, cv::OutputArray, int, cv::OutputArray, int, int, cv::InputArray, int, bool)
02-11 13:00:25.926: E/AndroidRuntime(16153): ]
02-11 13:00:25.926: E/AndroidRuntime(16153): at org.opencv.features2d.DescriptorMatcher.match_1(Native Method)
02-11 13:00:25.926: E/AndroidRuntime(16153): at org.opencv.features2d.DescriptorMatcher.match(DescriptorMatcher.java:437)
02-11 13:00:25.926: E/AndroidRuntime(16153): at com.example.cvcamt.MainActivity.onCameraFrame(MainActivity.java:152)
02-11 13:00:25.926: E/AndroidRuntime(16153): at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:283)
02-11 13:00:25.926: E/AndroidRuntime(16153): at org.opencv.android.NativeCameraView$CameraWorker.run(NativeCameraView.java:144)
02-11 13:00:25.926: E/AndroidRuntime(16153): at java.lang.Thread.run(Thread.java:856)

我尝试更改Mat类型(当前为CV_8UC4)。我只是不知道为什么当我尝试进行比赛时会发生这种情况。

非常感谢您的帮助,谢谢!

最佳答案

您需要创建keypoints1和keypoints2对象。喜欢

keypoints1 = new MatOfKeyPoint();

因为现在它们为空;

关于android - FeatureDetector.detect()函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14819230/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com