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

Photomosaic task #58

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open

Photomosaic task #58

wants to merge 18 commits into from

Conversation

mradzikowski
Copy link

Added photomosaic task's algorithm, the order of taking photos is important (TOP -> LEFT -> FRONT -> RIGHT -> BACK). Put constants to the constants folder with vision.

@TheCodeSummoner TheCodeSummoner changed the base branch from master to develop July 10, 2021 15:45
Copy link
Member

@TheCodeSummoner TheCodeSummoner left a comment

Choose a reason for hiding this comment

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

Generally:

  • No underscore imports, please
  • More comments!
  • Better docs!
  • Add a README with an example!
  • Try to new-line after code with comments (my preference really, but I think it looks better):
  • I will review again after these fixes :)
# some comment
some_code()

# another comment
more_code()

For commits, consider rebasing. In PyCharm:

image

You can fixup, drop, reword commits (fixup means merge to the above one):
image

Keep in mind you will need to force push (so careful!!! We can do it together if it's easier / you feel safer, at the end, once the branch is ready to be merged):

image

setup.py Outdated
@@ -41,7 +41,7 @@
"numpy",
"sklearn",
"pandas",
"opencv-python",
"opencv-python==4.5.1.48",
Copy link
Member

Choose a reason for hiding this comment

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

This is fine, but can you share the error proving this is the problem? It's a bit weird fixing the OpenCV installation version works...

Copy link
Author

Choose a reason for hiding this comment

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

https://stackoverflow.com/questions/67837617/cant-parse-pt-sequence-item-with-index-0-has-a-wrong-type-pointpolygon-er This is the solution I have found. Probably it has something with the integer types in function draw_circles. I might check it, but downgrading this version has solved it. The problem arose while testing.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, that's what you'd normally call a dirty hack, since it doesn't actually solve the problem and only walks around it. This might prove to be a problem in the long run (for example if some future cv version introduces some really cool stuff we will want to use). I will have a look at fixing the exact error, if it's simple enough I will just push to your branch, otherwise, we will go on with this fixed-version hack for now.

Copy link
Author

Choose a reason for hiding this comment

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

I have found that it might be the problem with parsing the integers, I am trying to refactor the code and will see if the actual parsing int(SOMETHING) would solve this

Copy link
Author

Choose a reason for hiding this comment

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

I have found that it might be the actual problem

@@ -1,3 +1,17 @@
"""
Computer vision constants.
"""
import numpy as _np
Copy link
Member

Choose a reason for hiding this comment

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

Should be import numpy as np, underscore-imports are a little outdated really.

import numpy as _np

# The height of the cut picture
MOSAIC_HEIGHT = 300
Copy link
Member

Choose a reason for hiding this comment

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

Add whitespace, please. Also, is "The height of the cut picture" referring to the result, or the input?

@@ -42,7 +43,7 @@ def _gaussian_blur_smooth(mask: ndarray) -> ndarray:
return blurred


def _get_edge_points(mask: ndarray) -> list:
def _get_edge_points(mask) -> list:
Copy link
Member

Choose a reason for hiding this comment

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

Type-hint input please

@@ -164,7 +165,7 @@ def count_mussels(image: ndarray) -> Tuple[int, ndarray, ndarray, ndarray, ndarr
hull_rect = _get_corner_points(points)

# Draw hull rect on the original image
convex_hull: ndarray = image.copy()
convex_hull = image.copy()
Copy link
Member

Choose a reason for hiding this comment

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

Type hint this please

img_cut = _cut_images(images_hsv)

dict_color_map = _color_detect(img_cut[:1])
print(dict_color_map)
Copy link
Member

Choose a reason for hiding this comment

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

!!!!


# divide the top and bottom image
bottom_index, top_index = _type_division(dict_color_map)
print("Image count", len(img_cut))
Copy link
Member

Choose a reason for hiding this comment

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

!!!!

# divide the top and bottom image
bottom_index, top_index = _type_division(dict_color_map)
print("Image count", len(img_cut))
print(bottom_index, top_index)
Copy link
Member

Choose a reason for hiding this comment

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

!!!!!

for i in range(5):
# This line to be changed when we get the camera
img.append(_cv2.imread("./proper_samples/" + str(i + 1) + ".png"))
print(len(img))
Copy link
Member

Choose a reason for hiding this comment

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

!!!!

print("Image count", len(img_cut))
print(bottom_index, top_index)

# combine the images
Copy link
Member

Choose a reason for hiding this comment

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

Wow I'm glad you told me what this line does :)

@TheCodeSummoner TheCodeSummoner requested review from TheCodeSummoner and removed request for TheCodeSummoner July 11, 2021 11:21
MOSAIC_HEIGHT is referred to the result picture
Change in mussels.py parsing to integers by function int() instead of astype()
Added logger and got rid of print statements. Changed imports to not be underscored. Added documentation about _cut_images function, _find_rectangle, _get_contours, _combine_images, _color_detect. _get_key function is to help with combining images and getting colors of interest to match while combining.
Changed parsing to be compatible with newer versions of OpenCV
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.

2 participants