The purpose of this work is to extract key points in real time from an existing image during the video scene. In the frame, execution is performed that does not work, because of the correspondence, is that I can simply display the key points of correspondence in the form of circles on the image in real time
class Sample1View extends SampleViewBase { public static final int VIEW_MODE_RGBA = 0; public static final int VIEW_MODE_BLUE = 1; public static final int VIEW_MODE_YELLOW = 2; public static final int VIEW_MODE_DE = 3; private Mat mYuv; private Mat mRgba; private Mat mGraySubmat; private Mat mResult; private Mat mIntermediateMat; private Bitmap mBitmap; private int mViewMode; private Mat mColor; private Mat mHsv; TimingLogger timings; private Mat img1; private Mat descriptors; private MatOfKeyPoint keypoints; private FeatureDetector detector; private DescriptorExtractor descriptor; private DescriptorMatcher matcher; private static final String TAG ="Sample::View"; public Sample1View(Context context) { super(context); mViewMode = VIEW_MODE_RGBA; try { img1=Utils.loadResource(getContext(), R.drawable.wings); } catch (IOException e) {
// cvt_YUVtoRGBtoHSV:
@Override protected Bitmap processFrame(byte[] data) { mYuv.put(0, 0, data); final int viewMode = mViewMode; ColorDetection.cvt_YUVtoRGBtoHSV(mYuv,mGraySubmat); MatOfKeyPoint mKeyPoints = new MatOfKeyPoint(); MatOfDMatch matches = new MatOfDMatch(); detector.detect(mGraySubmat, mKeyPoints); descriptor.compute(mGraySubmat, mKeyPoints, mIntermediateMat); matcher.match(mIntermediateMat, descriptors, matches); mIntermediateMat2.create(resultSize, CvType.CV_8UC1); Features2d.drawMatches(mGraySubmat, mKeyPoints, mGraySubmat, mKeyPoints, matches, mIntermediateMat2); Imgproc.resize(mIntermediateMat2, mIntermediateMat2, mRgba.size()); Imgproc.cvtColor(mIntermediateMat2, mRgba, Imgproc.COLOR_RGBA2BGRA, 4); break; } Bitmap bmp = mBitmap; try { Utils.matToBitmap(mRgba, bmp); } catch(Exception e) { Log.e("org.opencv.samples.*", "Utils.matToBitmap() throws an exception: " + e.getMessage()); bmp.recycle(); bmp = null; } return bmp; } public void setViewMode(int viewMode) { mViewMode = viewMode; } }
and what's in log
CvException [org.opencv.core.CvException: /home/reports/ci/slave/50-SDK/opencv/modules/features2d/src/draw.cpp: 207: error: (-215) i1> = 0 && i1 < static_cast (keypoints1.size ()) in the function void cv :: drawMatches (const cv :: Mat &, const std :: vector &, const cv :: Mat &, const std :: vector &, const std :: vector & , cv :: Mat &, const Scalar &, const Scalar &, const std :: vector &, int)