【01Studio MaixPy AI K210】10.LCD

本文介绍LCD显示屏的基础操作方法,包括初始化、显示文字与图片等。提供了详细的代码示例,如设置显示方向、镜像显示等功能,并附带了一个完整的示例程序。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

导包:

lcd库

烧图片文件:

脱机运行:

例程:

导包:

import lcd,image,utime

lcd库

'''
初始化 LCD。 
【type】LCD 类型;
【freq】通信频率;
【color】LCD 初始化的颜色。
'''
lcd.init(type=1,freq=15000000,color=lcd.BLACK)

#注销 LCD 驱动,释放 IO 引脚。
lcd.deinit()

#填充指定颜色。默认是黑色
lcd.clear(color)

'''
写字符
【x,y】起始坐标;
【str】字符内容
【color】字体颜色
【bg_color】字体背景颜色
'''
lcd.draw_string(x,y,str,color,bg_color)

'''
显示图片。
【image】RGB565 或 GRAYSCALE 图片。
【ROI】显示的感兴趣区域,未指定则为图像大小。
'''
lcd.display(image,roi=Auto)

'''
LCD 屏幕方向设定。
【dir】取值范围[0-3],从 0 到 3 依顺时钟旋转。
'''
lcd.rotation(dir)

'''
镜面显示。
【invert】=True 则为镜面显示;=False 则否。
'''
lcd.mirror(invert)

烧图片文件:

脱机运行:

将 LCD.py 改成 main.py,发送到开发板。

 

例程:

'''
main.py

说明:编程实现LCD显示信息。需要将01Studio.bmp文件发送到开发板。
'''

import lcd,image,utime

lcd.init() #初始化LCD
lcd.clear(lcd.WHITE) #清屏白色

#显示字符
lcd.draw_string(100, 100, "happy new years!",lcd.RED, lcd.WHITE) #显示字符

utime.sleep(2) #延时2秒

#显示图像,记得先将01Studio.bmp文件发送到开发板
lcd.rotation(1) #由于图像默认是240*320,因此顺时钟旋转90°。
lcd.display(image.Image("01Studio.bmp"))

(代码是:#实验名称:人脸检测_68关键点 #翻译和注释:01Studio #实验平台:01Studio CanMV K210 mini #导入相关模块 import sensor, image, time, lcd from maix import KPU import gc lcd.init() # LCD初始化 sensor.reset() # 摄像头初始化 #设置摄像头颜色和帧率 sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 500) clock = time.clock() od_img = image.Image(size=(320,256), copy_to_fb=False) #构建KPU对象 #需要导入2个模型,分别是人脸检测模型和68关键点检测模型 anchor = (0.893, 1.463, 0.245, 0.389, 1.55, 2.58, 0.375, 0.594, 3.099, 5.038, 0.057, 0.090, 0.567, 0.904, 0.101, 0.160, 0.159, 0.255) kpu = KPU() print("ready load model") kpu.load_kmodel("/sd/face_detect.kmodel") kpu.init_yolo2(anchor, anchor_num=9, img_w=320, img_h=240, net_w=320 , net_h=256 ,layer_w=10 ,layer_h=8, threshold=0.7, nms_value=0.2, classes=1) lm68_kpu = KPU() print("ready load model") lm68_kpu.load_kmodel("/sd/landmark68.kmodel") RATIO = 0.08 while 1: gc.collect() #print("mem free:",gc.mem_free()) clock.tick() # Update the FPS clock. img = sensor.snapshot() a = od_img.draw_image(img, 0,0) od_img.pix_to_ai() kpu.run_with_output(od_img) dect = kpu.regionlayer_yolo2() fps = clock.fps() #识别到人脸 if len(dect) > 0: print("dect:",dect) for l in dect : a = img.draw_rectangle(l[0],l[1],l[2],l[3], color=(0, 255, 0)) x1_t = l[0] - RATIO*l[2] x2_t = l[0]+l[2] + RATIO*l[2] y1_t = l[1] - RATIO*l[3] y2_t = l[1]+l[3] + RATIO*l[3] x1 = int(x1_t) if x1_t>1 else 1 x2 = int(x2_t) if x2_t<320 else 319 y1 = int(y1_t) if y1_t>1 else 1 y2 = int(y2_t) if y2_t<256 else 255 cut_img_w = x2-x1+1 cut_img_h = y2-y1+1 #print("cut img ",x1, y1, cut_img_w, cut_img_h) face_cut = img.cut(x1,y1,cut_img_w,cut_img_h) face_cut_128 = face_cut.resize(128, 128) face_cut_128.pix_to_ai() #识别68个关键点 out =
最新发布
03-23
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

因心,三人水

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值