'Developer/OpenCV'에 해당되는 글 29건

  1. 2013.01.30 보정객체(체스판) 찾기

#include <cv.h>

#include <highgui.h>

#include <stdio.h>

 

#define CHESSBOARD_WIDTH 9

#define CHESSBOARD_HEIGHT 6

#define COUNT_OF_CORNERS (CHESSBOARD_WIDTH*CHESSBOARD_HEIGHT)

 

 

void findChessBoardCalibrationObject(IplImage* chessBoardImage);

int main(void) {

        IplImage* chessBoardImage=cvLoadImage("right04.jpg");

 

        findChessBoardCalibrationObject(chessBoardImage);

 

        cvReleaseImage(&chessBoardImage);

}

 

void findChessBoardCalibrationObject(IplImage* chessBoardImage) {

       

        CvPoint2D32f corners[COUNT_OF_CORNERS];

        int corner_count;

        int pattern_was_found;

 

        pattern_was_found=cvFindChessboardCorners(chessBoardImage, cvSize(CHESSBOARD_WIDTH, CHESSBOARD_HEIGHT),

               corners, &corner_count, CV_CALIB_CB_ADAPTIVE_THRESH);

 

        printf("corner_count : %d\n", corner_count);

 

        for(int i=0; i<COUNT_OF_CORNERS; i++) {

               printf("x : %f, y : %f\n", corners[i].x, corners[i].y);

        }

 

        cvDrawChessboardCorners(chessBoardImage, cvSize(CHESSBOARD_WIDTH, CHESSBOARD_HEIGHT),

               corners, corner_count, pattern_was_found);

 

        cvNamedWindow("lueseypid", CV_WINDOW_AUTOSIZE);

        cvShowImage("lueseypid", chessBoardImage);

        cvWaitKey(0);

 

        cvDestroyWindow("lueseypid");

}


Posted by No names
,