|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Very basic boulder detection
Hi,
On our Stronghold robot, we had a camera on a servo for looking around the field. The problem was that the camera was too low on the robot (Thanks, low bar...) and our shooter cims were blocking a good portion of the view. So thinking of things we could actually use the camera for, I came up with the idea o a basic boulder detection using openCV to see if our boulder made it into our intake. Here is the image of what the boulder looks like inside of our intake. Yes, I know I could just use a sensor like a distance sensor to see if there is a boulder there, but that is not a very fun and doesn't make use of our useless camera. Also, I made it a goal to become more proficient with vision programming and this seemed like good practice. To go about doing this, I first tried the obvious "filter for the HSV", but that was too inconsistent and was wildly dependant on lighting since the boulders are quite shiny. Next, I tried edges, but that didn't work so well. I also tried HoughCircles which worked somewhat when there was a boulder present but went absolutely crazy when there wasn't one. Here is the code I am currently using: Code:
import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np
vid = cv.VideoCapture("boulder.mov")
while True:
_, frame = vid.read()
img = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
edges = cv.Canny(img, 250, 350)
circles = cv.HoughCircles(edges,cv.HOUGH_GRADIENT,1,30,
param1=2,param2=30,minRadius=200,maxRadius=500)
try: #Just in case there isn't a circle
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
cv.circle(img,(i[0],i[1]),i[2],(0,255,0),2)
cv.circle(img,(i[0],i[1]),2,(0,0,255),3)
except:
pass
cv.imshow('image', img)
k = cv.waitKey(5) & 0xFF
if k == 27:
break
vid.release()
cv.destroyAllWindows()
|
|
#2
|
||||
|
||||
|
Re: Very basic boulder detection
How about putting something bright green on your robot that the boulder would block when it's there?
|
|
#3
|
||||
|
||||
|
Re: Very basic boulder detection
That is an interesting workaround! I think I will give it a shot.
|
|
#4
|
|||
|
|||
|
Re: Very basic boulder detection
I was going to try this same thing, but I decided that it would be easier just to use an infrared proximity sensor (but I didn't have enough time to add one
). I can find the part number of the one I was going to use if anyone wants it. |
|
#5
|
|||
|
|||
|
Re: Very basic boulder detection
I would:
1. run a very small median blur 2. Very slight HSV filtering - barley anything - remove stuff that's say bright green. You will have much more than just a ball 3. Binary mask or something so that you have the full image with parts that didn't get through HSV now black - as opposed to just a black and white image that you would otherwise have Now, it would make it a lot easier to paint or colour the parts of the robot that border the boulder, from the camera's perspective. Enough that the HSV filtering will remove it, so you should end up with the gray ball (or part of it) not touching the robot. 4. Edge detection 5. filter based on criteria You could also use HoughCircles, but it still might go crazy without the boulder. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|