0

I have a question about C++. I'm working with OpenCV. I'm pretty new to both.

I have this declaration:

struct scoredRotatedRect
{
    double score;
    RotatedRect ellipse;
    vector<Point> contour;

};

The problem is that when I declare a scoredRotatedRect, it recognizes the double as a member but not the non-primitive types as members.

I.e.,

cur_scoredRotatedRect.score=0; // not a problem
cur_scoredRotatedRect.ellipse=a_RotatedRect; // get an error

The error is

"'ellipse' : is not a member of 'scoredRotatedRect'".

What is causing this?


The problem turned out to be that I was doing this:

struct scoredRotatedRect
{
    double score;
    RotatedRect ellipse;
    vector<Point> contour;

};

using namespace std;
using namespace cv;

as opposed to this:

using namespace std;
using namespace cv;

struct scoredRotatedRect
{
    double score;
    RotatedRect ellipse;
    vector<Point> contour;

};

so I guess the initial struct declaration didn't know what RotatedRect was referring to and just ignored it (?)

4

1 回答 1

0

问题原来是我正在这样做:

struct scoredRotatedRect
{
    double score;
    RotatedRect ellipse;
    vector<Point> contour;

};

using namespace std;
using namespace cv;

与此相反:

using namespace std;
using namespace cv;

struct scoredRotatedRect
{
    double score;
    RotatedRect ellipse;
    vector<Point> contour;

};

所以我猜最初的结构声明不知道 RotatedRect 指的是什么,只是忽略了它(?)

于 2013-07-11T21:58:14.790 回答