MCPcopy Create free account
hub / github.com/KAlO2/PerfectShow / line

Function line

jni/venus/opencv_utility.cpp:89–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void line(Mat& image, const Point2f& pt0, const Point2f& pt1, const Scalar& color,
90 int thickness/* = 1*/, int lineType/* = cv::LINE_8*/, int shift/* = 0*/)
91{
92 assert(pt0.x != pt1.x || pt0.y != pt1.y); // two points coincide!
93 Point2f delta = pt1 - pt0;
94 Point2f p0(0, 0), p1(static_cast<float>(image.cols - 1), static_cast<float>(image.rows - 1));
95 if(std::abs(delta.x) > std::abs(delta.y))
96 {
97 float k = delta.y / delta.x;
98 Point2f &left = p0, &right = p1;
99 left.y = k * (left.x - pt0.x) + pt0.y;
100 right.y = k * (right.x - pt0.x) + pt0.y;
101 }
102 else
103 {
104 float reciprocal_k = delta.x / delta.y;
105 Point2f &top = p0, &bottom = p1;
106 top.x = reciprocal_k * (top.y - pt0.y) + pt0.x;
107 bottom.x = reciprocal_k * (bottom.y - pt0.y) + pt0.x;
108 }
109 cv::line(image, p0, p1, color, thickness, lineType, shift);
110}
111
112void drawCross(cv::Mat& image, const cv::Point2f& position, int radius, const Scalar& color,
113 int thickness/* = 1*/, int lineType/* = cv::LINE_8*/, int shift/* = 0*/)

Callers 4

drawDelaunayFunction · 0.85
drawCrossFunction · 0.85
DrawShapeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected