369| 15
|
[求助] 行空板K10 micropython 如何拍照保存? |
早就细细读了好多遍,但是唯独缺“micropython"拍照并保存的介绍,是“micropython拍照保存照片”不是图形化c语言。 应该是k10的bug!<div class="reference"><p><a href="https://mc.dfrobot.com.cn/home.php?mod=space&uid=825817&do=profile" target="_blank">木子呢</a> 2024-12-06 04:57:34<p><div class="quote">看下官方教程:https://wiki.dfrobot.com.cn/_SKU ... 7%A9%BA%E6%9D%BFK10</div></div> |
深邃蓝 发表于 2024-12-7 06:58 https://mp.weixin.qq.com/s?__biz ... 4504476088303617#rd引脚改成K10的引脚就行,其实micropython的东西很难所以很难出教程。刷官方的K10库固件即可 |
PY学习笔记 发表于 2024-12-15 14:49 WARNING:root:Unexpected echo. Expected b'\r\n', got b'ES' ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0x8 (TG1WDT_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT) Saved PC:0x403764db SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3820,len:0x105c load:0x403c9700,len:0x4 load:0x403c9704,len:0xbd8 load:0x403cc700,len:0x2e30 entry 0x403c989c W (26) boot.esp32s3: PRO CPU has been reset by WDT. W (26) boot.esp32s3: APP CPU has been reset by WDT. |
本帖最后由 深邃蓝 于 2024-12-17 09:00 编辑 import camera camera.deinit() # 释放camera try: camera.init(0, d0=8, d1=10, d2=11, d3=9, d4=18, d5=16, d6=15, d7=6, format=camera.JPEG, framesize=camera.FRAME_SVGA, xclk_freq=camera.XCLK_10MHz, href=5, vsync=4, reset=-1, pwdn=-1, sioc=48, siod=47, xclk=7, pclk=17) except Exception as e: camera.deinit() # 释放camera camera.init(0, d0=8, d1=10, d2=11, d3=9, d4=18, d5=16, d6=15, d7=6, format=camera.JPEG, framesize=camera.FRAME_SVGA, xclk_freq=camera.XCLK_10MHz, href=5, vsync=4, reset=-1, pwdn=-1, sioc=48, siod=47, xclk=7, pclk=17)#y2-d0 buf = camera.capture() with open('1.jpg','wb') as f: f.write(buf) print("拍照已完成") camera.deinit() # 释放camera #
|
import camera from microbmp import MicroBMP #https://github.com/jacklinquan/m ... ob/main/microbmp.py # 将 RGB565 转换为 RGB888 的函数 def RGB565_to_RGB888_array(rgb565_array, length, rgb888_array): for i in range(length): rgb565 = rgb565_array # 提取 RGB565 中的颜色分量 red = (rgb565 >> 11) & 0x1F # 5 bits green = (rgb565 >> 5) & 0x3F # 6 bits blue = rgb565 & 0x1F # 5 bits # 将颜色分量扩展到 8 位 r = (red << 3) | (red >> 2) # 5 bits to 8 bits g = (green << 2) | (green >> 4) # 6 bits to 8 bits b = (blue << 3) | (blue >> 2) # 5 bits to 8 bits # 将结果存储到 RGB888 数组 rgb888_array[i * 3] = r rgb888_array[i * 3 + 1] = g rgb888_array[i * 3 + 2] = b # 初始化摄像头 camera.init(0) # 捕获一帧画面 buf = camera.capture() # 创建 MicroBMP 实例 bmp = MicroBMP(width=640, height=480, depth=24) # 将 RGB565 数据转换为 RGB888 rgb888_array = bytearray(bmp.DIB_w * bmp.DIB_h * 3) # 初始化 RGB888 格式的像素数据数组 RGB565_to_RGB888_array(buf, len(buf) // 2, rgb888_array) # 将 RGB888 数据写入 MicroBMP 实例 for y in range(bmp.DIB_h): for x in range(bmp.DIB_w): idx = (y * bmp.DIB_w + x) * 3 bmp[x, y] = (rgb888_array[idx], rgb888_array[idx + 1], rgb888_array[idx + 2]) # 保存 BMP 文件 bmp.save("image.bmp") 试试这个 |
本帖最后由 深邃蓝 于 2025-1-6 16:49 编辑 PY学习笔记 发表于 2025-1-1 17:57 再次测试,运行可以,就是非常慢,要几分钟时间。 有没有办法加快速度? 感谢大佬。 |
© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed