#include #include #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include #include "opencv2/imgcodecs.hpp" using namespace cv; using namespace std; /** @function main */ int main(int argc, char** argv) { Mat src = imread("d:/image/checkerboard.png", IMREAD_GRAYSCALE); Mat dst, cdst; Canny(src, dst, 50, 200, 3); cvtColor(dst, cdst, CV_GRAY2BGR); vector lines; HoughLinesP(dst, lines, 1, CV_PI / 180, 50, 50, 10); for (size_t i = 0; i < lines.size(); i++) { Vec4i l = lines[i]; line(cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 3, CV_AA); } imshow("source", src); imshow("detected lines", cdst); waitKey(0); } /** @function readme */