21 #include <opencv2/imgproc/imgproc.hpp> 22 #include <opencv2/highgui/highgui.hpp> 23 #include <opencv2/calib3d/calib3d.hpp> 26 #include <boost/foreach.hpp> 31 std::vector<cv::Point2f> vtx(4);
32 std::vector<cv::Point2f> vtxDis;
33 cv::Scalar colourContour(255,0,255);
34 cv::Scalar colourEllipse(0,0,255);
36 for(
unsigned int i = 0; i <
ellipses_.size(); i++) {
40 cv::RotatedRect box1, box2;
42 cv::ellipse(img, box1, colourEllipse, 1, CV_AA);
44 if(ellipse.
innerRing >= 0) cv::ellipse(img, box2, colourEllipse, 1, CV_AA);
46 for(
int j = 0; j < 4; j++ ) {
47 cv::line(img, vtx[j], vtx[(j+2)%4], cv::Scalar(0,255,0), 1, CV_AA);
48 sprintf(text,
"%i", j);
52 BOOST_FOREACH(
const cv::Point2f &p, vtxDis ) {
53 img.at<cv::Vec3b>(p) = cv::Vec3b(0,255,255);
58 for(
unsigned int k = 0; k < 2; k++) {
63 for(
int j = 0; j < pi.rows; j++) {
64 cv::Point p0(pi.at<
double>(j,0),pi.at<
double>(j,1));
65 cv::circle(img, p0,2, cv::Scalar(125*j,125*j,255));
66 cv::Point p1(pin.at<
double>(j,0),pin.at<
double>(j,1));
67 cv::line(img, p0, p1, cv::Scalar(125*j,125*j,255), 1, CV_AA);
74 std::cout <<
"% === " << std::setw(4) <<
loop_count;
75 std::cout <<
" ===== ellipse " << std::setw(4) << i <<
" ===" << std::endl;
76 std::cout <<
"ellipse.center = " << ellipse.
boxEllipse.center <<
"; " << std::endl;
77 std::cout <<
"ellipse.size = " << (cv::Point2f) ellipse.
boxEllipse.size <<
"; " << std::endl;
78 std::cout <<
"ellipse.angle = " << M_PI/180.0 *ellipse.
boxEllipse.angle <<
"; " << std::endl;
79 std::cout <<
"ellipse.C = " << ellipse.
cone.
C <<
"; " <<
" % Ellipse Image" << std::endl;
81 std::cout <<
"ellipse.nr_of_edges=" << ellipse.
contourUndistort->size() <<
"; " << std::endl;
82 std::cout <<
"ellipse.contour = " << cv::Mat(*ellipse.
contourUndistort) <<
"; " << std::endl;
cv::Mat_< double > distCoeffs
boost::shared_ptr< std::vector< cv::Point2f > > contourUndistort
void draw_ellipses(cv::Mat &m)
void distort(const std::vector< cv::Point2f > &src, std::vector< cv::Point2f > &des)
cv::Mat_< double > projectionMatrix
cv::RotatedRect boxEllipse
cv::Vec3d normals[2]
two plausible translations solutions
tuw::Contour contour_detector_
std::vector< Ellipse > ellipses_
cv::Mat_< double > cameraMatrix
cv::Point2d projections[2]
two plausible translations solutions
void Draw(unsigned char *pImgRGB)
Draws the detected contours in a RGB image with radom colours.
cv::Point3d translations[2]
ellipse equation