Ask Your Question
0

when is use the 'Vector' Command, it breaks my code evrytime. Is there any alternate to use other than 'vector' command

asked 2016-06-07 13:49:30 -0600

Example, Using the command 'vector<vec3f> circles;' breaks the code in the below program

include "opencv2/highgui/highgui.hpp"

include "opencv2/imgproc/imgproc.hpp"

include <iostream>

include <stdio.h>

using namespace cv;

/* @function main */ int main(int argc, char* argv) { Mat src, src_gray;

/// Read the image
src = imread(argv[1], 1);

if (!src.data)
{
    return -1;
}

/// Convert it to gray
cvtColor(src, src_gray, CV_BGR2GRAY);

/// Reduce the noise so we avoid false circle detection
GaussianBlur(src_gray, src_gray, Size(9, 9), 2, 2);

vector<Vec3f> circles;

/// Apply the Hough Transform to find the circles
HoughCircles(src_gray, circles, CV_HOUGH_GRADIENT, 1, src_gray.rows / 8, 200, 100, 0, 0);

/// Draw the circles detected
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]);
    // circle center
    circle(src, center, 3, Scalar(0, 255, 0), -1, 8, 0);
    // circle outline
    circle(src, center, radius, Scalar(0, 0, 255), 3, 8, 0);
}

/// Show your results
namedWindow("Hough Circle Transform Demo", CV_WINDOW_AUTOSIZE);
imshow("Hough Circle Transform Demo", src);

waitKey(0);
return 0;

}

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-07 23:42:06 -0600

Tetragramm gravatar image

Make sure you're including the vector header file

#include <vector>

Make sure to familiarize yourself with the basics of C++. You should know this.

edit flag offensive delete link more

Comments

1

also:

using std::vector;

or even:

using namespace std;
berak gravatar imageberak ( 2016-06-07 23:51:15 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-07 13:49:30 -0600

Seen: 61 times

Last updated: Jun 07 '16