C++ 圆霍夫中心坐标

C++ 圆霍夫中心坐标,c++,opencv,C++,Opencv,在opencv中,我对圆查找器使用了Hough变换。下面是代码 HoughCircles (diff, circles, CV_HOUGH_GRADIENT, 2, src.cols / 5, 200, 80, 20, 62); for (size_t i = 0; i < circles.size(); i++ ) { //if(circles[i][2]<62) { Point center(cvRound(circles[i][0]),

opencv
中,我对圆查找器使用了Hough变换。下面是代码

HoughCircles (diff, circles, CV_HOUGH_GRADIENT, 2, src.cols / 5, 200, 80, 20, 62);    

for (size_t i = 0; i < circles.size(); i++ )
{
    //if(circles[i][2]<62)
    {
        Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
        int radius = cvRound(circles[i][2]);
        // draw the green circle center
        circle( src, center, 3, Scalar(0,255,255), -1, 8, 0 );
        // draw the blue circle outline
        circle(src, center, radius, Scalar(0,255,0), 3, 8, 0 );
    }
}
HOUGH圆(diff,圆,CV_-HOUGH_梯度,2,src.cols/5200,80,20,62);
对于(size_t i=0;i//如果(圈[i][2]嗯,这很有趣。我运行了你的代码并填写了前后两次,没有任何问题。老实说,我只在linux和mac机器上进行了测试。这是我的完整代码,试试看会发生什么。另外,请检查此解决方案

intmain(intargc,char*argv[]){
视频捕获(0);
如果(!capture.isOpened()){
日志(致命)>帧;
if(frame.empty()){
日志(致命)>帧;
席灰色;
CVT颜色(边框、灰色、CV_BGR2灰色);
高斯模糊(灰色,灰色,大小(9,9),2,2);
矢量圆;
霍夫圆(灰色,圆,CV_-HOUGH_梯度,2,灰色.cols/5200,80,20,62);
对于(大小i=0;i
int main(int argc, char* argv[]) {

VideoCapture capture(0);
if (!capture.isOpened()) {
    LOG(FATAL) << "COULD NOT OPEN CAPTURE";
}

Mat frame;
capture >> frame;
if (frame.empty()) {
    LOG(FATAL) << "FRAME IS EMPTY!";
}

char key;
while ((int)key != 27) {

    capture >> frame;

    Mat gray;
    cvtColor(frame, gray, CV_BGR2GRAY);
    GaussianBlur(gray, gray, Size(9, 9), 2, 2);

    vector<Vec3f> circles;
    HoughCircles(gray, circles, CV_HOUGH_GRADIENT, 2, gray.cols/5,200,80,20,62);

    for (size_t i = 0; i < circles.size(); ++i) {
        Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
        int radius = cvRound(circles[i][2]);
        // draw the green circle center
        circle(frame, center, 3, Scalar(0,255,255), -1, 8, 0 );
        // draw the blue circle outline
        circle(frame, center, radius, Scalar(0,255,0), 3, 8, 0 );
    }

    imshow("frame", frame);
    key = waitKey(1);
}

return 0;
}