Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Dec 12, 2022

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from sudharsan2020 December 12, 2022 10:48
detector = FaceDetector(cascade_path)
face_boxes = detector.detect(gray, 1.2, 5)
print("{} face(s) found".format(len(face_boxes)))
print(f"{len(face_boxes)} face(s) found")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 15-15 refactored with the following changes:

Comment on lines -10 to +12
# Detect faces in the image
boxes = self.face_cascade.detectMultiScale(image, scale_factor, min_neighbors, flags=cv2.CASCADE_SCALE_IMAGE)

# Return the bounding boxes
return boxes
return self.face_cascade.detectMultiScale(
image, scale_factor, min_neighbors, flags=cv2.CASCADE_SCALE_IMAGE
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FaceDetector.detect refactored with the following changes:

This removes the following comments ( why? ):

# Return the bounding boxes
# Detect faces in the image

Comment on lines -10 to +12
# Detect faces in the image
boxes = self.face_cascade.detectMultiScale(image, scale_factor, min_neighbors, flags=cv2.CASCADE_SCALE_IMAGE)

# Return the bounding boxes
return boxes
return self.face_cascade.detectMultiScale(
image, scale_factor, min_neighbors, flags=cv2.CASCADE_SCALE_IMAGE
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FaceDetector.detect refactored with the following changes:

This removes the following comments ( why? ):

# Return the bounding boxes
# Detect faces in the image


# Return the translated image
return shifted
return cv2.warpAffine(image, matrix, (image.shape[1], image.shape[0]))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function translate refactored with the following changes:

This removes the following comments ( why? ):

# Return the translated image

Comment on lines -24 to +21
rotated = cv2.warpAffine(image, matrix, (w, h))

# Return the rotated image
return rotated
return cv2.warpAffine(image, matrix, (w, h))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function rotate refactored with the following changes:

This removes the following comments ( why? ):

# Return the rotated image

Comment on lines -50 to +44
# Resize the image
resized = cv2.resize(image, dim, interpolation=inter)

# Return the resized image
return resized
return cv2.resize(image, dim, interpolation=inter)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function resize refactored with the following changes:

This removes the following comments ( why? ):

# Return the resized image
# Resize the image

Comment on lines -16 to +17
image_paths = sorted(glob.glob(path_to_images + "/*.png"))
mask_paths = sorted(glob.glob(path_to_masks + "/*.png"))
image_paths = sorted(glob.glob(f"{path_to_images}/*.png"))
mask_paths = sorted(glob.glob(f"{path_to_masks}/*.png"))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 16-72 refactored with the following changes:

Comment on lines -18 to +30
min_matches = 40

# Initialize the database dictionary of covers
database = {}

# Loop over the database
for l in csv.reader(open(database_path)):
# Update the database using the image ID as the key
database[l[0]] = l[1:]

# If SIFT is to be used, then update the parameters
if use_sift:
min_matches = 50
database = {l[0]: l[1:] for l in csv.reader(open(database_path))}

min_matches = 50 if use_sift else 40
# Initialize the cover descriptor and cover matcher
cover_descriptor = CoverDescriptor(use_sift=use_sift)
cover_matcher = CoverMatcher(cover_descriptor, glob.glob(covers_path + "/*.png"), ratio=ratio, min_matches=min_matches,
use_hamming=use_hamming)
cover_matcher = CoverMatcher(
cover_descriptor,
glob.glob(f"{covers_path}/*.png"),
ratio=ratio,
min_matches=min_matches,
use_hamming=use_hamming,
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 18-35 refactored with the following changes:

This removes the following comments ( why? ):

# If SIFT is to be used, then update the parameters
# Update the database using the image ID as the key
# Loop over the database


# If matches were found, sort them
if len(results) > 0:
if results:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CoverMatcher.search refactored with the following changes:

Comment on lines -45 to +49
matches = []

# Loop over the raw matches
for match in raw_matches:
# Ensure the distance is within a certain ratio of each other
if len(match) == 2 and match[0].distance < match[1].distance * self.ratio:
matches.append((match[0].trainIdx, match[0].queryIdx))
matches = [
(match[0].trainIdx, match[0].queryIdx)
for match in raw_matches
if len(match) == 2 and match[0].distance < match[1].distance * self.ratio
]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CoverMatcher.match refactored with the following changes:

This removes the following comments ( why? ):

# Ensure the distance is within a certain ratio of each other
# Loop over the raw matches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants