rmsalinas / DBow3

Improved version of DBow2
Other
507 stars 238 forks source link

matrix.cpp:307: error: (-215) s >= 0 #12

Open liudongdong1 opened 7 years ago

liudongdong1 commented 7 years ago

i try this project and i meet a problem at Vocabulary voc("small_voc.yml.gz");the error is as follows:OpenCV Error: Assertion failed (s >= 0) in cv::setSize, file C:\build\master_winpack-build-win64-vc14\opencv\modules\core\src\matrix.cpp, line 307 C:\build\master_winpack-build-win64-vc14\opencv\modules\core\src\matrix.cpp:307: error: (-215) s >= 0 in function cv::setSize,and i don't know how to fix it

alashui commented 7 years ago

hi,@liudongdong1 Have you worked out any approach to solve the problem? I also meet that when I load a database file. I get the error at this statement: DBoW3::Database db( database_dir ); the error is as follows: OpenCV Error: Assertion failed (s >= 0) in setSize, file /home/robot/opencv-3.3.0/modules/core/src/matrix.cpp, line 310 terminate called after throwing an instance of 'cv::Exception' what(): /home/robot/opencv-3.3.0/modules/core/src/matrix.cpp:310: error: (-215) s >= 0 in function setSize

liudongdong1 commented 7 years ago

i found the answer which already solved by other in issues,and change it, void DescManip::fromString(cv::Mat &a, const std::string &s) { string ss_aux; stringstream ss(s); ss>>ss_aux; if(ss_aux.find("dbw3")==std::string::npos){ int val; vector data;data.reserve(100); while( ss>>val) data.push_back(val); a.create(1,data.size(),CV_8UC1); memcpy(a.ptr(0),&data[0],data.size()); } else{ int type,cols; ss >>type>>cols; a.create(1, cols, type); if(type==CV_8UC1){ unsigned char p = a.ptr(); int n; for(int i = 0; i < a.cols; ++i, ++p) if ( ss >> n) p = (unsigned char)n; } else{ float p = a.ptr(); for(int i = 0; i < a.cols; ++i, ++p) if ( !(ss >> p))cerr<<"Error reading. Unexpected EOF. DescManip::fromString"<<endl; }

}

} it does work

alashui commented 7 years ago

Thank you very much,it really works after change,but there are two small mistake in the code you given,

vector data;data.reserve(100);

float *p = a.ptr();

I corrected it and it worked.thank you!