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