Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update image_processing.py #495

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

whoiskatrin
Copy link

@whoiskatrin whoiskatrin commented Jan 5, 2023

I made the following changes in this PR:

  • Removed unnecessary multiplication of vertical and horizontal arrays, as it seems to be excessive, so I tried to improve that bit (I might be wrong though, but it seems like that)
  • Changed the try-except block to just a single line that calls cv2.findContours() and gets the second element of the returned tuple, which is the list of contours
  • Simplified the calculation for the coordinates of the joint by using int division to calculate the center of the bounding rectangle for each contour (about htis one, first we are tracing the contours of the object in the image, then drawing a rectangle around each contour, then finding the point in the middle and in the end using this point as an est for the coordinates of the joint we were looking for)

Ping me if there are any questions, thanks.

I made the following changes:

- Removed unnecessary multiplication of vertical and horizontal arrays, as it seems to be unnecessary.
- Changed the try-except block to just a single line that calls cv2.findContours() and gets the second element of the returned tuple, which is the list of contours.
- Simplified the calculation for the coordinates of the joint by using integer division to calculate the center of the bounding rectangle for each contour.
Removed the unnecessary if-else block and moved the np.invert() call to the beginning of the function to avoid inverting the image twice if process_background is True.
Changed the function always to invert the image if process_background is False. This makes the function more efficient because it avoids the need to perform the inversion and thresholding separately.
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.

None yet

1 participant