コード例 #1
0
def update_take():
    global database
    global cur_type_of_clothes
    global cur_color
    if request.method == "POST":
        # here I will update the database
        angle = db.find_clothes_angle(database, cur_type_of_clothes, cur_color)
        db.take_from_database(database, angle)
        cur_type_of_clothes = next_type_of_clothes
        cur_color = next_color

        angle = db.find_clothes_angle(database, cur_type_of_clothes, cur_color)
        if angle != -1:
            setCurAngle(angle)
            return redirect(url_for('update_take2'))
        else:
            print(
                "couldn't find the clothes for the bottom clothing for some reason"
            )
            return redirect(url_for('home'))

        return redirect(url_for('update_take2'))

    else:
        print("going to update_take.html")
        return render_template("update_take.html")
コード例 #2
0
def remove():
    global cur_type_of_clothes
    global cur_color

    if request.method == "POST":
        # Here the user will decide what clothes they would like to remove
        temp = request.form.getlist("remove")

        split_index = temp[0].find(")")
        cur_color_temp = temp[0][:split_index + 1]
        cur_color = db.convert_string_to_tuple(cur_color_temp)
        cur_type_of_clothes = temp[0][split_index + 2:]

        print("cur type of clothes is" + cur_type_of_clothes)
        angle = db.find_clothes_angle(database, cur_type_of_clothes, cur_color)
        if angle != -1:
            setCurAngle(angle)
            return redirect(url_for('update_remove'))
        else:
            print("couldn't find the clothes for some reason")
            return redirect(url_for('home'))

    else:
        print("going to remove.html")
        return render_template("remove.html", datab=database)
コード例 #3
0
def update_take2():
    global database
    if request.method == "POST":
        # here I will update the database
        angle = db.find_clothes_angle(database, cur_type_of_clothes, cur_color)
        db.take_from_database(database, angle)
        return redirect(url_for('home'))

    else:
        print("going to update_take2.html")
        return render_template("update_take2.html")
コード例 #4
0
def update_remove():
    global database
    if request.method == "POST":
        # here I will update the database
        angle = db.find_clothes_angle(database, cur_type_of_clothes, cur_color)
        if angle != -1:
            db.remove_from_database(database, angle)
        else:
            print("this clothes can't be found from database")
        return redirect(url_for('home'))

    else:
        print("going to update_remove.html")
        return render_template("update_remove.html")
コード例 #5
0
def show_take():
    global cur_type_of_clothes
    global cur_color
    global global_clothes_information
    global next_type_of_clothes
    global next_color

    if request.method == "POST":
        temp_0 = request.form.getlist("mycheckbox")
        print("temp_0 is")
        print(temp_0)
        temp = temp_0[0]
        print("temp is")
        print(temp)
        parse_index_0 = temp.find("/")
        parse_index_1 = temp.find("/", parse_index_0 + 1)
        parse_index_2 = temp.find(".")
        temp_index = int(temp[parse_index_1 + 1:parse_index_2])
        print(temp_index)

        # might need to use this one
        #temp = request.form.getlist("correct")
        temp_combination = global_clothes_information[temp_index]
        print(temp_combination)
        # now temp combination will contain the information about the clothes combination
        # we expect temp combination to be in this form
        # (("Tee", "Tee", "Tee", "Tee", "Tee",(0, 0, 0)), ("jeans", "jeans", "jeans", "jeans", "jeans", (255, 255, 255)))

        if len(temp_combination) == 2:
            # we will be taking 2 clothes
            cur_type_of_clothes = temp_combination[0][0]

            cur_color = temp_combination[0][5]

            next_type_of_clothes = temp_combination[1][0]
            next_color = temp_combination[1][5]

            angle = db.find_clothes_angle(database, cur_type_of_clothes,
                                          cur_color)
            if angle != -1:
                setCurAngle(angle)
                return redirect(url_for('update_take'))
            else:
                print(
                    "couldn't find the clothes for 2 clothes (top) for some reason"
                )
                return redirect(url_for('home'))

        else:
            # it will be a one piece clothing
            cur_type_of_clothes = temp_combination[0][0]
            cur_color = temp_combination[0][5]
            angle = db.find_clothes_angle(database, cur_type_of_clothes,
                                          cur_color)
            if angle != -1:
                setCurAngle(angle)
                return redirect(url_for('update_take2'))
            else:
                print(
                    "couldn't find the clothes for one piece of clothing for some reason"
                )
                return redirect(url_for('home'))

    else:
        # Call the matching API
        print(final_clothes, cur_color)
        clothes_to_take = matching.setFilter(final_clothes, cur_color,
                                             database)
        print("clothes to take: ", clothes_to_take)
        # Call the preference API using the clothes_to_take
        combinations = matching.getMatches(database, clothes_to_take)

        global_clothes_information = []

        # call the visualizerAPI using combinations
        # using these clothes combinations, we will get the corresponding images
        outfitImages = []
        filenames = []
        for combination in combinations:
            print(combination)
            outfitImages += vapi.getOutfitImgs(combination, 5)
            global_clothes_information += [combination for i in range(5)]

        # Here  we will be saving the files into jpeg
        for (index, image) in enumerate(outfitImages):
            filename = "static/take_img/" + str(index) + ".jpeg"
            image.save(filename, format="JPEG")
            filenames.append(filename)

        return render_template("show_take.html", imgs=filenames)