0

我正在尝试使用 javaCV 使用网络摄像头识别对象的颜色,并使 NXT 移动机器人根据检测到的颜色对象执行特定任务。

我无法识别物体的颜色。(基本上,我想区分蓝色和红色,并打印出检测到的颜色。)

谁能帮我 ?提前非常感谢!

4

1 回答 1

0

我建议BufferedImage从捕获中创建,并获取每个像素 RGB。一旦你到达那个点,只需使用这些函数来获取 RGB 值。

public static int getAlpha(int rgb) {
    return (rgb >> 24) & 0xFF;
}

public static int getRed(int rgb) {
    return (rgb >> 16) & 0xFF;
}

public static int getGreen(int rgb) {
    return (rgb >> 8) & 0xFF;
}

public static int getBlue(int rgb) {
    return rgb & 0xFF;
}
于 2013-04-10T18:45:08.850 回答