-
Notifications
You must be signed in to change notification settings - Fork 0
Grid mapping #32
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
base: master
Are you sure you want to change the base?
Grid mapping #32
Conversation
ryankarpuszka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The grid mapping stuff looks pretty good. The main thing I would suggest is to use some sort of class that holds the information about all the squares rather than using global variables to keep track of them. Also it's better to abstract out any numeric parameters to their own variables.
vision/grid_map/grid_map.py
Outdated
| def empty(a): | ||
| pass | ||
|
|
||
| def start_mapping(video): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this method into the testing script since it's just being used to read frames from a file. You could create a class Grid_Mapping that has a method update(image) that just takes in every new frame as input. This will make it easier to integrate with the camera feed from the robot.
vision/grid_map/grid_map.py
Outdated
| screenshot_squares(squares, frame) | ||
|
|
||
| # Drawing squares on the frame | ||
| for s in squares: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe only do this if we're in debug mode.
vision/grid_map/grid_map.py
Outdated
|
|
||
| blur = cv2.GaussianBlur(frame, (7, 7), 1) | ||
|
|
||
| thresh1 = cv2.getTrackbarPos("Thresh1", "Trackbar") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since your algorithm has a lot of different parameters, it would be a good idea to put them all in one place that's easy to adjust. These could be fields in the class you make. Then in the testing script, you can add sliders that will adjust the values of the class fields.
vision/grid_map/grid_map.py
Outdated
| if not ret: | ||
| break | ||
|
|
||
| blur = cv2.GaussianBlur(frame, (7, 7), 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make this 7 a variable.
vision/grid_map/grid_map.py
Outdated
| lines = np.zeros_like(frame) | ||
| draw_lines(lines, canny) | ||
|
|
||
| kernel = np.ones((10, 10)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a variable too
vision/grid_map/grid_map.py
Outdated
|
|
||
| def find_squares(curr_squares, frame): | ||
| global id | ||
| global squares # Square objects already being tracked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to avoid using global variables. Make a class to keep track of these instead.
vision/grid_map/grid_map.py
Outdated
| area = cv2.contourArea(cnt) | ||
| approx = cv2.approxPolyDP(cnt, .01 * cv2.arcLength(cnt, True), True) | ||
|
|
||
| if area > 10000: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This number might not work for different resolution frames. You could do a comparison with the percentage of the frame's total area.
vision/grid_map/grid_map.py
Outdated
| self.h = h # height | ||
| self.visible = True # True if square is visible in video | ||
| self.delete = 0 # Tracks num of frames visible = False | ||
| self.screenshot_num = 0 # Tracks num of screenshots taken per square |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of saving screenshots of the squares to the filesystem, they could just be saved in an array within this class which could then get passed along to the object detection code.
No description provided.