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

我对向量下标超出范围存在问题。Eyes[0]表示左眼,而Eye [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);
评论