- Mastering OpenCV 4 with Python
- Alberto Fernández Villán
- 164字
- 2021-07-02 12:07:21
Understanding advanced shapes
In this section, we are going to see how to draw clip lines, arrowed lines, ellipses, and polylines. These shapes are not as straightforward to draw as the shapes we saw in the previous section, but they are simple to understand. The first step is to create an image where the shapes will be drawn. For this, a 300 300 image with the 3 channels (to properly display a BGR image) and a uint8 type (8-bit unsigned integers) will be created:
# We create the canvas to draw: 300 x 300 pixels, 3 channels, uint8 (8-bit unsigned integers)
# We set the background to black using np.zeros()
image = np.zeros((300, 300, 3), dtype="uint8")
We set the background to light gray using the colors dictionary:
# If you want another background color, you can do the following:
image[:] = colors['light_gray']
At this point, we can start drawing the new shapes.
推薦閱讀
- 案例式C語言程序設計
- Apache Oozie Essentials
- C#程序設計實訓指導書
- 密碼學原理與Java實現
- C# 從入門到項目實踐(超值版)
- 大學計算機基礎(第2版)(微課版)
- JavaScript 程序設計案例教程
- C++20高級編程
- Visual C#.NET Web應用程序設計
- Learning Nessus for Penetration Testing
- ArcPy and ArcGIS(Second Edition)
- iOS Development with Xamarin Cookbook
- HTML5 Canvas核心技術:圖形、動畫與游戲開發
- AI輔助編程Python實戰:基于GitHub Copilot和ChatGPT
- C++從零開始學(視頻教學版)(第2版)