Go to Post - Only think of Gracious Professionalism as a standard to work toward personally. - Never use it as a gauge to point out someone else’s shortcomings. - Rich Kressly [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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: 216
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
 


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 10:42.

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