|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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
}
Thanks, Elijah 4601 P.S. actual code is here https://github.com/CircuitBirds-FRC4601/CB5 |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
||||
|
||||
|
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.
|
|
#4
|
||||
|
||||
|
Re: Open CV help
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.
|
|
#5
|
||||
|
||||
|
Re: Open CV help
Now that just might work. You would just need to have some way to tell the RC when to lock in the distance.
|
|
#6
|
||||
|
||||
|
Re: Open CV help
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.
|
|
#7
|
||||
|
||||
|
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 |
|
#8
|
||||
|
||||
|
Re: Open CV help
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|