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;

};

最初の struct 宣言は RotatedRect が何を参照しているのかわからず、無視しただけだと思います (?)

于 2013-07-11T21:58:14.790 に答える