|
@@ -119,6 +119,8 @@ class BookShape {
|
|
|
double ysize();
|
|
|
cv::Mat* getTrasfs();
|
|
|
};
|
|
|
+//topleft topmiddle topright
|
|
|
+//botleft botmiddle botright
|
|
|
BookShape::BookShape(cv::Point tl, cv::Point tm, cv::Point tr, cv::Point bl, cv::Point bm, cv::Point br)
|
|
|
{
|
|
|
trapezoids[0][0] = tl;
|
|
@@ -195,14 +197,32 @@ BookShape get_book_shape(cv::Mat img)
|
|
|
corn_3 = hull[maxdistances[1]];
|
|
|
corn_4 = hull[(maxdistances[1]+1)%hull.size()];
|
|
|
|
|
|
- std::vector<cv::Point> verticals[2];
|
|
|
+ std::vector<cv::Point> vertical_points[2];
|
|
|
+ cv::Vec<double,3> verticals[2];
|
|
|
// Between the two corners on the same side, the longest line is the vertical border of the book
|
|
|
- verticals[0] = find_longest_line(hull, (maxdistances[0]+1)%hull.size(), maxdistances[1]);
|
|
|
+ vertical_points[0] = find_longest_line(hull, (maxdistances[0]+1)%hull.size(), maxdistances[1]);
|
|
|
std::cout << maxdistances[1] << std::endl;
|
|
|
std::cout << maxdistances[1]+1 << std::endl;
|
|
|
std::cout << (maxdistances[1]+1)%hull.size() << std::endl;
|
|
|
- verticals[1] = find_longest_line(hull, (maxdistances[1]+1)%hull.size(), maxdistances[0]);
|
|
|
+ vertical_points[1] = find_longest_line(hull, (maxdistances[1]+1)%hull.size(), maxdistances[0]);
|
|
|
free(maxdistances);
|
|
|
+#ifdef _DEBUG
|
|
|
+ img = cv::imread("files/masckera.png", CV_LOAD_IMAGE_COLOR);
|
|
|
+ cv::circle(img, vertical_points[0][0], img.cols>>7, cv::Scalar(200, 0, 0), -1);
|
|
|
+ cv::circle(img, vertical_points[0][vertical_points[0].size()-1], img.cols>>7, cv::Scalar(200, 0, 0), -1);
|
|
|
+ cv::circle(img, vertical_points[1][0], img.cols>>7, cv::Scalar(200, 200, 0), -1);
|
|
|
+ cv::circle(img, vertical_points[1][vertical_points[1].size()-1], img.cols>>7, cv::Scalar(200, 0, 0), -1);
|
|
|
+ cv::circle(img, corn_1, img.cols>>7, cv::Scalar(200, 0, 200), -1);
|
|
|
+ cv::namedWindow("aaa", CV_GUI_NORMAL);
|
|
|
+ cv::imshow("aaa", img);
|
|
|
+ cv::waitKey(0);
|
|
|
+#endif
|
|
|
+ verticals[0] = get_line(vertical_points[0][0], vertical_points[0][vertical_points[0].size()-1]);
|
|
|
+ std::cout << verticals[0] << std::endl;
|
|
|
+ std::cout << line_value(verticals[0], corn_1) << std::endl;
|
|
|
+ verticals[0][2] -= line_value(verticals[0], corn_1);
|
|
|
+ std::cout << line_value(verticals[0], corn_1) << "=0?" << std::endl;
|
|
|
+ verticals[1] = get_line(vertical_points[1][0], vertical_points[1][vertical_points[1].size()-1]);
|
|
|
|
|
|
// theta is the angle of the line connecting point 1 and 2; it will be the
|
|
|
// rotation of our new coordinate system
|