completely new C++ persistence implementation#13011
Conversation
…OpenCV compiles fine! the tests have not been run yet
…amples from build
alalek
left a comment
There was a problem hiding this comment.
It would be nice to resolve interface/public API/public headers issues.
Implementation-specific issues have lower priority and they are mostly come from previous implementation.
| APPEND = 2, //!< value, open the file for appending | ||
| MEMORY = 4, //!< flag, read data from source or write data to the internal buffer (which is | ||
| //!< returned by FileStorage::release) | ||
| //!< returned by FileStorage::release) |
| The full constructor opens the file. Alternatively you can use the default constructor and then | ||
| call FileStorage::open. | ||
| The full constructor opens the file. Alternatively you can use the default constructor and then | ||
| call FileStorage::open. |
There was a problem hiding this comment.
unnecessary indentation changes here and below
| int state; //!< the writer state | ||
| }; | ||
| int state; | ||
| std::string elname; |
There was a problem hiding this comment.
Private implementation details should be avoided.
Also related enum (line 321) should go away from public headers:
enum
{
UNDEFINED = 0,
VALUE_EXPECTED = 1,
NAME_EXPECTED = 2,
INSIDE_MAP = 4
};
Especially it is re-implemented here.
|
|
||
| /** @brief Returns type of the node. | ||
| @returns Type of the node. See FileNode::Type | ||
| @returns Type of the node. See FileNode::Type |
There was a problem hiding this comment.
FileNode::Type
Reference is broken because name of enum is dropped.
Why?
| #endif | ||
| } | ||
|
|
||
| static inline void writeReal(uchar* p, double fval) |
There was a problem hiding this comment.
API of these functions doesn't look safe.
Who controls and checks size of available buffer?
| { | ||
| const uchar* p = ptr(); | ||
| if( !p || (*p & TYPE_MASK) != STRING ) | ||
| return std::string(); |
| const uchar* p = ptr(); | ||
| if( !p || (*p & TYPE_MASK) != STRING ) | ||
| return std::string(); | ||
| p += (*p & NAMED) ? 5 : 1; |
| Usually it is more convenient to use operator `>>` instead of this method. | ||
| @param fmt Specification of each array element. See @ref format_spec "format specification" | ||
| @param vec Pointer to the destination array. | ||
| @param len Number of elements to read. If it is greater than number of remaining elements then all |
There was a problem hiding this comment.
yes, the description is wrong; it confused me too. it's always used as the buffer size. We need to fix it.
| " -\n" | ||
| " name: algorithm\n" | ||
| " type: 9\n" // FLANN_INDEX_TYPE_ALGORITHM | ||
| " value: 6\n"// this line is changed! |
There was a problem hiding this comment.
this line is changed!
Do we still need this?
Where is it from? It is not a part of my drop CV_USRTYPE1 patch.
There was a problem hiding this comment.
I basically copied 1:1 one of java tests that, since I did not want to debug java tests. If we remove FLANN sometimes (not in OpenCV 4.0, I guess), this test can be removed as well.
| return false; | ||
| FileNode oldroot = oldfs.getFirstTopLevelNode(); | ||
|
|
||
| bool ok = haar_cvt::convert(oldroot, newfs); |
There was a problem hiding this comment.
IMHO, This conversion code should be placed near traincascade app.
There was a problem hiding this comment.
disagree. Support of the old-style XML haar detector formats does not take much code, it's one little function. And it let me not to convert the old XML cascades in the test data to the new format, but rather read and use them as-is. Let's retain it in objdetect.
But it definitely makes sense to remove completely the old C-API Haar/LBP detector code from objdetect before 4.0. I'll prepare the corresponding PR shortly.
|
@alalek, thank you for the thorough review! at least some of the points really make sense to address. Let's merge your 3.4=>master patch and then do some other big coarse-scale changes (move modules between opencv and opencv_contrib, remove some old stuff) and then I make extra PR or a few that fix some of the found issues |
| endif() | ||
| endmacro() | ||
|
|
||
| ocv_add_app(traincascade) |
There was a problem hiding this comment.
Why are createsamples and traincascade not included in this build?
* integrated the new C++ persistence; removed old persistence; most of OpenCV compiles fine! the tests have not been run yet * fixed multiple bugs in the new C++ persistence * fixed raw size of the parsed empty sequences * [temporarily] excluded obsolete applications traincascade and createsamples from build * fixed several compiler warnings and multiple test failures * undo changes in cocoa window rendering (that was fixed in another PR) * fixed more compile warnings and the remaining test failures (hopefully) * trying to fix the last little warning
replaced the old persistence (CvMemStorage, CvSeq-based) with the new C++ implementation. The new persistence provides the same C++ API. The C API has gone. FileNodeIterator is now just one-directional, but the parsed file storage takes 3-4x less memory than in the previous implementation.