Hi there, we are trying to send numbers from the cam to our arduino board via UART. However, testing with other code that we uploaded on the camera, they were able to run fine and we were able to receive stuff on the arduino board so there is probably no issue with the UART connection. However, when we uploaded this code through “Save Open Script to OpenMV Cam” we were not able to receive anything. Hope yall can look through the code. Thanks!
import sensor, image, pyb, time
from pyb import UART
#setup sensor
sensor.reset()
sensor.set_contrast(1)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
face_cascade = image.HaarCascade("frontalface", stages=25)
eyes_cascade = image.HaarCascade("eye", stages=24)
uart = pyb.UART(3, 115200)
while (True):
img = sensor.snapshot()
objects = img.find_features(face_cascade, threshold=0.9, scale=1.5)
for face in objects:
if face [2] in range (80,85) and face [1] in range (25,55) and face [0] in range (60,110): uart.write("4")
if face [1] in range (0,25) and face [0] in range (60,110): uart.write("0")
if face [1] in range (55,200) and face [0] in range (60,110): uart.write("2")
if face [0] in range (0,60) and face [1] in range (25,55): uart.write("3")
if face [0] in range (110, 200) and face [1] in range (25,55): uart.write("1")
time.sleep (500)