示例#1
0
def get_feature(task):
    count = 20
    for i in range(3):
        for j in range(count):
            img = sensor.snapshot()
            if j < (count>>1):
                img.draw_rectangle(1,46,222,132,color=br.get_color(255,0,0),thickness=3)
            lcd.display(img)
    time.sleep(1.0)
    feature = kpu.forward(task,img)
    return feature
示例#2
0
def get_feature(task):
    count = 20
    for i in range(3):
        for j in range(count):
            img = sensor.snapshot()
            if j < (count>>1):
                br.set_led(1,0,0)
                img.draw_rectangle(1,46,222,132,color=br.get_color(255,0,0),thickness=3)
            else:
                br.set_led(0,0,0)
            br.show_image(img)
    time.sleep(1.0)
    feature = kpu.forward(task,img)
    return np.array(feature[:])
示例#3
0
def get_feature(task):
    count = 20
    print('get_feature 1')
    for i in range(3):
        print('get_feature 2-' + str(3 - i))
        br.play_sound("/sd/voice/" + str(3 - i) + "s.wav", vol)
        for j in range(count):
            img = sensor.snapshot()
            if j < (count >> 1):
                img.draw_rectangle(1,
                                   46,
                                   222,
                                   132,
                                   color=br.get_color(255, 0, 0),
                                   thickness=3)
            lcd.display(img)


#    print('get_feature 2')
#    time.sleep(1.0)
    print('get_feature 3')
    feature = kpu.forward(task, img)
    print('get_feature 4')
    return np.array(feature[:])
示例#4
0
        plist=fmap[:]
        clock.tick()
        if len(feature_0)>0 and len(feature_100)>0:
            p = plist
            f0 = feature_0[0]
            f100 = feature_100[0]
            dist = 100.0 * get_dist(f0[1],f100[1],p)
            dist_str = "%.1f"%(dist)
            print("[DISTANCE]: " + dist_str)
            img.draw_string(2,47,  dist_str,scale=3)
            lcd.display(img)
            continue
        name,dist = get_nearest(feature_list,plist)
        #print(clock.fps())
        if dist < 50 and name != "exclude":      #50 is modified from original value 200
            img.draw_rectangle(1,46,222,132,color=br.get_color(0,255,0),thickness=3)
            img.draw_string(2,47 +30,  "%s"%(name),scale=3)
            if old_name != name:
                namestring = str(name) + "\n"  #UART to StickC
                uart_Port.write(namestring)    #UART to StickC
                # print(name)                  #modified from original
                lcd.display(img)
                br.play_sound("/sd/voice/"+name+".wav")
                old_name = name
        else:
            old_name = ''

        # output
        img.draw_string(2,47,  "%.2f "%(dist),scale=3)
        lcd.display(img)
        kpu.fmap_free(fmap)
示例#5
0
            dist = 100.0 * get_dist(f0, f100, p)
            dist_str = "%.1f" % (dist)

            print("[DISTANCE]: " + dist_str)
            img.draw_string(2, 47, dist_str, scale=3)
            lcd.display(img)
            continue

        # get nearest target
        name, dist, _ = get_nearest(feature_list, p)
        if dist < 200 and name != "*exclude":
            img.draw_rectangle(1,
                               46,
                               222,
                               132,
                               color=br.get_color(0, 255, 0),
                               thickness=3)
            img.draw_string(2, 47 + 30, "%s" % (name), scale=3)
            if old_name != name:
                print("[DETECTED]: " + name)
                lcd.display(img)
                send_packet(name)
                #br.play_sound("/sd/voice/"+name+".wav")
                old_name = name
        else:
            old_name = ''

        # output
        img.draw_string(2, 47, "%.2f " % (dist), scale=3)
        lcd.display(img)
        kpu.fmap_free(fmap)