View Single Post
  #2   Spotlight this post!  
Unread Yesterday, 18:53
SamCarlberg's Avatar
SamCarlberg SamCarlberg is offline
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 164
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Need help with running GRIP on roboRIO

The class that GRIP generates has methods for getting the outputs of every step. The last step (probably findContours or filterContours) is probably the one you want. You can get that output with GetFindContoursOutput or GetFilterContoursOutput, if you have it. This'll give you a std::vector of the contours. If you want to get the positions of each contour like GRIP does, you need to loop over them and call boundingRect on each one that you can use to find the centers.


Here's a little code snippet that can help. I haven't compiled or run this, but it should get you going.

Code:
auto contours = myGripPipeline.GetFilterContoursOutput();
std::vector<cv::Point> centers;

for (int i = 0; i < contours.size(); i++) {
  cv::Rect r = cv::boundingRect(contours[i]);
  int centerX = r.x + r.width / 2;
  int centerY = r.y + r.height / 2;
  centers.push_back(cv::Point(centerX, centerY));
}
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote