当我使用vs2013 + opencv3.0来运行我的项目时,我发现函数“imread”无法读取图像,除非image_list中只有一行。有人说它是因为“readImageList”函数可以不认识txt文件中的换行符,我不知道怎么办。有人能解决这个问题吗?
string model_path = "E:\\images\\opencv3.0\\opencv_contrib-master\\modules\\dpm\\samples\\data\\inriaperson.xml";
string image_dir = "E:\\images\\opencv3.0\\DPMopencv\\INRIAPerson";
string image_list = "E:\\images\\opencv3.0\\DPMopencv\\INRIAPerson\\Test\\pos1.lst";
if( model_path.empty() || image_dir.empty() )
{
help();
return -1;
}
vector<string> imgFileList;
if ( !readImageLists(image_list, imgFileList) )
return -1;
for (size_t i = 0; i < imgFileList.size(); i++)
{
double t = (double) getTickCount();
vector<DPMDetector::ObjectDetection> ds;
string imageFile = image_dir + "\\" + imgFileList[i];
Mat image = imread(imageFile);
frame = image.clone();
if (image.empty()) {
cerr << "\nInvalid image:\n" << imgFileList[i] << endl;
return -1;
}
答案 0 :(得分:0)
我通过更改读取image_list文件的方式解决了这个问题:
NEW
A thread that has not yet started is in this state.
RUNNABLE
A thread executing in the Java virtual machine is in this state.
BLOCKED
A thread that is blocked waiting for a monitor lock is in this state.
WAITING
A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
TIMED_WAITING
A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.
TERMINATED
A thread that has exited is in this state.
string model_path = "E:\\images\\opencv3.0\\opencv_contribmaster\\modules\\dpm\\samples\\data\\inriaperson.xml";