Hola, soy nuevo aquí, estoy tratando de implementar una red neuronal en la OpenMV Cam H7 para realizar un control de los motores de un robot, desearía saber que herramientas serian adecuadas de usar para obtener un desarrollo más optimo en mi proyecto.
las características del proyecto son:
identificar tipos de líneas y tomar una decisión para que el robot pueda activar la velocidad de cada motor y seguir la trayectoria de la misma.
muchas gracias, estoy atento a sus sugerencias y opiniones.
Please use Edge Impulse to develop a CNN.
Saludos, intente ejecutar el modelo en el dispositivo, y tengo el siguiente error:
memoryerror: Out of fast Frame Buffer Stack Memory! Please reduce the resolution of the image you are running this algorithm on to bypass issue!
Trate de hacer el ejemplo en la documentación de Edge impulse, seguí los pasos pero al momento de correr el programa aparece dicho error.
¿Cuales son los consejos a tener en cuenta?. Probé todas las resoluciones y tengo el mismo error.
gracias por la ayuda.
me encanta mucho este dispositivo tiene muchas aplicaciones interesantes.
Hi, if you have the original H7 and not the H7 Plus you just need to shrink the network input size.
When creating the network, make a 48x48 pixel input network versus a larger 96x96 network. This will shrink then model enough for it to run on the H7.
logre solucionar el error de memoria, pero ahora tengo un problema al momento de ejecutar el control a los motores, un motor se queda moviendo siempre en una dirección, en cambio el otro ejecuta correctamente las instrucciones, ¿Cuál podría ser el problema?. Aquí dejo el código el cual estoy desarrollando. muchas gracias por la atención.
import sensor, image, time, os, tf, lcd, pyb
from tb6612 import Motor
m1 = Motor(1) # motor 1: A0 and A1
m2 = Motor(2) # motor 2: B0 and B1
thresholds = (220, 255)
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((240, 240))
sensor.skip_frames(time=2000)
lcd.init()
net = "trained.tflite"
labels = [line.rstrip('\n') for line in open("labels.txt")]
clock = time.clock()
m1.set_speed(0) # stop
m2.set_speed(0) # stop
while(True):
clock.tick()
img = sensor.snapshot()
y=img.draw_line((120,0,120,240),color=(200,0,0))
x=img.draw_line((0,120,320,120),color=(200,0,0))
blobs = img.binary([(0,80)]).find_blobs([thresholds], pixels_threshold=10, area_threshold=10, merge=True)
lcd.display(img)
# default settings just do one detection... change them to search the image...
for obj in tf.classify(net, img, min_scale=1.0, scale_mul=0.8, x_overlap=0.5, y_overlap=0.5):
print("**********\nPredictions at [x=%d,y=%d,w=%d,h=%d]" % obj.rect())
img.draw_rectangle(obj.rect())
# This combines the labels and confidence values into a list of tuples
predictions_list = list(zip(labels, obj.output()))
for i in range(len(predictions_list)):
print("%s = %f" % (predictions_list[i][0], predictions_list[i][1]))
m1.set_speed(0) # Forward
m2.set_speed(0) # Forward
if predictions_list[i][1] > 0.6:
m1.set_speed(10) # Forward
m2.set_speed(10) # Forward
else:
m1.set_speed(0) # stop
m2.set_speed(0) # stop
I think you can create only one motor at a time using that code. Instead of using that code… use the pyb module directly:
tim = pyb.Timer(4, freq=1000)
class Motor():
def __init__(self, channel):
if channel == 1:
self.pin1 = pyb.Pin('P3', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)
self.pin2 = pyb.Pin('P2', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)
self.power = tim.channel(1, pyb.Timer.PWM, pin=pyb.Pin("P7"), pulse_width_percent=0)
elif channel == 2:
self.pin1 = pyb.Pin('P1', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)
self.pin2 = pyb.Pin('P0', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)
self.power = tim.channel(2, pyb.Timer.PWM, pin=pyb.Pin("P8"), pulse_width_percent=0)
def set_speed(self, pwm):
if pwm < 0:
self.pin1.low()
self.pin2.high()
else:
self.pin1.high()
self.pin2.low()
self.power.pulse_width_percent(abs(pwm))
Include the above in your code instead of the tb6612.
Things should work then.