1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4
5 // This file contains wrappers for legacy OpenCV C API
6
7 #include "precomp.hpp"
8 #include "opencv2/calib3d/calib3d_c.h"
9
10 using namespace cv;
11
12 CV_IMPL void
cvDrawChessboardCorners(CvArr * _image,CvSize pattern_size,CvPoint2D32f * corners,int count,int found)13 cvDrawChessboardCorners(CvArr* _image, CvSize pattern_size,
14 CvPoint2D32f* corners, int count, int found)
15 {
16 CV_Assert(corners != NULL); //CV_CheckNULL(corners, "NULL is not allowed for 'corners' parameter");
17 Mat image = cvarrToMat(_image);
18 CV_StaticAssert(sizeof(CvPoint2D32f) == sizeof(Point2f), "");
19 drawChessboardCorners(image, pattern_size, Mat(1, count, traits::Type<Point2f>::value, corners), found != 0);
20 }
21
22 CV_IMPL int
cvFindChessboardCorners(const void * arr,CvSize pattern_size,CvPoint2D32f * out_corners_,int * out_corner_count,int flags)23 cvFindChessboardCorners(const void* arr, CvSize pattern_size,
24 CvPoint2D32f* out_corners_, int* out_corner_count,
25 int flags)
26 {
27 if (!out_corners_)
28 CV_Error( CV_StsNullPtr, "Null pointer to corners" );
29
30 Mat image = cvarrToMat(arr);
31 std::vector<Point2f> out_corners;
32
33 if (out_corner_count)
34 *out_corner_count = 0;
35
36 bool res = cv::findChessboardCorners(image, pattern_size, out_corners, flags);
37
38 int corner_count = (int)out_corners.size();
39 if (out_corner_count)
40 *out_corner_count = corner_count;
41 CV_CheckLE(corner_count, Size(pattern_size).area(), "Unexpected number of corners");
42 for (int i = 0; i < corner_count; ++i)
43 {
44 out_corners_[i] = cvPoint2D32f(out_corners[i]);
45 }
46 return res ? 1 : 0;
47 }
48