From 5f142516d948aec6f67836bb52ff4a8725950993 Mon Sep 17 00:00:00 2001 From: Mendelcollege Date: Wed, 21 May 2025 13:39:13 +0200 Subject: Update openMV.py --- code/main/openMV_cam/openMV.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'code/main/openMV_cam/openMV.py') diff --git a/code/main/openMV_cam/openMV.py b/code/main/openMV_cam/openMV.py index 73194c1..0fb36ac 100644 --- a/code/main/openMV_cam/openMV.py +++ b/code/main/openMV_cam/openMV.py @@ -1,18 +1,25 @@ -# blinky.py +import sensor, image, time -# This work is licensed under the MIT license. -# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved. -# https://github.com/openmv/openmv/blob/master/LICENSE -# -# Blinky example +thresholds = [(37, 69, -7, 20, -52, -35),# Thresholds for blue + (50, 68, -9, 7, 50, 63)]# Thresholds for yellow +x_data=0 +y_data=0 -import time -from machine import LED +sensor.reset() +sensor.set_pixformat(sensor.RGB565) +sensor.set_framesize(sensor.QVGA) +sensor.skip_frames(time = 2000) -led = LED("LED_BLUE") +clock = time.clock() -while True: - led.on() - time.sleep_ms(500) - led.off() - time.sleep_ms(500) +while(True): + clock.tick() + img = sensor.snapshot() + for blob in img.find_blobs(thresholds, pixels_threshold=200, area_threshold=200): + img.draw_rectangle(blob.rect()) + img.draw_cross(blob.cx(), blob.cy()) + x_data=blob.cx() + y_data=blob.cy() + print("fps=%d" % clock.fps()), + print(" x=%d" % x_data), + print(" y=%d" % y_data) -- cgit v1.2.3