Skip to content

Comments

Test Tub Detection (Assuming circular shape)#2

Open
DavidLCPyML wants to merge 2 commits intoECLAIR-Robotics:masterfrom
DavidLCPyML:circle_detection
Open

Test Tub Detection (Assuming circular shape)#2
DavidLCPyML wants to merge 2 commits intoECLAIR-Robotics:masterfrom
DavidLCPyML:circle_detection

Conversation

@DavidLCPyML
Copy link

@DavidLCPyML DavidLCPyML commented Feb 24, 2023

Description

  • How this works
    This will take in an image feed, read and preprocess a single frame, and generate predictions of possible circular test tube openings via a Hough transform.
  • Limitations
    Working Hough Transform has notoriously low accuracy, can't detect plastic tube entrances unless there is a lot of contrast around the border
    I suspect overfitting may be at play here since it's extremely conservative in its predictions.
  • What doesn't work
    Attempted RANSAC for better circle detection - didn't work as well as Hough Transform
    Attempted to combine the two, but the resultant model did not yield a better result than just using a Hough Transform.
  • Possible Routes
    Utilizing a Neural Net-based architecture to identify test tubes via bounding boxes. Maybe YOLOv5 or some other conventional model.

Testing

  • Pictures

image

  • Screenshots
    WIP
  • Test cases
    WIP

@sahiljain11 sahiljain11 self-requested a review February 24, 2023 00:38
Copy link

@sahiljain11 sahiljain11 left a comment

Choose a reason for hiding this comment

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

This is just a test. Please add the rest of your code!

@DavidLCPyML DavidLCPyML requested a review from sahiljain11 March 7, 2023 01:46
Copy link

@sahiljain11 sahiljain11 left a comment

Choose a reason for hiding this comment

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

Overall, looks pretty good! I thought the self.dist = lambda stuff was really cool (I'm stealing that). Listed some comments for you two iterate on! :)

return True


import cv2 as cv

Choose a reason for hiding this comment

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

Add these imports to the top of the file since that's where all of them are. Just good python coding procedure

self.dist = lambda x1, y1, x2, y2: (x1 - x2) ** 2 + (y1 - y2) ** 2
self.debug = False

def predict(self, frame):

Choose a reason for hiding this comment

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

Using python typing, you can say the following:

def predict(self, frame) -> List[Tuple[[int, int]]]:

This increases code readability so a person looking at this can more easily tell what this function takes in for input and output. You may need to import Tuple and List from typing

cv.imshow("grayscale", gray)
return pred

def getCircles(self):

Choose a reason for hiding this comment

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

Same thing but you can do def getCircles(self) -> None


from xarm.wrapper import XArmAPI
from gizzmos import CustomGripper, PressureSensor
from pcr.gizzmos import CustomGripper, PressureSensor, AtalantaModule

Choose a reason for hiding this comment

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

You should probably add TestTubeCV instead of AtalantaModule

Args: None
Returns: None
"""
while True:

Choose a reason for hiding this comment

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

Can you setup the code such as the if someone calls predict, we can just open the vidoecapture briefly (like one frame) and feed it in. Currently, this code will run forever without letting any of the xArm code to run

if circles is not None:
circles = np.uint16(np.around(circles))
chosen = None
for i in circles[0, :]:

Choose a reason for hiding this comment

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

Could you explain in comments what's happening here? I think you're comparing the Eucledian distance between chosen and i but not sure what that means or what the algorithm here is...


if cv.waitKey(1) == ord('q'):
break
self.videoCapture.release()

Choose a reason for hiding this comment

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

Yeah, I don't think we need this getCircles() method tbh since it'll just be a one off call not a continuous call. I'd just use that for the predict() method. Look at the above comment for more information.

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