-
Notifications
You must be signed in to change notification settings - Fork 4
Description
I am trying to upload a script that was developed by @AIWintermuteAI and posted here aXeleRate - Keras-Based Framework for AI on the Edge.
But there seems to be some issue where there is not an obvious error message that I can follow.
I have uploaded the latest firmware to the M.A.R.K from the Codecraft web interface and then tried to run the script posted below:
import sensor,image,lcd, os, time, utime
from maix_motor import Maix_motor
import KPU as kpu
def find_center():
img = sensor.snapshot()
img = img.resize(224,224)
img= img.rotation_corr(z_rotation=90.0)
a = img.pix_to_ai()
code = kpu.run_yolo2(task, img)
if code:
for i in code:
a=img.draw_rectangle(i.rect(),color = (0, 255, 0))
a = img.draw_string(i.x(),i.y(), classes[i.classid()], color=(255,0,0), scale=3)
x_center = i.x()+i.w()/2
print(x_center)
a = lcd.display(img)
return x_center
else:
a = lcd.display(img)
return -1
def scan_pan():
Maix_motor.motor_run(0, 0, 0)
Maix_motor.servo_angle(2, 110)
for i in range(0, 180, 5):
pos = find_center()
if pos >= 100 and pos <= 124:
Maix_motor.servo_angle(1, 90)
if i >= 90:
Maix_motor.motor_right(40, 0)
Maix_motor.motor_left(-40, 0)
utime.sleep_ms(((i - 90) * 12))
if i < 90:
Maix_motor.motor_right(-40, 0)
Maix_motor.motor_left(40, 0)
utime.sleep_ms(((90 - i) * 12))
Maix_motor.motor_motion(1, 1, 0)
time.sleep(0.3)
return True
else:
Maix_motor.servo_angle(1, i)
def scan_tilt():
#Maix_motor.motor_run(0, 0, 0)
Maix_motor.servo_angle(1, 90)
for i in range(100, 140, 2):
pos = find_center()
if pos > 0:
return True
else:
Maix_motor.servo_angle(2, i)
def scan_rotate():
Maix_motor.servo_angle(1, 90)
Maix_motor.servo_angle(2, 110)
Maix_motor.motor_motion(1, 3, 0)
while True:
pos = find_center()
if pos > 0:
break
lcd.init()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_vflip(1)
sensor.run(1)
Maix_motor.servo_angle(1, 90)
Maix_motor.servo_angle(2, 110)
DEBUG = 0
classes = ["person"]
task = kpu.load('/sd/model_people_end.kmodel')
a = kpu.set_outputs(task, 0, 7,7,30)
anchor = (0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828)
a = kpu.init_yolo2(task, 0.3, 0.3, 5, anchor)
while(True):
x_center = find_center()
if not DEBUG:
if x_center >= 100 and x_center <= 124: Maix_motor.motor_motion(1, 1, 0)
if x_center < 100 and x_center > 0: Maix_motor.motor_motion(1, 4, 0)
if x_center > 124: Maix_motor.motor_motion(1, 3, 0)
if x_center < 0:
if not scan_tilt():
scan_pan()
if not scan_pan():
scan_rotate()
a = kpu.deinit(task)
I have trained the kmodel placed it on the SD card with the correct filename and inserted into the CyberEye module.
I am able to connect to the board through MaixPy IDE but when trying to run the script the terminal displays the following before it automatically disconnects the serial port connection:
>>> init i2c:2 freq:100000
[MAIXPY]: find ov2640
[MAIXPY]: find ov sensor
Nothing is displayed on the lcd screen of the device except a black screen.
FYI as additional information: I have been able to upload other scripts to a seperate Maixduino device using MaixPy IDE. And have had the M.A.R.K kit working with code developed through the Codecraft graphical coding web interface such as the line following example using with the on board camera and object detection algorithm.
Is anyone able to assist in troubleshooting why this script isn't functioning?