视觉识别模块
0、学前先看&供电说明
1、固件下载与烧录
2、安装编程环境
3、调试运行例程
4、离线运行例程
5、Micropython 快速入门
6、GUI程序使用说明
7、二维云台安装教程
8、FPIOA引脚分配
9、RGB灯
10、蜂鸣器
11、按键
12、串口通信
13、I2C通讯
14、PWM
15、WDT看门狗
16、定时器计时
17、傅里叶变换
18、SHA256加密
19、AES加密
20、多线程
21、文件读写
22、图像显示
23、触摸显示
24、摄像头显示
25、图像翻转
26、照相机
27、绘制圆形
28、绘制矩形
29、绘制椭圆
30、绘制箭头
31、绘制十字准心
32、绘制文字
汝城县职业中等专业学校知识库-信息中心朱老师编辑
-
+
首页
29、绘制椭圆
## 例程简介 本节我们介绍绘制椭圆的draw_ellipse()方法 `draw_ellipse`函数可实现在图像上绘制一个椭圆。 * 语法 `image.draw_ellipse(cx, cy, rx, ry, color, thickness=1)` * 参数解释 * `cx, cy`:椭圆中心的坐标。 * `rx, ry`:椭圆的半径(x轴和y轴方向)。 * `color`:椭圆的颜色。 * `thickness`:椭圆边框的厚度(默认为1)。 > 详情请参考[OpenMV](https://openmv.io/)的官方文档 ## 示例代码 ``` # Import required modules # 导入所需的模块 import time, os, urandom, sys, math # Import display and media related modules # 导入显示和媒体相关模块 from media.display import * from media.media import * from random import randint # Define display resolution constants # 定义显示分辨率常量 DISPLAY_WIDTH = 640 DISPLAY_HEIGHT = 480 def display_test(): """ Function to test display functionality 测试显示功能的函数 """ # Create main background image with white color # 创建白色背景的主图像 img = image.Image(DISPLAY_WIDTH, DISPLAY_HEIGHT, image.ARGB8888) img.clear() img.draw_rectangle(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT,color=(255,255,255),fill=True) # Initialize display with ST7701 driver # 使用ST7701驱动初始化显示器 Display.init(Display.ST7701, width = DISPLAY_WIDTH, height = DISPLAY_HEIGHT, to_ide = True) # Initialize media manager # 初始化媒体管理器 MediaManager.init() for i in range(10): x = randint(0, 2 * img.width()) - img.width() // 2 y = randint(0, 2 * img.height()) - img.height() // 2 rx = randint(0, max(img.height(), img.width()) // 2) ry = randint(0, max(img.height(), img.width()) // 2) rot = randint(0, 360) r = randint(0, 127) + 128 g = randint(0, 127) + 128 b = randint(0, 127) + 128 # 如果第一个参数是缩放器,则此方法需要传递x,y,半径x 和 半径y。 # 否则,它需要一个(x,y,radius_x,radius_y)元组。 img.draw_ellipse( x, y, rx, ry, rot, color=(r, g, b), thickness=2, fill=False ) # Update display with background image # 更新显示背景图像 Display.show_image(img) while True: time.sleep(2) # Cleanup and deinitialize display # 清理并反初始化显示器 Display.deinit() os.exitpoint(os.EXITPOINT_ENABLE_SLEEP) time.sleep_ms(100) # Release media resources # 释放媒体资源 MediaManager.deinit() if __name__ == "__main__": # Enable exit points and run display test # 启用退出点并运行显示测试 os.exitpoint(os.EXITPOINT_ENABLE) display_test() ``` ## 运行效果 
admin
2026年1月4日 08:02
转发
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
Word文件
PDF文档
PDF文档(打印)
分享
链接
类型
密码
更新密码
有效期
AI