opencv c++ 질문입니다 움직이는 영상에 맞춰 표시를 해주려하는데 영상재생이안되네여

조회수 401회
int main() {
    VideoCapture capture;
    capture.open("pipoball.avi");
    CV_Assert(capture.isOpened());

    double frame_rate = capture.get(CAP_PROP_FPS);
    int delay = 1000 / frame_rate;
    Mat frame;
    int nofrm = 0;
    Point inball,accpt[30];

    while (capture.read(frame))
    {
        float pxcnt = 0;
        Point pt;
        Point inball(0, 0);

        if (waitKey(delay) >= 0) break;

        Mat dstimg(frame.size(), CV_8UC3);

        for (pt.y = 0; pt.y < frame.rows; pt.y++)
        {
            for (pt.x = 0; pt.x < frame.cols; pt.x++)
            {
                Vec3b val = frame.at<Vec3b>(pt.y, pt.x);

                float luma = 0.11 * (float)val[0] + 0.59 * (float)val[1] + 0.3 * (float)val[2];

                if (val[2] > 0.5 * luma && val[2] > 1.2 * val[0] && val[2] > 1.5 * val[1] && luma > 50.) {
                    dstimg.at<Vec3b>(pt.y, pt.x) = Vec3b(0, 255, 255); //yellow
                }
                nofrm++;
                if (pxcnt == 0) pxcnt = 1;
                inball /= pxcnt;
                int radius = (int)(sqrt((double)pxcnt / 3.14));
                circle(dstimg, inball, radius, CV_RGB(255, 0, 0), 2);
                rectangle(dstimg, Point(inball.x - radius, inball.y - radius), Point(inball.x + radius, inball.y + radius), CV_RGB(0, 0, 0), 2);

                //30개 이상의 프레임에 대해 중심점 표시
                accpt[(nofrm - 1) % 30] = inball;
                if (nofrm >= 100) {
                    for (int k = 0; k < 29; k++) {
                        line(dstimg, accpt[(nofrm - k - 1) % 30], accpt[(nofrm - k - 2) % 30],CV_RGB(0,255,0 ));
                    }
                }
            }putText(dstimg, "A", inball, FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(0, 0, 0));

            imshow("결과영상",dstimg);
            imshow("동영상 파일읽기", frame);
        }
        waitKey(0);
        return 0;
    }
}

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)