opencv 에서 일치 하 는 좌표 추출 방식 을 사용 합 니 다.

opencv 에서 특징 검 측,설명,매 칭 은 모두 통합 함수 가 있 습 니 다.vector bestMatches;저장 할 일치 점 쌍.그렇다면 그 중의 좌 표를 어떻게 추출 합 니까?

 int index1, index2;
 for (int i = 0; i < bestMatches.size(); i++)//           point
 {
 index1 = bestMatches.at(i).queryIdx;
 index2 = bestMatches.at(i).trainIdx;
 
 cout << keyImg1.at(index1).pt.x << " "
    << keyImg1.at(index1).pt.y << " "
    << keyImg2.at(index2).pt.x << " "
    << keyImg2.at(index2).pt.y << endl;
 }
OpenCV 는 연결 필드 의 모든 좌표 점 을 어떻게 얻 습 니까?

#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
 
int main(int argc, char* argv[])
{
    IplImage* img;
    img = cvLoadImage("D:\\OOTT\\WEEK5\\2.png");
    IplImage* gray = cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,1);
    cvCvtColor(img,gray,CV_BGR2GRAY);
    cvThreshold(gray,gray,128,255,CV_THRESH_BINARY);
    CvMemStorage* storage = cvCreateMemStorage();
    CvSeq * first_contour = NULL;
    int Ncontour = cvFindContours(gray,storage,&first_contour,sizeof(CvContour),CV_RETR_LIST); 
    //Ncontour cvFindContours         
    for(CvSeq* c = first_contour;c!= NULL;c=c->h_next)
    { 
    //    cvDrawContours(img,c,cvScalar(255,255,0),cvScalar(255,0,255),0,2,8);
        cvNamedWindow("contours",CV_WINDOW_AUTOSIZE);
    //    cvShowImage("contours",img);
        for(int k = 0;k <c->total;++k)
        {
            CvPoint* p = CV_GET_SEQ_ELEM(CvPoint,c,k);
            printf("(%d,%d)
",p->x,p->y); } CvRect rect; rect = cvBoundingRect(c,0); cvFloodFill(img,cvPoint(img->width/2,img->height/2),cvScalar(255,255,255),cvScalar(20),cvScalar(20),NULL,4,NULL); cvShowImage("contours",img); int Num[500][500]; for (int i=0;i<(img->height-5);i++) for (int j=0;j<(img->width-5);j++) { CvScalar S0; S0=cvGet2D(img,i,j); if(S0.val[0] == 255) Num[i][j]=1; else Num[i][j]=0; printf("(%d,%d)
",i,j); } } cvWaitKey(0); cvReleaseImage(&img); cvReleaseImage(&gray); cvDestroyWindow("contours"); return 0; }
이상 의 이 편 은 opencv 에서 일치 하 는 좌표 추출 방식 을 사용 하 는 것 이 바로 편집장 이 여러분 에 게 공유 하 는 모든 내용 입 니 다.여러분 께 참고 가 되 고 저희 도 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기