私は自分の画像にラベルを付けていますが、私のコードのこの部分は私にエラーランタイムエラーを与えます.ここで私はそれにラベルを割り当てます.この行コードを削除すると正常に実行されます.
int count_2=0;
cv::Mat training_mat(num_img , dictionarySize,CV_32FC1);
cv::Mat labels(0,1,CV_32FC1);
for (k = all_names.begin(); k != all_names.end(); ++k)
{
Dir=( (count_2 < files.size() ) ? YourImagesDirectory : YourImagesDirectory_2);
Mat row_img_2 = cv::imread( Dir +*k, 0 );
detector.detect( row_img_2, keypoints);
RetainBestKeypoints(keypoints, 20);
dextract.compute( row_img_2, keypoints, descriptors_1);
Mat my_img = descriptors_1.reshape(1,1);
my_img.convertTo( training_mat.row(count_2), CV_32FC1 );
//training_mat.push_back(descriptors_1);
***Here is the error***
//labels.at< float >(count_2, 0) = (count_2<nb_face)?1:-1; // 1 for face, -1 otherwise*/
++count_2;
}
私のコードの一部の上で、ポジティブなイメージを含むディレクトリに1を与え、ネガティブなイメージを含むイメージのディレクトリに-1を与えたいのnb_face
はfile.size()
、ポジティブなイメージです