C++ 如何将图像转换为c+中的RGB数据值+;
我正在和我的团队(其中一个团队叫Rusty Huskies)一起为第一场比赛制作一个机器人。我们需要知道如何将图像转换为不同的rgb值,以便我们的机器人能够检测到我们正在查看的开关(开关是我们将块放置到增益点的位置) 所以结果是这样的:C++ 如何将图像转换为c+中的RGB数据值+;,c++,colors,robotics,C++,Colors,Robotics,我正在和我的团队(其中一个团队叫Rusty Huskies)一起为第一场比赛制作一个机器人。我们需要知道如何将图像转换为不同的rgb值,以便我们的机器人能够检测到我们正在查看的开关(开关是我们将块放置到增益点的位置) 所以结果是这样的: #include <color_reader.h> #include <string> class Robot: public frc::IterativeRobot { std::string color = ""; colorD
#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)
#包括
#包括
类Robot:public frc::IterativeRobot{
std::string color=“”;
彩色检测器;
colorDet.readImg(“image.png”);
r=色度测定值r;
g=色度单位g;
b=彩色数据点b;
如果(r>=150){
color=“红色”;
}否则{
color=“蓝色”;
}
};
启动机器人类(机器人)
提前谢谢你的帮助
在这篇文章中,同样的问题也会被讨论,这取决于相机制造商
您必须搜索库才能使用相机,编写代码可能太困难。在项目中安装OpenCV。它具有许多用于此类机器人项目的实时图像处理功能