Skip to content

Conversation

@ryankarpuszka
Copy link
Contributor

No description provided.

Copy link
Contributor Author

@ryankarpuszka ryankarpuszka left a 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.

def empty(a):
pass

def start_mapping(video):
Copy link
Contributor Author

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.

screenshot_squares(squares, frame)

# Drawing squares on the frame
for s in squares:
Copy link
Contributor Author

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.


blur = cv2.GaussianBlur(frame, (7, 7), 1)

thresh1 = cv2.getTrackbarPos("Thresh1", "Trackbar")
Copy link
Contributor Author

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.

if not ret:
break

blur = cv2.GaussianBlur(frame, (7, 7), 1)
Copy link
Contributor Author

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.

lines = np.zeros_like(frame)
draw_lines(lines, canny)

kernel = np.ones((10, 10))
Copy link
Contributor Author

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


def find_squares(curr_squares, frame):
global id
global squares # Square objects already being tracked
Copy link
Contributor Author

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.

area = cv2.contourArea(cnt)
approx = cv2.approxPolyDP(cnt, .01 * cv2.arcLength(cnt, True), True)

if area > 10000:
Copy link
Contributor Author

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.

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
Copy link
Contributor Author

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.

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.

4 participants