Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/322.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
Java Android OpenCV描述符错误_Java_Android_Opencv - Fatal编程技术网

Java Android OpenCV描述符错误

Java Android OpenCV描述符错误,java,android,opencv,Java,Android,Opencv,我真的很难让描述器工作。我有一个模板图像,我想在每一帧的视频饲料寻找。以下是相关代码: //the following is done once since the template is static: templateImage = Utils.loadResource(mContext, R.raw.watch); detector.detect(rgb, templateKeypoints); Toast.makeText(mContext,"templateImage:" + temp

我真的很难让描述器工作。我有一个模板图像,我想在每一帧的视频饲料寻找。以下是相关代码:

//the following is done once since the template is static:
templateImage = Utils.loadResource(mContext, R.raw.watch);
detector.detect(rgb, templateKeypoints);
Toast.makeText(mContext,"templateImage:" + templateImage.rows() + "/" + templateImage.cols() + " templateKeypoints:" + templateKeypoints.rows() + "/"
                        + templateKeypoints.cols(), Toast.LENGTH_LONG).show();
descriptor.compute(rgb, templateKeypoints, templateDescriptors);
此toast的结果是“templateImage:480/640 templateKeypoints:0/1”,因此关键点有0行和1列

接下来,在每个帧上运行此代码:

public Mat featureDetection(Mat inputImage) {

    // first image
    Mat descriptors1 = new Mat();
    MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
    detector.detect(inputImage, keypoints1);
    descriptor.compute(inputImage, keypoints1, descriptors1);

    // second image - COVERED BY templateKeypoints, templateDescriptors
    // detector.detect(img2, keypoints2);
    // descriptor.compute(img2, keypoints2, descriptors2);
    // detector.detect(templateImage, templateKeypoints);
    // descriptor.compute(templateImage, templateKeypoints,
    // templateDescriptors);

    // matcher should include 2 different image's descriptors
    Log.d(TAG, "descriptors1.type: " + descriptors1.type() + " / cols: " + descriptors1.cols());
    Log.d(TAG, "templateDescriptors.type: " + templateDescriptors.type() + " / cols: " + templateDescriptors.cols());
    matcher.match(descriptors1, templateDescriptors, matches);

    // output image
    Mat outputImg = new Mat();
    MatOfByte drawnMatches = new MatOfByte();
    // this will draw all matches, works fine
    Features2d.drawMatches(inputImage, keypoints1, templateImage, templateKeypoints, matches, outputImg, GREEN, RED, drawnMatches,
            Features2d.NOT_DRAW_SINGLE_POINTS);

    return inputImage;
}
我还没来得及归还任何东西,它就崩溃了:

(首先记录结果:)

因此,我认为我的
tempateKeypoints
模板描述符肯定存在一些大问题

另外,假设我已经克服了这个错误,
outImage
drawnMatches
到底是什么?如果我想在我的640x480视频源(featureDetection
的返回值mat)上覆盖与模板的潜在匹配,我会返回
outImage

谢谢

可能重复的
04-27 23:04:53.011: D/FrameProcessing(2225): descriptors1.type: 0 / cols: 32
04-27 23:04:53.011: D/FrameProcessing(2225): templateDescriptors.type: 0 / cols: 0

04-27 23:04:53.011: E/cv::error()(2225): 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/reports/ci/slave/50-SDK/opencv/modules/core/src/stat.cpp, line 1797
04-27 23:04:53.011: W/dalvikvm(2225): threadid=11: thread exiting with uncaught exception (group=0x413c9930)
04-27 23:04:53.018: E/AndroidRuntime(2225): FATAL EXCEPTION: Thread-207
04-27 23:04:53.018: E/AndroidRuntime(2225): CvException [org.opencv.core.CvException: /home/reports/ci/slave/50-SDK/opencv/modules/core/src/stat.cpp:1797: 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)
04-27 23:04:53.018: E/AndroidRuntime(2225): ]
04-27 23:04:53.018: E/AndroidRuntime(2225):     at org.opencv.features2d.DescriptorMatcher.match_1(Native Method)
04-27 23:04:53.018: E/AndroidRuntime(2225):     at org.opencv.features2d.DescriptorMatcher.match(DescriptorMatcher.java:437)
04-27 23:04:53.018: E/AndroidRuntime(2225):     at com.bigsolve.frameprocessing.FrameProcessing.featureDetection(FrameProcessing.java:114)