Skip to content

Commit

Permalink
Fixed Torch parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Lyudvichenko committed Jul 30, 2015
1 parent 4da1046 commit 7d795af
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 55 deletions.
40 changes: 40 additions & 0 deletions modules/dnn/include/opencv2/dnn/dict.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <opencv2/core.hpp>
#include <map>
#include <ostream>

namespace cv
{
Expand Down Expand Up @@ -35,6 +36,8 @@ struct DictValue

DictValue &operator=(const DictValue &r);

friend std::ostream &operator<<(std::ostream &stream, const DictValue &dictv);

~DictValue();

protected:
Expand Down Expand Up @@ -135,6 +138,8 @@ class CV_EXPORTS Dict

return value;
}

friend std::ostream &operator<<(std::ostream &stream, const Dict &dict);
};

template<>
Expand Down Expand Up @@ -299,6 +304,41 @@ inline int DictValue::size() const
}
}

inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv)
{
int i;

if (dictv.isInt())
{
for (i = 0; i < dictv.size() - 1; i++)
stream << dictv.get<int64>(i) << ", ";
stream << dictv.get<int64>(i);
}
else if (dictv.isReal())
{
for (i = 0; i < dictv.size() - 1; i++)
stream << dictv.get<double>(i) << ", ";
stream << dictv.get<double>(i);
}
else if (dictv.isString())
{
for (i = 0; i < dictv.size() - 1; i++)
stream << "\"" << dictv.get<String>(i) << "\", ";
stream << dictv.get<String>(i);
}

return stream;
}

inline std::ostream &operator<<(std::ostream &stream, const Dict &dict)
{
Dict::_Dict::const_iterator it;
for (it = dict.dict.begin(); it != dict.dict.end(); it++)
stream << it->first << " : " << it->second << "\n";

return stream;
}

}
}

Expand Down
Loading

0 comments on commit 7d795af

Please sign in to comment.