- Mastering OpenCV 4 with Python
- Alberto Fernández Villán
- 90字
- 2021-07-02 12:07:20
Drawing lines
The first function we are going to see is cv2.line(). The signature is as follows:
img = line(img, pt1, pt2, color, thickness=1, lineType=8, shift=0)
This function draws a line on the img image connecting pt1 and pt2:
cv2.line(image, (0, 0), (400, 400), colors['green'], 3)
cv2.line(image, (0, 400), (400, 0), colors['blue'], 10)
cv2.line(image, (200, 0), (200, 400), colors['red'], 3)
cv2.line(image, (0, 200), (400, 200), colors['yellow'], 10)
After coding these lines, we call the show_with_matplotlib(image, 'cv2.line()') function. The result is shown in the next screenshot:

推薦閱讀
- Web全棧工程師的自我修養
- Python機器學習:手把手教你掌握150個精彩案例(微課視頻版)
- Creating Stunning Dashboards with QlikView
- MySQL從入門到精通(軟件開發視頻大講堂)
- Python算法詳解
- “笨辦法”學C語言
- Visual Basic程序設計習題與上機實踐
- Python Projects for Kids
- Angular Design Patterns
- 深入淺出 HTTPS:從原理到實戰
- HTML5 WebSocket權威指南
- Java Web動態網站開發(第2版·微課版)
- SOA Patterns with BizTalk Server 2013 and Microsoft Azure(Second Edition)
- Programming MapReduce with Scalding
- Java Web程序員面試筆試寶典