Go to Post And to think, a lot of students are planning parties and celebrations on their last day of school and you guys are recycling trash. - JaneYoung [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 02-02-2017, 16:51
elijah1111's Avatar
elijah1111 elijah1111 is online now
Registered User
FRC #4601 (Circuit Birds)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Ohio
Posts: 15
elijah1111 is an unknown quantity at this point
Question Open CV help

Hey anybody got any ideas on Open CV? We were planning on using it for auto gears.
Code:
static void VisionThread(){
//blah blah set up cameras

while(true){
inRange(mat,cv::Scalar(0,100,0),cv::Scalar(100,255,100),mat)//find green light
cv::findContours(mat,contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_TC89_KCOS);//find reflect tape
			cv::drawContours(mat,contours,-1,cv::Scalar(255,255,255),1,8);//draw them
cameraserver.putframe(mat);//put the modifed image matrix
centerpoints.read()//I need to find the centerpoints here how would I do that?
}
}

void RobotInit(){
std::thread camthread(VisionThread);//makes a new thread
camthread.detach();//snaps the thread off to do its own thing
}

void AutonomousPeriodic(){
 camera.read()//Here is where I need help how do I get the two threads to talk
}
Anybody got any suggestions? I was thinking if you could calculate the distance between the two center points and you know the actual distance you can find out how far you are from the peg for the gear.

Thanks,
Elijah
4601

P.S. actual code is here https://github.com/CircuitBirds-FRC4601/CB5
Reply With Quote
  #2   Spotlight this post!  
Unread 02-02-2017, 17:04
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,386
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Open CV help

My biggest concern with this approach is that the gear itself will be covering those two pieces of retro tape most of the time when aligned. Encoders might be a better approach.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2017, 17:16
elijah1111's Avatar
elijah1111 elijah1111 is online now
Registered User
FRC #4601 (Circuit Birds)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Ohio
Posts: 15
elijah1111 is an unknown quantity at this point
Re: Open CV help

I agree, if you get to start in front of the peg facing the wall, but what about the other ones? You would need to preset it in a certain location which seems harder this year.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-02-2017, 17:23
elijah1111's Avatar
elijah1111 elijah1111 is online now
Registered User
FRC #4601 (Circuit Birds)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Ohio
Posts: 15
elijah1111 is an unknown quantity at this point
Re: Open CV help

Quote:
Originally Posted by billbo911 View Post
My biggest concern with this approach is that the gear itself will be covering those two pieces of retro tape most of the time when aligned. Encoders might be a better approach.
what do you mean by covering them? I was thinking of finding the distance between the tape before you put the gear on then reading encoder counts for that distance.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-02-2017, 17:28
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,386
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Open CV help

Quote:
Originally Posted by elijah1111 View Post
what do you mean by covering them? I was thinking of finding the distance between the tape before you put the gear on then reading encoder counts for that distance.
Now that just might work. You would just need to have some way to tell the RC when to lock in the distance.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
Reply With Quote
  #6   Spotlight this post!  
Unread 02-02-2017, 17:45
elijah1111's Avatar
elijah1111 elijah1111 is online now
Registered User
FRC #4601 (Circuit Birds)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Ohio
Posts: 15
elijah1111 is an unknown quantity at this point
Re: Open CV help

Quote:
Originally Posted by billbo911 View Post
Now that just might work. You would just need to have some way to tell the RC when to lock in the distance.
Yah, that is my problem I'm pretty sure I open cv has the capability for doing that but how do I pass it to the auto code, because its a static void for the multi threading.
Reply With Quote
  #7   Spotlight this post!  
Unread 02-02-2017, 18:38
Maxcr1's Avatar
Maxcr1 Maxcr1 is offline
Registered User
AKA: Max D
FRC #2169 (KING TeC)
Team Role: Programmer
 
Join Date: Nov 2016
Rookie Year: 2013
Location: Savage, MN
Posts: 9
Maxcr1 is an unknown quantity at this point
Re: Open CV help

The secret to using vision for Steamworks is having an angle of attack of the camera to avoid the gear getting in the way of seeing the tape. The vision is possible and the calculations do exist, and aren't too bad if you follow 254's presentation.

Vision Presentation

Multithreading is often unrealistic because all of the tasks have to be run in a linear pattern, and while running multiple versions can be effective, it causes issues with multiple threads fighting over the same frame. You can use a lock, but that requires Python and that can be another issue
Reply With Quote
  #8   Spotlight this post!  
Unread 02-02-2017, 18:52
elijah1111's Avatar
elijah1111 elijah1111 is online now
Registered User
FRC #4601 (Circuit Birds)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Ohio
Posts: 15
elijah1111 is an unknown quantity at this point
Re: Open CV help

Quote:
Originally Posted by Maxcr1 View Post
The secret to using vision for Steamworks is having an angle of attack of the camera to avoid the gear getting in the way of seeing the tape. The vision is possible and the calculations do exist, and aren't too bad if you follow 254's presentation.

Vision Presentation

Multithreading is often unrealistic because all of the tasks have to be run in a linear pattern, and while running multiple versions can be effective, it causes issues with multiple threads fighting over the same frame. You can use a lock, but that requires Python and that can be another issue
By frame do you mean the image? The multithread would be linear, there is only one thread for camera. I just need the auto to tell that thread to find the distance between the center points then relay it back to convert to encoder values. I am multithreading because the open cv capture and operations would bog down the robot. Of course I could always just take a still image of the tape but i figured it would be better to take a video to average out the distances.
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 15:28.

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