Exemple #1
0
    def main(startwert):
        global datei
        startwert = startwert
        trainings_bilder = []
        trainings_steuerung = []
        bilder = 0
        datei = open(startwert)
        for i in list(range(6))[::-1]:
            print(i + 1)
            time.sleep(1)

        paused = False
        closed = False
        newfile = False
        while not closed:
            if not paused:
                bild = grab_screen()
                bild = cv2.resize(bild, (int(nn_width), int(nn_height)))
                bild = cv2.cvtColor(bild, cv2.COLOR_BGR2RGB)

                tasten = key_check()
                ausgabe = tasten_ausgabe(tasten)
                trainings_bilder.append(bild)
                trainings_steuerung.append(ausgabe)

                if len(trainings_bilder) % 50 == 0:
                    bilder = int(bilder) + 50
                    print("Speichere Daten in Datei {}, Länge insgesamt: {}".
                          format(str(startwert), str(bilder)))
                    threading.Thread(target=speichern,
                                     args=(trainings_bilder,
                                           trainings_steuerung)).start()
                    trainings_bilder = []
                    trainings_steuerung = []
                    newfile = False

                if bilder > 0 and bilder % 10000 == 0 and newfile is False:
                    startwert = int(startwert) + 1
                    print("Länge: 10000, erstelle neue Datei ({})".format(
                        str(startwert)))
                    datei = open(startwert)
                    newfile = True

                time.sleep(0.01)

            keys = key_check()

            if 'T' in keys:
                if paused:
                    paused = False
                    time.sleep(1)
                else:
                    paused = True
                    time.sleep(1)

            if 'C' in keys:
                closed = True
                datei.close()
                time.sleep(1)
                sys.exit()
Exemple #2
0
def run(screen_width, screen_height, dateiname):
    def tasten_ausgabe(tasten):
        #[A,W,D]
        ausgabe = [0, 0, 0]
        if "A" in tasten:
            ausgabe[0] = '1'
        elif "D" in tasten:
            ausgabe[2] = '1'
        elif "W" in tasten:
            ausgabe[1] = '1'
        else:
            ausgabe = [0, 0, 0]

        return ausgabe

    if os.path.isfile(dateiname):
        print("Trainingsdaten existieren bereits, lade vorhandene Daten...")
        trainingsdaten = list(np.load(dateiname))
    else:
        print("Keine Trainingsdaten existieren.")
        trainingsdaten = []

    for i in list(range(10))[::-1]:
        print(i + 1)
        time.sleep(1)

    paused = False

    while True:
        if not paused:
            bild = bild_erfassen(region=(0, 30, int(screen_width),
                                         int(screen_height) + 26))
            bild = cv2.cvtColor(bild, cv2.COLOR_BGR2GRAY)
            #bild = cv2.resize(bild, (int(int(screen_width)/10),int(int(screen_height)/10)))
            bild = cv2.resize(bild, (80, 60))
            tasten = key_check()
            ausgabe = tasten_ausgabe(tasten)
            if ausgabe != [0, 0, 0]:
                trainingsdaten.append([bild, ausgabe])

            if len(trainingsdaten) % 500 == 0:
                print("100%, speichere...")
                np.save(dateiname, trainingsdaten)

            keys = key_check()

        if 'T' in keys:
            if paused:
                paused = False
                time.sleep(1)
            else:
                paused = True
                time.sleep(1)
Exemple #3
0
    def main(dateiname, startwert):

        dateiname = dateiname
        startwert = startwert
        trainingsdaten = []
        for i in list(range(10))[::-1]:
            print(i + 1)
            time.sleep(1)

        paused = False
        while (True):
            if not paused:
                bild = bild_erfassen(region=(0, 30, int(screen_width),
                                             int(screen_height) + 26))
                bild = cv2.resize(bild, (int(nn_width), int(nn_height)))
                bild = cv2.cvtColor(bild, cv2.COLOR_BGR2RGB)

                tasten = key_check()
                ausgabe = tasten_ausgabe(tasten)
                trainingsdaten.append([bild, ausgabe])

                if len(trainingsdaten) % 100 == 0:
                    print("Länge der Trainingsdaten: " +
                          str(len(trainingsdaten)))

                    if len(trainingsdaten) == 4000:
                        print("Länge: " + str(len(trainingsdaten)) +
                              ", speichere...")
                        np.save(dateiname, trainingsdaten)
                        trainingsdaten = []
                        startwert = int(startwert) + 1
                        dateiname = "trainingsdaten-{}.npy".format(startwert)

            keys = key_check()

            if 'T' in keys:
                if paused:
                    paused = False
                    time.sleep(1)
                else:
                    paused = True
                    time.sleep(1)
def run(width, height, learning_rate, epochs):
    for i in range(1, 10):
        check_model = "car-{}-{}-{}.model".format(str(i), str(learning_rate),
                                                  str(epochs))
        if os.path.isfile(check_model):
            print("Model existiert bereits: " + str(check_model))
        else:
            model_name = "car-{}-{}-{}.model".format(str(i),
                                                     str(learning_rate),
                                                     str(epochs))
            return model_name
    nn_width = int(width) / 2
    nn_height = int(height) / 2
    t_time = 0.09

    def geradeaus():
        PressKey(W)
        ReleaseKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    def links():
        if random.randrange(0, 3) == 1:
            PressKey(W)
        else:
            ReleaseKey(W)
        PressKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    def rechts():
        if random.randrange(0, 3) == 1:
            PressKey(W)
        else:
            ReleaseKey(W)
        PressKey(D)
        ReleaseKey(A)
        ReleaseKey(S)

    def zurücksetzen():
        PressKey(S)
        ReleaseKey(W)
        ReleaseKey(A)
        ReleaseKey(D)

    def geradeaus_links():
        PressKey(W)
        PressKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    def geradeaus_rechts():
        PressKey(W)
        PressKey(D)
        ReleaseKey(A)
        ReleaseKey(S)

    def zurücksetzen_links():
        PressKey(S)
        PressKey(A)
        ReleaseKey(W)
        ReleaseKey(D)

    def zurücksetzen_rechts():
        PressKey(S)
        PressKey(D)
        ReleaseKey(W)
        ReleaseKey(A)

    def nichts():
        if random.randrange(0, 3) == 1:
            PressKey(W)
        else:
            ReleaseKey(W)
        ReleaseKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    model = alexnet(int(nn_width), int(nn_height), float(learning_rate))
    model.load(model_name)

    for i in list(range(6))[::-1]:
        print(i + 1)
        time.sleep(1)

    paused = False

    while True:
        if not paused:
            bild = bild_erfassen(region=(0, 30, int(width), int(height) + 26))
            bild = cv2.cvtColor(bild, cv2.COLOR_BGR2RGB)
            nn_width = int(width) / 2
            nn_height = int(height) / 2
            bild = cv2.resize(bild, (int(nn_width), int(nn_height)))

            vorhersage = model.predict(
                [bild.reshape(int(nn_width), int(nn_height), 3)])[0]
            vorhersage = np.array(vorhersage) * np.array(
                [4.5, 0.1, 0.1, 0.1, 1.8, 1.8, 0.5, 0.5, 0.2])
            print(vorhersage)
            auswahl = np.argmax(vorhersage)

            if auswahl == 0:
                geradeaus()
                auswahl_getroffen = "Geradeaus"
            elif auswahl == 1:
                zurücksetzen()
                auswahl_getroffen = "Zurücksetzen"
            elif auswahl == 2:
                links()
                auswahl_getroffen = "Links"
            elif auswahl == 3:
                rechts()
                auswahl_getroffen = "Rechts"
            elif auswahl == 4:
                geradeaus_links()
                auswahl_getroffen = "Geradeaus + Links"
            elif auswahl == 5:
                geradeaus_rechts()
                auswahl_getroffen = "Geradeaus + Rechts"
            elif auswahl == 6:
                zurücksetzen_links()
                auswahl_getroffen = "Zurücksetzen + Links"
            elif auswahl == 7:
                zurücksetzen_rechts()
                auswahl_getroffen = "Zurücksetzen + Rechts"
            elif auswahl == 8:
                nichts()
                auswahl_getroffen = "Nichts"

            print(auswahl_getroffen)

        keys = key_check()

        if 'T' in keys:
            if paused:
                paused = False
                time.sleep(1)
            else:
                paused = True
                ReleaseKey(A)
                ReleaseKey(W)
                ReleaseKey(D)
                ReleaseKey(S)
                time.sleep(1)
Exemple #5
0
else:
    print("Keine Trainingsdaten existieren.")
    trainingsdaten = []

for i in list(range(6))[::-1]:
    print(i + 1)
    time.sleep(1)

paused = False

while True:
    if not paused:
        bild = bild_erfassen(region=(0, 30, 800, 626))
        bild = cv2.cvtColor(bild, cv2.COLOR_BGR2GRAY)
        bild = cv2.resize(bild, (80, 60))
        tasten = key_check()
        ausgabe = tasten_ausgabe(tasten)
        if ausgabe != [0, 0, 0]:
            trainingsdaten.append([bild, ausgabe])

        if len(trainingsdaten) % 500 == 0:
            print("100%, speichere...")
            np.save(dateiname, trainingsdaten)

        keys = key_check()

    if 'T' in keys:
        if paused:
            paused = False
            time.sleep(1)
        else:
def run(width, height, learning_rate, epochs):
    model_name = "car-{}-{}-{}-epochs.model".format(float(learning_rate),
                                                    "alexnet", int(epochs))
    nn_width = int(width) / 10
    nn_height = int(height) / 10
    t_time = 0.09

    def geradeaus():
        PressKey(W)
        ReleaseKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    def links():
        if random.randrange(0, 3) == 1:
            PressKey(W)
        else:
            ReleaseKey(W)
        PressKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    def rechts():
        if random.randrange(0, 3) == 1:
            PressKey(W)
        else:
            ReleaseKey(W)
        PressKey(D)
        ReleaseKey(A)
        ReleaseKey(S)

    def zurücksetzen():
        PressKey(S)
        ReleaseKey(W)
        ReleaseKey(A)
        ReleaseKey(D)

    def geradeaus_links():
        PressKey(W)
        PressKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    def geradeaus_rechts():
        PressKey(W)
        PressKey(D)
        ReleaseKey(A)
        ReleaseKey(S)

    def zurücksetzen_links():
        PressKey(S)
        PressKey(A)
        ReleaseKey(W)
        ReleaseKey(D)

    def zurücksetzen_rechts():
        PressKey(S)
        PressKey(D)
        ReleaseKey(W)
        ReleaseKey(A)

    def nichts():
        if random.randrange(0, 3) == 1:
            PressKey(W)
        else:
            ReleaseKey(W)
        ReleaseKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    model = alexnet(int(nn_width), int(nn_height), float(learning_rate))
    model.load(model_name)

    for i in list(range(6))[::-1]:
        print(i + 1)
        time.sleep(1)

    paused = False

    while True:
        if not paused:
            bild = bild_erfassen(region=(0, 30, int(width), int(height) + 26))
            bild = cv2.cvtColor(bild, cv2.COLOR_BGR2GRAY)
            nn_width = int(width) / 10
            nn_height = int(height) / 10
            bild = cv2.resize(bild, (int(nn_width), int(nn_height)))

            vorhersage = model.predict(
                [bild.reshape(int(nn_width), int(nn_height), 1)])[0]
            vorhersage = np.array(vorhersage)
            print(vorhersage)
            auswahl = np.argmax(vorhersage)

            if auswahl == 0:
                geradeaus()
                auswahl_getroffen = "Geradeaus"
            elif auswahl == 1:
                zurücksetzen()
                auswahl_getroffen = "Zurücksetzen"
            elif auswahl == 2:
                links()
                auswahl_getroffen = "Links"
            elif auswahl == 3:
                rechts()
                auswahl_getroffen = "Rechts"
            elif auswahl == 4:
                geradeaus_links()
                auswahl_getroffen = "Geradeaus + Links"
            elif auswahl == 5:
                geradeaus_rechts()
                auswahl_getroffen = "Geradeaus + Rechts"
            elif auswahl == 6:
                zurücksetzen_links()
                auswahl_getroffen = "Zurücksetzen + Links"
            elif auswahl == 7:
                zurücksetzen_rechts()
                auswahl_getroffen = "Zurücksetzen + Rechts"
            elif auswahl == 8:
                nichts()
                auswahl_getroffen = "Nichts"

            print(auswahl_getroffen)

        keys = key_check()

        if 'T' in keys:
            if paused:
                paused = False
                time.sleep(1)
            else:
                paused = True
                ReleaseKey(A)
                ReleaseKey(W)
                ReleaseKey(D)
                ReleaseKey(S)
                time.sleep(1)
Exemple #7
0
        ausgabe[1] = '1'
    else:
        pass

    return ausgabe

dateiname="trainingsdaten.npy"

if os.path.isfile(dateiname):
    print("Trainingsdaten existieren bereits, lade vorhandene Daten...")
    trainingsdaten = list(np.load(dateiname)) 
else:
    print("Keine Trainingsdaten existieren.")
    trainingsdaten = []

for i in list(range(6))[::-1]:
    print(i+1)
    time.sleep(1)
    
while True:
    bild = bild_erfassen(region=(0,30,800,626))
    bild = cv2.cvtColor(bild, cv2.COLOR_BGR2GRAY)
    bild = cv2.resize(bild, (80,60))
    tasten = key_check()
    ausgabe = tasten_ausgabe(tasten)
    trainingsdaten.append([bild, ausgabe])
    if len(trainingsdaten) % 500 == 0:
        print("100%, speichere...")
        np.save(dateiname, trainingsdaten)
        
Exemple #8
0
def run(screen_width, screen_height, dateiname):
    def tasten_ausgabe(tasten):
        #[W,A,S,D,WA,WD,SA,SD,nokey]
        ausgabe = [0, 0, 0, 0, 0, 0, 0, 0, 0]
        if "W" in tasten:
            ausgabe = [1, 0, 0, 0, 0, 0, 0, 0, 0]
        elif "S" in tasten:
            ausgabe = [0, 1, 0, 0, 0, 0, 0, 0, 0]
        elif "A" in tasten:
            ausgabe = [0, 0, 1, 0, 0, 0, 0, 0, 0]
        elif "D" in tasten:
            ausgabe = [0, 0, 0, 1, 0, 0, 0, 0, 0]
        elif "W" in tasten and "A" in tasten:
            ausgabe = [0, 0, 0, 0, 1, 0, 0, 0, 0]
        elif "W" in tasten and "D" in tasten:
            ausgabe = [0, 0, 0, 0, 0, 1, 0, 0, 0]
        elif "S" in tasten and "A" in tasten:
            ausgabe = [0, 0, 0, 0, 0, 0, 1, 0, 0]
        elif "S" in tasten and "D" in tasten:
            ausgabe = [0, 0, 0, 0, 0, 0, 0, 1, 0]
        else:
            ausgabe = [0, 0, 0, 0, 0, 0, 0, 0, 1]

        return ausgabe

    if os.path.isfile(dateiname):
        print("Trainingsdaten existieren bereits, lade vorhandene Daten...")
        trainingsdaten = list(np.load(dateiname))
    else:
        print("Keine Trainingsdaten existieren.")
        trainingsdaten = []

    for i in list(range(10))[::-1]:
        print(i + 1)
        time.sleep(1)

    paused = False

    while True:
        if not paused:
            bild = bild_erfassen(region=(0, 30, int(screen_width),
                                         int(screen_height) + 26))
            bild = cv2.cvtColor(bild, cv2.COLOR_BGR2GRAY)
            nn_width = int(screen_width) / 10
            nn_height = int(screen_height) / 10
            bild = cv2.resize(bild, (int(nn_width), int(nn_height)))
            tasten = key_check()
            ausgabe = tasten_ausgabe(tasten)
            trainingsdaten.append([bild, ausgabe])

            if len(trainingsdaten) % 500 == 0:
                print(str(len(trainingsdaten)) + " , speichere...")
                np.save(dateiname, trainingsdaten)
            if len(trainingsdaten) == 20001:
                sys.exit()

            keys = key_check()

        if 'T' in keys:
            if paused:
                paused = False
                time.sleep(1)
            else:
                paused = True
                time.sleep(1)
def run(width, height, learning_rate, epochs):
    width = 80
    height = 60
    learning_rate = 1E-3
    epoch = 10
    model_name = "car-{}-{}-{}-epochs.model".format(float(learning_rate),
                                                    "alexnet", int(epochs))

    t_time = 0.09

    def geradeaus():
        PressKey(W)
        ReleaseKey(A)
        ReleaseKey(D)

    def links():
        PressKey(W)
        PressKey(A)
        ReleaseKey(D)
        time.sleep(t_time)
        ReleaseKey(A)

    def rechts():
        PressKey(W)
        PressKey(D)
        ReleaseKey(A)
        time.sleep(t_time)
        ReleaseKey(D)

    def chill():
        ReleaseKey(W)
        ReleaseKey(A)
        ReleaseKey(D)

    model = alexnet(int(width), int(height), float(learning_rate))
    model.load(model_name)

    for i in list(range(6))[::-1]:
        print(i + 1)
        time.sleep(1)

    paused = False

    while True:
        if not paused:
            bild = bild_erfassen(region=(0, 30, 800, 626))
            bild = cv2.cvtColor(bild, cv2.COLOR_BGR2GRAY)
            bild = cv2.resize(bild, (int(width), int(height)))

            vorhersage = model.predict(
                [bild.reshape(int(width), int(height), 1)])[0]
            #moves = list(np.around(vorhersage))
            print(vorhersage)

            turn_thresh = 0.75
            forward_thresh = 0.70

            if vorhersage[1] > forward_thresh:
                geradeaus()
            elif vorhersage[0] > turn_thresh:
                links()
            elif vorhersage[2] > turn_thresh:
                rechts()
            elif vorhersage[0] < 0.1 and vorhersage[1] < 0.1 and vorhersage[
                    2] < 0.1:
                chill()
            else:
                geradeaus()

    ##        if moves == [1, 0, 0]:
    ##            links()
    ##        elif moves == [0, 1, 0]:
    ##            geradeaus()
    ##        elif moves == [0, 0, 1]:
    ##            rechts()

        keys = key_check()

        if 'T' in keys:
            if paused:
                paused = False
                time.sleep(1)
            else:
                paused = True
                ReleaseKey(A)
                ReleaseKey(W)
                ReleaseKey(D)
                time.sleep(1)
Exemple #10
0
def run(width, height, learning_rate, epochs):
    model_id = 1
    nn_width = int(width) / 2
    nn_height = int(height) / 2
    output_size = 9

    model_name = "model{}-{}_lr-{}_epochs".format(str(model_id),
                                                  float(learning_rate),
                                                  str(epochs))

    def geradeaus():
        PressKey(W)
        ReleaseKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    def links():
        if random.randrange(0, 3) == 1:
            PressKey(W)
        else:
            ReleaseKey(W)
        PressKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    def rechts():
        if random.randrange(0, 3) == 1:
            PressKey(W)
        else:
            ReleaseKey(W)
        PressKey(D)
        ReleaseKey(A)
        ReleaseKey(S)

    def zurücksetzen():
        PressKey(S)
        ReleaseKey(W)
        ReleaseKey(A)
        ReleaseKey(D)

    def geradeaus_links():
        PressKey(W)
        PressKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    def geradeaus_rechts():
        PressKey(W)
        PressKey(D)
        ReleaseKey(A)
        ReleaseKey(S)

    def zurücksetzen_links():
        PressKey(S)
        PressKey(A)
        ReleaseKey(W)
        ReleaseKey(D)

    def zurücksetzen_rechts():
        PressKey(S)
        PressKey(D)
        ReleaseKey(W)
        ReleaseKey(A)

    def nichts():
        if random.randrange(0, 4) == 1:
            PressKey(W)
        else:
            ReleaseKey(W)
        ReleaseKey(A)
        ReleaseKey(D)
        ReleaseKey(S)

    model = inception3(int(nn_width),
                       int(nn_height),
                       float(learning_rate),
                       output=int(output_size))
    model.load(model_name)

    for i in list(range(6))[::-1]:
        print(i + 1)
        time.sleep(1)

    paused = False

    while True:
        if not paused:
            bild = bild_erfassen(region=(0, 30, int(width), int(height) + 26))
            bild = cv2.cvtColor(bild, cv2.COLOR_BGR2RGB)
            bild = cv2.resize(bild, (int(nn_width), int(nn_height)))
            #cv2.imshow("test", bild)
            #time.sleep(0.09)

            vorhersage = model.predict(
                [bild.reshape(int(nn_width), int(nn_height), 3)])[0]
            vorhersage = np.array(vorhersage) * np.array(
                [0.3, 0.9, 2.8, 2.8, 1.5, 1.5, 0.5, 0.5, 0.7])
            #print(vorhersage)
            auswahl = np.argmax(vorhersage)

            if auswahl == 0:
                geradeaus()
                auswahl_getroffen = "Geradeaus"
            elif auswahl == 1:
                zurücksetzen()
                auswahl_getroffen = "Zurücksetzen"
            elif auswahl == 2:
                links()
                auswahl_getroffen = "Links"
            elif auswahl == 3:
                rechts()
                auswahl_getroffen = "Rechts"
            elif auswahl == 4:
                geradeaus_links()
                auswahl_getroffen = "Geradeaus + Links"
            elif auswahl == 5:
                geradeaus_rechts()
                auswahl_getroffen = "Geradeaus + Rechts"
            elif auswahl == 6:
                zurücksetzen_links()
                auswahl_getroffen = "Zurücksetzen + Links"
            elif auswahl == 7:
                zurücksetzen_rechts()
                auswahl_getroffen = "Zurücksetzen + Rechts"
            elif auswahl == 8:
                nichts()
                auswahl_getroffen = "Nichts"

            print(auswahl_getroffen)

##            if cv2.waitKey(15) & 0xFF == ord("q"):
##                cv2.destroyAllWindows()
##                break

        keys = key_check()

        if 'T' in keys:
            if paused:
                paused = False
                time.sleep(1)
            else:
                paused = True
                ReleaseKey(A)
                ReleaseKey(W)
                ReleaseKey(D)
                ReleaseKey(S)
                time.sleep(1)
Exemple #11
0
def run(learning_rate, epochs, model_id):
    # Breite des Neural Networks
    nn_width = 480
    # Höhe des Neural Networks
    nn_height = 270
    # Größe des Outputs (Standart: 9)
    output_size = 9
    # Modelname mit ID, Lernrate und Epochen
    model_name = "model{}-{}_lr-{}_epochs.model".format(str(model_id), float(learning_rate), str(epochs))
    # Inception Model erstellen
    model = inception3(int(nn_width), int(nn_height), float(learning_rate), output=int(output_size))
    # Laden des trainierten Models
    model.load(model_name)

    for i in list(range(6))[::-1]:
        print(i+1)
        time.sleep(1)

    paused = False

    while True:
        if not paused:
            bild = grab_screen()
            bild = cv2.cvtColor(bild, cv2.COLOR_BGR2RGB)
            bild = cv2.resize(bild, (int(nn_width), int(nn_height)))
            cv2.imshow("test", bild)
            time.sleep(0.09)

            vorhersage = model.predict([bild.reshape(int(nn_width), int(nn_height), 3)])[0]
            vorhersage = np.array(vorhersage)  # * np.array([0.3, 0.9, 4, 4, 1.5, 1.5, 0.5, 0.5, 0.7])
            auswahl = np.argmax(vorhersage)

            if auswahl == 0:
                geradeaus()
                auswahl_getroffen = "Geradeaus, mit {}% Sicherheit".format(float(vorhersage[0]) * 100)
            elif auswahl == 1:
                zurücksetzen()
                auswahl_getroffen = "Zurücksetzen, mit {}% Sicherheit".format(float(vorhersage[1]) * 100)
            elif auswahl == 2:
                links()
                auswahl_getroffen = "Links, mit {}% Sicherheit".format(float(vorhersage[2]) * 100)
            elif auswahl == 3:
                rechts()
                auswahl_getroffen = "Rechts, mit {}% Sicherheit".format(float(vorhersage[3]) * 100)
            elif auswahl == 4:
                geradeaus_links()
                auswahl_getroffen = "Geradeaus + Links, mit {}% Sicherheit".format(float(vorhersage[4]) * 100)
            elif auswahl == 5:
                geradeaus_rechts()
                auswahl_getroffen = "Geradeaus + Rechts, mit {}% Sicherheit".format(float(vorhersage[5]) * 100)
            elif auswahl == 6:
                zurücksetzen_links()
                auswahl_getroffen = "Zurücksetzen + Links, mit {}% Sicherheit".format(float(vorhersage[6]) * 100)
            elif auswahl == 7:
                zurücksetzen_rechts()
                auswahl_getroffen = "Zurücksetzen + Rechts, mit {}% Sicherheit".format(float(vorhersage[7]) * 100)
            elif auswahl == 8:
                nichts()
                auswahl_getroffen = "Keine Aktion, mit {}% Sicherheit".format(float(vorhersage[8]) * 100)

            print(auswahl_getroffen)

            if cv2.waitKey(15) & 0xFF == ord("q"):
                cv2.destroyAllWindows()
                break

        keys = key_check()

        if 'T' in keys:
            if paused:
                paused = False
                time.sleep(1)
            else:
                paused = True
                nichts()
                time.sleep(1)
Exemple #12
0
            geradeaus()
        elif vorhersage[0] > turn_thresh:
            links()
        elif vorhersage[2] > turn_thresh:
            rechts()
        elif vorhersage[0] < 0.1 and vorhersage[1] < 0.1 and vorhersage[
                2] < 0.1:
            chill()
        else:
            geradeaus()

##        if moves == [1, 0, 0]:
##            links()
##        elif moves == [0, 1, 0]:
##            geradeaus()
##        elif moves == [0, 0, 1]:
##            rechts()

    keys = key_check()

    if 'T' in keys:
        if paused:
            paused = False
            time.sleep(1)
        else:
            paused = True
            ReleaseKey(A)
            ReleaseKey(W)
            ReleaseKey(D)
            time.sleep(1)