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

推薦閱讀
- C# 7 and .NET Core Cookbook
- JavaScript 從入門到項目實踐(超值版)
- 跟老齊學Python:輕松入門
- 深度強化學習算法與實踐:基于PyTorch的實現
- SAS數據統計分析與編程實踐
- TradeStation交易應用實踐:量化方法構建贏家策略(原書第2版)
- SQL Server 2016數據庫應用與開發
- Web Development with MongoDB and Node(Third Edition)
- HTML5從入門到精通 (第2版)
- Learning Laravel's Eloquent
- Scala Reactive Programming
- 深入剖析Java虛擬機:源碼剖析與實例詳解(基礎卷)
- 編程可以很簡單
- FFmpeg開發實戰:從零基礎到短視頻上線
- UML軟件建模