|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Need help with running GRIP on roboRIO
This is the first time for me to do vision process on our robot.
So far I figured out how to generate C++ code from GRIP. However, I don't know how can I get the values from the contours report without publishing the report to a network table. Are there methods that return those values or are they stored somewhere after the process? Appreciation for any help! |
|
#2
|
||||
|
||||
|
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));
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|