- 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:

推薦閱讀
- 匯編語言程序設計(第3版)
- Learning Data Mining with R
- Mastering JavaScript High Performance
- Corona SDK Mobile Game Development:Beginner's Guide(Second Edition)
- C語言從入門到精通
- Android嵌入式系統程序開發:基于Cortex-A8(第2版)
- 深度學習原理與PyTorch實戰(第2版)
- RESTful Web Clients:基于超媒體的可復用客戶端
- Laravel Design Patterns and Best Practices
- 零基礎學編程系列(全5冊)
- Building a Media Center with Raspberry Pi
- Microsoft Dynamics GP 2013 Cookbook
- WCF全面解析
- 樹莓派開發從零開始學:超好玩的智能小硬件制作書
- 循序漸進Vue.js 3前端開發實戰