c++ - OpenCV error in codes -


i'm doing project on opencv on image matching. lines

    std::vector<cv::keypoint> keypoints1;     std::vector<cv::keypoint> keypoints2; 

have error: namespace "cv" has no member "keypoint" how solve this?

another error in code

    //define feature detector     cv::fastfeaturedetector fastdet(80);     //keypoint detection     fastdet.detect(image1, keypoints1);     fastdet.detect(image2, keypoints2); 

where error says: object of abstract class type "cv::fastfeaturedetector" not allowed:

function :cv::fastfeaturedetector::setthreshold" pure virtual function

function :cv::fastfeaturedetector::getthreshold" pure virtual function

function :cv::fastfeaturedetector::setnonmaxsuppression" pure virtual function

function :cv::fastfeaturedetector::getnonmaxsuppression" pure virtual function

function :cv::fastfeaturedetector::settype" pure virtual function

function :cv::fastfeaturedetector::gettype" pure virtual function

can please help?

here whole code:

    #include "opencv2/highgui/highgui.hpp"     #include "opencv2/imgproc/imgproc.hpp"     #include "opencv2\features2d\features2d.hpp"     #include"opencv2\core.hpp"      #include <iostream>     #include <stdio.h>     #include <stdlib.h>     #include <vector>      using namespace cv;     using namespace std;      void main(int argc, const char** argv)     {         mat image1 = imread("image1.jpg", cv_load_image_unchanged);         mat image2 = imread("image2.jpg", cv_load_image_unchanged);          //define keypoints vector         std::vector<cv::keypoint> keypoints1;         std::vector<cv::keypoint> keypoints2;          //define feature detector         cv::fastfeaturedetector fastdet(80);         //keypoint detection         fastdet.detect(image1, keypoints1);         fastdet.detect(image2, keypoints2);          //define square neighbourhood         const int nsize(11);                            //size of neighbourhood         cv::rect neighbourhood(0, 0, nsize, nsize);     //11x11         cv::mat patch1;         cv::mat patch2;          //for points in first image         //find best match in second image         cv::mat result;         std::vector<cv::dmatch> matches;          //for keypoints in image 1         (int = 0; < keypoints1.size(); i++)         {             //define image patch             neighbourhood.x = keypoints1[i].pt.x - nsize / 2;             neighbourhood.y = keypoints1[i].pt.y - nsize / 2;              //if neighbourhood of points outside image,             //then continue next point             if (neighbourhood.x < 0 || neighbourhood.y < 0 || neighbourhood.x + nsize >= image1.cols || neighbourhood.y + nsize >= image1.rows)                 continue;              //patch in image 1             patch1 = image1(neighbourhood);              //reset best correlation value;             cv::dmatch bestmatch;              //for keypoints in image 2             (int j = 0; j < keypoints2.size(); j++)             {                 //define image patch                 neighbourhood.x = keypoints2[j].pt.x - nsize / 2;                 neighbourhood.y = keypoints2[j].pt.y - nsize / 2;                   //if neighbourhood of points outside image,                 //then continue next point                 if (neighbourhood.x < 0 || neighbourhood.y < 0 || neighbourhood.x + nsize >= image2.cols || neighbourhood.y + nsize >= image2.rows)                     continue;                  //patch in image 2                 patch2 = image2(neighbourhood);                  //match 2 patches                 cv::matchtemplate(patch1, patch2, result, cv_tm_sqdiff_normed);                  //check if best match                 if (result.at<float>(0, 0) < bestmatch.distance)                 {                     bestmatch.distance = result.at<float>(0, 0);                     bestmatch.queryidx = i;                     bestmatch.trainidx = j;                 }             }             //add best match             matches.push_back(bestmatch);         }         //extract 25 best matches         std::nth_element(matches.begin(), matches.begin() + 25, matches.end());         matches.erase(matches.begin() + 25, matches.end());          //draw matching results         cv::mat matchimage;         cv::drawmatchesflags();     } 

  • there mistakes in code.

    1. replace belowe line

      std::vector<cv::keypoint> keypoints1; std::vector<cv::keypoint> keypoints2; 

      with this

      std::vector<cv::keypoint> keypoints1; std::vector<cv::keypoint> keypoints2; 
    2. for cv::fastfeaturedetector fastdet(80); may need include library opencv_features2d

  • after changes code run successfully.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -