I am creating a robot along with my team (of which is called The Rusty Huskies) for a FIRST competition. We need to know how to convert an image to different values of rgb so that our robot can detect which switch we are looking at (the switch is where we would be placing our blocks to gain points).
So it would turn out to be something like this:
#include <color_reader.h>
#include <string>
class Robot: public frc::IterativeRobot {
std::string color = "";
colorDetector colorDet;
colorDet.readImg("image.png");
r = colorDet.r;
g = colorDet.g;
b = colorDet.b;
if (r >= 150) {
color = "red";
} else {
color = "blue";
}
};
START_ROBOT_CLASS(Robot)
Thanks for any help in advance!