first95 / FRC2020

Code base for 2020 robot, initialized with develop branch of 2019 repo.
MIT License
1 stars 1 forks source link

General strategy and implementation for processing high port vision target #17

Open lindsayvallen opened 4 years ago

lindsayvallen commented 4 years ago

Determine a general approach to identify the high port vision target, and where the robot is relative to the target (position and orientation). Suggest using GRiP and example images from FIRST.

lindsayvallen commented 4 years ago

Useful links for this work

The second link has some good ideas for applying arclength, area, and moments to contours, like the ones we have thus far. I think we could characterize the outer port target pretty specifically using a combination of these properties, even tolerating some variation in angle and distance relative to target.

Working on this in git branch feature/outer_port_finder.

lindsayvallen commented 4 years ago

Can use moments to get rotational inertia term John suggested: I{1}=\eta {{20}}+\eta _{{02}} from https://en.wikipedia.org/wiki/Image_moment

jwalthour commented 4 years ago

I should probably mention: the OpenCV simple blob detector computes inertial ratio by default. GRiP doesn't expose it as an option, but you should be able to set it in Java. Depending how your code is structured it might save you a lot of time.

Here's what setting up a simple blob detector looks like in Python - note the minInertiaRatio line. (from that camera calibration project I mentioned)


    def make_detector(self):
        # Setup SimpleBlobDetector parameters.
        parms = cv2.SimpleBlobDetector_Params()

        # Change thresholds
        parms.minThreshold = 0;
        parms.maxThreshold = 128;

        # Filter by Area.
        parms.filterByArea = True
        parms.minArea = 5

        # Filter by Circularity
        parms.filterByCircularity = True
        parms.minCircularity = 0.25

        # Filter by Convexity
        parms.filterByConvexity = False
        parms.minConvexity = 0.9
        parms.maxConvexity = 1

        # Filter by Inertia
        parms.filterByInertia = True
        parms.minInertiaRatio = 0.5

        # logger.debug("Orig minDistBetweenBlobs: " + str(parms.minDistBetweenBlobs))
        parms.minDistBetweenBlobs = 5
        parms.blobColor = 0

        # Create a detector with the parameters
        return cv2.SimpleBlobDetector_create(parms)
lindsayvallen commented 4 years ago

@jwalthour you did mention that Saturday (and possibly in Slack too), hence why I have the mention above about the inertial metric. However, you also mentioned that the blob detector seemed slower than finding lines or contours, so I thought finding the info using something other than the blob detector was worth trying.

jwalthour commented 4 years ago

great plans!

jwalthour commented 4 years ago

Today I started a draft version of this that uses the line finder. I figure it might end up being a useful starting point for later. I committed it to feature/outer_port_finder, but in separate files, so as to not interfere with the contour-based approach.