Go to Post Adversity should be seen as a challenge and not as an obstacle. :D - waialua359 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 27-05-2016, 20:31
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 214
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
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()
Because of the lack of a wide FOV from the camera, you cannot see the entire boulder at any time. I am just looking for suggestions on what to try in OpenCV. Any help would be greatly appreciated! Thanks!
__________________
#Python4Life
Reply With Quote
  #2   Spotlight this post!  
Unread 27-05-2016, 22:12
SoftwareBug2.0's Avatar
SoftwareBug2.0 SoftwareBug2.0 is offline
Registered User
AKA: Eric
FRC #1425 (Error Code Xero)
Team Role: Mentor
 
Join Date: Aug 2004
Rookie Year: 2004
Location: Tigard, Oregon
Posts: 485
SoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant futureSoftwareBug2.0 has a brilliant future
Re: Very basic boulder detection

How about putting something bright green on your robot that the boulder would block when it's there?
Reply With Quote
  #3   Spotlight this post!  
Unread 27-05-2016, 23:51
team-4480's Avatar
team-4480 team-4480 is offline
Debug? What's that?
FRC #4480
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Minnesooota
Posts: 214
team-4480 will become famous soon enoughteam-4480 will become famous soon enough
Re: Very basic boulder detection

Quote:
Originally Posted by SoftwareBug2.0 View Post
How about putting something bright green on your robot that the boulder would block when it's there?
That is an interesting workaround! I think I will give it a shot.
__________________
#Python4Life
Reply With Quote
  #4   Spotlight this post!  
Unread 28-05-2016, 10:33
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 519
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
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.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #5   Spotlight this post!  
Unread 28-05-2016, 18:56
Cabey4 Cabey4 is offline
Vision/Scouting/Strategy/Too much
AKA: Tom Schwarz
no team
Team Role: Programmer
 
Join Date: May 2015
Rookie Year: 2015
Location: Sydney
Posts: 26
Cabey4 is on a distinguished road
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.
__________________
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:03.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi