我正在标记我的图像,但是我的这部分代码给了我错误运行时错误,我将标签分配给它,当我删除此行代码运行良好:
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 给包含负图像的目录,nb_face
是file.size()
正图像的目录