使用 micropython 将 ESP32-CAM 拍摄的照片在后端处理返回结果_micropython中的camera有没有处理图片的库

该博客探讨如何使用 MicroPython 在 ESP32-CAM 上拍摄照片,并通过后端进行图像处理。利用Flask创建API,接收并处理图片数据,将结果回传。同时,介绍了图形用户界面与图片的交互,包括发送最新照片到前端显示。
摘要由CSDN通过智能技术生成
led_pin.value(1)
while not camera.init(0):
    time.sleep(1)
frame = camera.capture()
camera.deinit()
led_pin.value(0)
led_blink_timed(timer, red_pin, state='READY')
r = requests.post(flask_url, headers = {'content-type': 'image/jpeg'}, data = frame)
return r.json(), 200, {'Content-Type': 'application/json'}

请求后端处理的结果回传值

def parse_image():

url = "http://172.20.10.6:5000/send_result"
r = requests.get(url)
print(r.json())
response = r.json()

# 合格判别

if response["quilties"] == "apple":
    buzzer_pin.value(0)

if response["quilties"] == "bad_apple":
    buzzer_pin.value(1)

if name == ‘main’:

# 每隔5秒拍张照片
while True:
    
    print("发送照片")
    image_upload()
    print("**********")
    print("处理照片")
    parse_image()
    print("**********")
    time.sleep(5)

注:后端回传的结果为JSON格式,合格判别的规则是,如果苹果的质量为坏苹果(有斑点),则蜂鸣器警报,反之蜂鸣器则不发生警报。


#### 图像识别程序:


**苹果质量检测**  
  
 设置文件名为"qulityApple"



import cv2
import os

def detect_spots():

maxnum = []
picturePath = './fruits_photos'
for fi in os.listdir(picturePath):
    if fi.endswith(".jpg"):
        maxnum.append(int(fi[0:10]))

maxPhoto = max(maxnum)
# print(max(maxnum))
path = "./fruits_photos/" + "0" + str(maxPhoto) + ".jpg"

# 读取图片
image = cv2.imread(path)

# 转换为灰度图像
gray = cv2.cvtColor(image, cv2.COLOR_BGR2
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值