Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/132.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ OpenCV对象识别与四旋翼机r/c控制接口_C++_Opencv_Computer Vision - Fatal编程技术网

C++ OpenCV对象识别与四旋翼机r/c控制接口

C++ OpenCV对象识别与四旋翼机r/c控制接口,c++,opencv,computer-vision,C++,Opencv,Computer Vision,我们正试图使用安装在四架直升机上的无线摄像机,使用HSV颜色阈值来跟踪地面上的物体。无线命令通过Futaba R/C控制器发送,该控制器使用USB接口连接到我们的Linux计算机。Qt用于运行和编译我们的C++代码。p> 目标是确定一个特定颜色的物体在视野内,然后命令被发送到四架直升机,四架直升机将指示飞行器向该物体飞去。目前,物体的几何中心已被找到,其像素坐标用于决定飞行器的飞行方向。在下面列出的代码中,即使屏幕上没有对象,也会发送命令 为什么在一个物体出现在视野中之前,命令被发送到飞行器上?

我们正试图使用安装在四架直升机上的无线摄像机,使用HSV颜色阈值来跟踪地面上的物体。无线命令通过Futaba R/C控制器发送,该控制器使用USB接口连接到我们的Linux计算机。Qt用于运行和编译我们的C++代码。p> 目标是确定一个特定颜色的物体在视野内,然后命令被发送到四架直升机,四架直升机将指示飞行器向该物体飞去。目前,物体的几何中心已被找到,其像素坐标用于决定飞行器的飞行方向。在下面列出的代码中,即使屏幕上没有对象,也会发送命令

为什么在一个物体出现在视野中之前,命令被发送到飞行器上?为什么飞船在物体到达屏幕中央后仍继续作出反应?240像素

我的猜测是循环结构不正确,但我几乎没有编码经验,希望您能提供帮助!谢谢

int main(int argc, char* argv[])
{


    //Matrix to store camera frames
    Mat cameraFeed;
    Mat threshold,thresholdRed,thresholdBlue,thresholdGreen;
    Mat HSV;

    VideoCapture capture;
    capture.open(0);
    capture.set(CV_CAP_PROP_FRAME_WIDTH,FRAME_WIDTH);
    capture.set(CV_CAP_PROP_FRAME_HEIGHT,FRAME_HEIGHT);

    //Create infinite loop
    bool loop = true;
    while(loop)
    {
        capture >> cameraFeed;
        capture.read(cameraFeed);

        //Convert to HSV
        cvtColor(cameraFeed,HSV,COLOR_BGR2HSV);

        //ADD GAUSIAN BLUR
        GaussianBlur(HSV,HSV,Size(5,5),0,0);

        Object groundRobotRed("groundRobotRed");

        //Values taken from trackbars
        groundRobotRed.setHSVmin(Scalar(18, 44, 103));
        groundRobotRed.setHSVmax(Scalar(36,142,249));

        inRange(HSV,groundRobotRed.getHSVmin(),groundRobotRed.getHSVmax(),thresholdRed);
        morphOps(thresholdRed);
        trackFilteredObject(groundRobotRed,thresholdRed,HSV,cameraFeed);

            //Quadcopter Systems Check
            if (flying == 0)
            {
                std::cout<<"hello:"<<std::endl;
                test_control.conn();
                test=test_control.isConnected();
                cout<<"test:"<<test<<endl;
                if (test)
                    testing();
                else
                    loop = false;
            }


         //If object is located on the top of the screen
         if(groundRobotRed.getYPos()<<240)
         {
         //Pitch forward command
         test_control.transmit(570, 565, 500, 500, 0, 0, 0, 0, 0);
         std:cout<<"Pitch Complete"<<std::endl;
         }
         else
         {
           //Hover command
           test_control.transmit(570,565,500,500,0,0,0,0,0);
         }


            capture.release();
            HSV.release();
            thresholdRed.release();

            capture.open(0);


            imshow(windowName,cameraFeed);
            waitKey(10);


        }

    return 0;
} 

groundRobotRed.getYPos的返回值是多少,如果这是一个数值,那么为什么要使用按位左运算符groundRobotRed.getYPos返回一个数值,我没有注意到