Browse Source

Merge pull request #50 from PommeDroid/ultimate_refactoring_fix

Fix some regression for the no so ultimate refactor :D
master
deeppppp 3 years ago committed by GitHub
parent
commit
8fead426b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      processing/folder.py
  2. 10
      transform/opencv/bodypart/extract.py
  3. 13
      transform/opencv/bodypart/inferrer.py
  4. 21
      transform/opencv/bodypart/resolver.py

2
processing/folder.py

@ -26,7 +26,7 @@ class FolderImageProcessing(MultipleImageProcessing): @@ -26,7 +26,7 @@ class FolderImageProcessing(MultipleImageProcessing):
self.__output_folder_path = self._args['output']
self.__multiprocessing = Conf.multiprocessing()
def _setup(self):
def _setup(self, *args):
Conf.log.debug([(r, d, f) for r, d, f in os.walk(self.__input_folder_path)])
for r, _, _ in os.walk(self.__input_folder_path):

10
transform/opencv/bodypart/extract.py

@ -84,9 +84,9 @@ def find_body_part(image, part_name): @@ -84,9 +84,9 @@ def find_body_part(image, part_name):
xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(h, w, x, y)
bodypart_list.append(
BodyPart(part_name, BoundingBox(xmin, ymin, xmax, ymax), Center(x, y), Dimension(w, h))
)
BodyPart.add_body_part_to_list(part_name, BoundingBox(xmin, ymin, xmax, ymax), Center(x, y),
Dimension(w, h), bodypart_list)
return bodypart_list
@ -131,10 +131,10 @@ def get_correct_filter_color(image, part_name): @@ -131,10 +131,10 @@ def get_correct_filter_color(image, part_name):
color_mask = cv2.bitwise_or(color_mask1, color_mask2) # combine
elif part_name == "aur":
color_mask = get_simple_mask(image, [0, 0, 250], [0, 0, 250])
color_mask = get_simple_mask(image, [0, 0, 250], [0, 0, 255])
elif part_name == "vag":
color_mask = get_simple_mask(image, [250, 0, 0], [250, 0, 0])
color_mask = get_simple_mask(image, [250, 0, 0], [255, 0, 0])
elif part_name == "belly":
color_mask = get_simple_mask(image, [250, 0, 250], [255, 0, 255])

13
transform/opencv/bodypart/inferrer.py

@ -27,10 +27,8 @@ def infer_nip(aur_list): @@ -27,10 +27,8 @@ def infer_nip(aur_list):
# Calculate Bounding Box:
xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(nip_dim, nip_dim, x, y)
nip_list.append(
BodyPart("nip", BoundingBox(xmin, ymin, xmax, ymax), Center(x, y), Dimension(nip_dim, nip_dim)
)
)
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
@ -55,10 +53,9 @@ def infer_hair(vag_list, enable): @@ -55,10 +53,9 @@ def infer_hair(vag_list, enable):
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)
xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(hair_h, hair_w, x, y)
hair_list.append(
BodyPart("nip", BoundingBox(xmin, ymin, xmax, ymax), Center(x, y), Dimension(hair_w, hair_h))
)
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

21
transform/opencv/bodypart/resolver.py

@ -90,10 +90,8 @@ def resolve_tit_aur_missing_problems(tits_list, aur_list, problem_code): @@ -90,10 +90,8 @@ def resolve_tit_aur_missing_problems(tits_list, aur_list, problem_code):
# Calculate Bounding Box:
xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(new_w, new_w, new_x, new_y)
tits_list.append(
BodyPart("tit", BoundingBox(xmin, ymin, xmax, ymax), Center(new_x, new_y),
Dimension(tits_list[0].w, tits_list[0].w))
)
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)
def resolve_problem_7():
# Add the first aur:
@ -103,7 +101,8 @@ def resolve_tit_aur_missing_problems(tits_list, aur_list, problem_code): @@ -103,7 +101,8 @@ def resolve_tit_aur_missing_problems(tits_list, aur_list, problem_code):
xmax, xmin, ymax, ymin = BoundingBox.calculate_bounding_box(new_w, new_w, new_x, new_y)
BodyPart("aur", BoundingBox(xmin, ymin, xmax, ymax), Center(new_x, new_y), Dimension(new_w, new_w))
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
@ -128,12 +127,12 @@ def resolve_tit_aur_missing_problems(tits_list, aur_list, problem_code): @@ -128,12 +127,12 @@ def resolve_tit_aur_missing_problems(tits_list, aur_list, problem_code):
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)
{
3: resolve_problem_3,
6: resolve_problem_6,
7: resolve_problem_7,
8: resolve_problem_8,
}.get(problem_code, lambda: None)()
{
3: resolve_problem_3,
6: resolve_problem_6,
7: resolve_problem_7,
8: resolve_problem_8,
}.get(problem_code, lambda: None)()
def detect_tit_aur_position_problem(tits_list, aur_list):

Loading…
Cancel
Save