예제 #1
0
def infer_nip(aur_list):
    """
    Infer nipples.

    :param aur_list: <BodyPart[]> aur list)
    :return: <BodyPart[]> nip list
    """
    nip_list = []

    for aur in aur_list:
        # Nip rules:
        # - circle (w == h)
        # - min dim: 5
        # - bigger if aur is bigger
        nip_dim = int(5 + aur.w * random.uniform(0.03, 0.09))

        # center:
        x = aur.x
        y = aur.y

        # Calculate Bounding Box:
        xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(
            nip_dim, nip_dim, x, y)

        BodyPart.add_body_part_to_list("nip",
                                       BoundingBox(xmin, ymin, xmax, ymax),
                                       Center(x, y),
                                       Dimension(nip_dim, nip_dim), nip_list)

    return nip_list
예제 #2
0
def infer_hair(vag_list, enable):
    """
    Infer vaginal hair.

    :param vag_list: <BodyPart[]> vag list
    :param enable: <Boolean> Enable or disable hair generation
    :return: <BodyPart[]> hair list
    """
    hair_list = []

    if enable:
        for vag in vag_list:
            # Hair rules:
            hair_w = vag.w * random.uniform(0.4, 1.5)
            hair_h = vag.h * random.uniform(0.4, 1.5)

            # center:
            x = vag.x
            y = vag.y - (hair_h / 2) - (vag.h / 2)

            xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(
                hair_h, hair_w, x, y)

            BodyPart.add_body_part_to_list("hair",
                                           BoundingBox(xmin, ymin, xmax, ymax),
                                           Center(x, y),
                                           Dimension(hair_w, hair_h),
                                           hair_list)

    return hair_list
예제 #3
0
    def resolve_problem_6():
        # Find width aur is full:
        new_x, new_y = find_l2_width_is_full(tits_list, aur_list)
        new_w = tits_list[0].w / 2

        # Calculate Bounding Box:
        xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(new_w, new_w, new_x, new_y)

        BodyPart.add_body_part_to_list("tit", BoundingBox(xmin, ymin, xmax, ymax), Center(new_x, new_y),
                                       Dimension(tits_list[0].w, tits_list[0].w), tits_list)
예제 #4
0
    def resolve_problem_7():
        # Add the first aur:
        new_w = tits_list[0].w * random.uniform(0.03, 0.1)  # TOTEST
        new_x = tits_list[0].x
        new_y = tits_list[0].y

        xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(new_w, new_w, new_x, new_y)

        BodyPart.add_body_part_to_list("aur", BoundingBox(xmin, ymin, xmax, ymax), Center(new_x, new_y),
                                       Dimension(new_w, new_w), aur_list)

        # Add the second aur:
        new_w = tits_list[1].w * random.uniform(0.03, 0.1)  # TOTEST
        new_x = tits_list[1].x
        new_y = tits_list[1].y

        xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(new_w, new_w, new_x, new_y)

        BodyPart.add_body_part_to_list("aur", BoundingBox(xmin, ymin, xmax, ymax), Center(new_x, new_y),
                                       Dimension(new_w, new_w), aur_list)
예제 #5
0
    def resolve_problem_8():
        # Find width tit is full
        new_x, new_y = find_l2_width_is_full(aur_list, tits_list)

        # Calculate Bounding Box:
        xmin = int(new_x - (aur_list[0].w / 2))
        xmax = int(new_x + (aur_list[0].w / 2))
        ymin = int(new_y - (aur_list[0].w / 2))
        ymax = int(new_y + (aur_list[0].w / 2))

        BodyPart.add_body_part_to_list("aur", BoundingBox(xmin, ymin, xmax, ymax), Center(new_x, new_y),
                                       Dimension(aur_list[0].w, aur_list[0].w), aur_list)
예제 #6
0
    def resolve_problem_3():
        random_tit_factor = random.randint(2, 5)  # TOTEST

        # Add the first tit:
        new_w = aur_list[0].w * random_tit_factor  # TOTEST
        new_x = aur_list[0].x
        new_y = aur_list[0].y

        xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(new_w, new_w, new_x, new_y)

        BodyPart.add_body_part_to_list("tit", BoundingBox(xmin, ymin, xmax, ymax), Center(new_x, new_y),
                                       Dimension(new_w, new_w), tits_list)

        # Add the second tit:
        new_w = aur_list[1].w * random_tit_factor  # TOTEST
        new_x = aur_list[1].x
        new_y = aur_list[1].y

        xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(new_w, new_w, new_x, new_y)

        BodyPart.add_body_part_to_list("tit", BoundingBox(xmax, xmin, ymax, ymin), Center(new_x, new_y),
                                       Dimension(new_w, new_w), tits_list)
예제 #7
0
def find_body_part(image, part_name):
    """
    Find body part.

    :param image: <RGB> image
    :param part_name: <string> part_name
    :return: <BodyPart[]>list
    """
    bodypart_list = []  # empty BodyPart list

    color_mask = get_correct_filter_color(image, part_name)

    # find contours:
    contours, _ = cv2.findContours(color_mask, cv2.RETR_TREE,
                                   cv2.CHAIN_APPROX_SIMPLE)

    # for every contour:
    for cnt in contours:

        if len(cnt) > 5:  # at least 5 points to fit ellipse

            # (x, y), (MA, ma), angle = cv2.fitEllipse(cnt)
            ellipse = cv2.fitEllipse(cnt)

            # Fit Result:
            x = ellipse[0][0]  # center x
            y = ellipse[0][1]  # center y
            angle = ellipse[2]  # angle
            a_min = ellipse[1][0]  # asse minore
            a_max = ellipse[1][1]  # asse maggiore

            h, w = detect_direction(a_max, a_min, angle)

            h, w = normalize_belly_vag(h, part_name, w)

            xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(
                h, w, x, y)

            BodyPart.add_body_part_to_list(part_name,
                                           BoundingBox(xmin, ymin, xmax, ymax),
                                           Center(x, y), Dimension(w, h),
                                           bodypart_list)

    return bodypart_list