View Single Post
  #7   Spotlight this post!  
Unread 12-01-2016, 21:51
ThomasClark's Avatar
ThomasClark ThomasClark is offline
Registered User
FRC #0237
 
Join Date: Dec 2012
Location: Watertown, CT
Posts: 146
ThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud of
Re: GRIP - Vision Processing

Quote:
Originally Posted by tomy View Post
Also how do I use the information back
The C++ example on this page shows how to print the area and x/y coordinates of each target.

Assuming you're able to get this far, exactly how you use this data depends on your robot and your strategy. For example, if you're trying to like the robot up horizontally with the biggest target, you might do something like this. (This is a really oversimplified example, but hopefully it serves as a good starting point)

PHP Code:
const double CENTER_X 320.0;
const 
double TOLERANCE_X 20.0;

void AutoShoot() {
    while (
true) {
        
auto areas grip->GetNumberArray("myContoursReport/area"llvm::ArrayRef<double>()),
             
xs    grip->GetNumberArray("myContoursReport/x",    llvm::ArrayRef<double>());

        
// Pick whatever target has the biggest area
        
double targetArea = -1.0targetX 0.0;
        for (
int i 0areas.size(); i++) {
            if (
areas[i] > targetArea) {
                
targetArea areas[i];
                
targetX xs[i];
            }
        }
        
        
// If we didn't find a target, return control to the operator
        
if (targetArea 0.0) {
            return;
        }

        
// If we're too far to the left to shoot, move right.  If we're too far
        // to the right, move left.  If we're spot on, shoot and return.
        
if (targetX CENTER_X TOLERANCE_X) {
            
MoveRobotRight();
        } else if (
targetX CENTER_X TOLERANCE_X) {
            
MoveRobotLeft();
        } else {
            
ShootBoulder();
            return;
        }
    }

__________________
GRIP (Graphically Represented Image Processing) - rapidly develop computer vision algorithms for FRC

Last edited by ThomasClark : 12-01-2016 at 21:54.