次のコードで問題が発生しましたが、何時間も解決できません...どんな種類のアドバイスでもうれしいです。
タイプは次のように定義されています。
typedef std::vector< cv::RotatedRect > ds_t;
typedef struct id_ {
std::string path;
std::string fileName;
} id_t;
typedef struct dd_ {
cv::RotatedRect bB;
} dd_t;
typedef std::pair<id_t, std::vector<dd_t> > ts_t;
typedef std::vector<ts_t> tss_t;
次に、型にデータを入力しようとします。
tss_t samples
while (readdir(pDir) != NULL) {
ts_t sample;
sample.first.path = _path;
sample.first.fileName = _name;
ds_t detections;
getDetections(_path, detections); //this only filles the detecions byref
for(size_t i=0; i<detections.size(); i++) {
dd_t data;
data.bB = detections[i];
sample.second.push_back(data); //TODO FIXME
}
samples.push_back(sample);
}
cv::RotatedRect は非常に基本的なクラスです。
class RotatedRect{
public:
RotatedRect();
RotatedRect(const Point2f& _center, const Size2f& _size, float _angle);
void points(Point2f pts[]) const;
Point2f center;
Size2f size;
float angle;
};
bool getDetections(const std::string &imagePath, ds_t &detections)
{
//some processing
for(size_t i=0;i<5;i++)
detections.push_back(RotatedRect(cv::Point2f(110.,110.), cv::Size2f(10.,10.), 90.0f));
return true;
}
うまくいけば、コード全体をコピーしたので、ほとんどの typedef は必要ありません...
すでにスペースを予約しようとしましたが、これはエラーを samples.push_back に延期するだけです。
FIXME によって誤った行が示され、「'std::bad_alloc' のインスタンスをスローした後に終了が呼び出されました」
事前にアドバイスをありがとう。