logo

我电脑运行程序可以,但是脱机运行后就会卡住怎么回事?

2019-11-23 21:33
V
axql
# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

import sensor, image, time,pyb
from image import SEARCH_EX, SEARCH_DS
from pyb import UART
import ujson
import lcd

uart = UART(3, 19200)

sensor.reset()

# Set sensor settings
sensor.set_contrast(1)
sensor.set_gainceiling(16)
# Max resolution for template matching with SEARCH_EX is QQVGA
sensor.set_framesize(sensor.QQVGA)
# You can set windowing to reduce the search image.
#sensor.set_windowing(((640-80)//2, (480-60)//2, 80, 60))
sensor.set_pixformat(sensor.GRAYSCALE)
lcd.init()
led=pyb.LED(3)

templates1= ["/16.pgm","/161.pgm","/162.pgm"]  #正方形
templates2= ["/12.pgm","/121.pgm","/122.pgm"]  #五角星
templates3= ["/13.pgm","/131.pgm","/132.pgm"]  #n
templates4= ["/14.pgm","/141.pgm","/142.pgm"]  #三角形
templates5= ["/11.pgm","/111.pgm","/112.pgm"]  #圆
templates6= ["/15.pgm","/151.pgm","/152.pgm"]  #六边形

while(True):
    led.on()
    img = sensor.snapshot()         # Take a picture and return the image.
    lcd.display(sensor.snapshot())
    #x=str(10)
    #uart.write(x+'\r\n')
    #print(x)
    #time.sleep(1000)
    if(uart.any()):
        d=uart.readchar()-48
        #print(d)
        if d==1:
            print(d)
            for t in templates1:
                template = image.Image(t)
                r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
                if r:
                    img.draw_rectangle(r, color=0)
                    str1="16"
                    uart.write(str1+'\r\n')
                    print(str1)
                    time.sleep(2)
                    break
                else:
                    #print(2)
                    for t in templates2:
                        template = image.Image(t)
                        r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
                        if r:
                            img.draw_rectangle(r, color=0)
                            str1="12"
                            uart.write(str1+'\r\n')
                            print(str1)
                            time.sleep(2)
                            break
                        else:
                            #print(3)
                            for t in templates3:
                                template = image.Image(t)
                                r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
                                if r:
                                    img.draw_rectangle(r, color=0)
                                    str1="13"
                                    uart.write(str1+'\r\n')
                                    print(str1)
                                    time.sleep(2)
                                    break
                                else:
                                    #print(4)
                                    for t in templates4:
                                        template = image.Image(t)
                                        r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
                                        if r:
                                            img.draw_rectangle(r, color=0)
                                            str1="14"
                                            uart.write(str1+'\r\n')
                                            print(str1)
                                            time.sleep(2)
                                            break
                                        else:
                                            #print(5)
                                            for t in templates5:
                                                template = image.Image(t)
                                                r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
                                                if r:
                                                    img.draw_rectangle(r, color=0)
                                                    str1="11"
                                                    uart.write(str1+'\r\n')
                                                    print(str1)
                                                    time.sleep(2)
                                                    break
                                                else:
                                                    for t in templates6:
                                                        template = image.Image(t)
                                                        r = img.find_template(template, 0.70, step=4, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
                                                        if r:
                                                            img.draw_rectangle(r, color=0)
                                                            str1="15"
                                                            uart.write(str1+'\r\n')
                                                            print(str1)
                                                            time.sleep(2)
                                                            break
                                                        else:
                                                            str1="99"
                                                            uart.write(str1+'\r\n')
                                                            time.sleep(2)
                                                            break
                                                    break
                                            break
                                    break
                            break
                    break
2019-11-24 12:39
I
网红小智智 星瞳科技

什么叫做卡住?具体的现象是什么。

2024-07-22 10:11
5
懿欣尉茹

@kidswong999 运行一会后,画面卡住,不再运行程序,数据不再传输