DBow3
DBow3 copied to clipboard
bug in "void DescManip::fromString(cv::Mat &a, const std::string &s)"
Hi! When I run the demo, demo_genera
, there was an error occurred show as follow:
... Done Creating a small database... OpenCV Error: Assertion failed (s >= 0) in setSize, file /home/koker/library/opencv/modules/core/src/matrix.cpp, line 306 /home/koker/library/opencv/modules/core/src/matrix.cpp:306: error: (-215) s >= 0 in function setSize ...
and the opencv I use was 3.1.0.
I debugged the codes and found that the error was occurred in file "src/DescManip.cpp" at a.create(1, cols, type);
(line 185).
because there were wrong values of type
and cols
loading from ss
.
there was my solution:
void DescManip::fromString(cv::Mat &a, const std::string &s)
{
//check if the dbow3 is present
string ss_aux;
stringstream ss(s);
ss>>ss_aus;
if(ss_aux.find("dbw3")==std::string::npos){//is dbow2
//READ UNTIL END
//stringstream ss(s);
int val;
vector<uchar> data;data.reserve(100);
while( ss>>val) data.push_back(val);
//copy to a
a.create(1,data.size(),CV_8UC1);
memcpy(a.ptr<char>(0),&data[0],data.size());
}
else{
int type,cols;
//stringstream ss(s);
ss >>type>>cols;
a.create(1, cols, type);
This has been fixed both in my branch and in @hcjghr's (who also issued a pull request #2) branch. @rmsalinas has not made the change.
Yes! I solved the same problem with @kokerf 's solution!
But, a little mistake in the solution:
ss>>ss_aus;
It should be:
ss>>ss_aux;