C ++向量下标超出了opencv的范围

时间:2020-05-17 11:41:31

标签: c++ opencv

我在向量下标超出范围方面遇到问题。Eyes[0]表示左眼,而Eye [1]表示右眼。下面的代码功能允许一个称为eyecascade的OpenCV函数跟踪眼睛,并且我已经编辑了它可以输出眼睛的坐标,但是对于右眼[1],我相信它会导致矢量超出范围。

vector<Rect> eyes;
        eyeCascade.detectMultiScale(faceROI, eyes);
        unsigned int x = eyes.size();
        {
            Point eye_center(eyes[0].x + eyes[0].width / 2,  eyes[0].y + eyes[0].height / 2);
            int radius = cvRound((eyes[0].width + eyes[0].height)*0.25);
            circle(frame, eye_center, radius, Scalar(255, 0, 0), 5);
            printf("eyes0_x;%d", eyes[0].x);
            printf(" eyes0_y;%d\n",eyes[0].y );
            circle(frame, eye_center, radius, Scalar(255, 0, 0), 5);
            printf("eyes1_x;%d", eyes[(1)].x);
            printf(" eyes1_y;%d\n", eyes[(1)].y);

0 个答案:

没有答案