Allow users to specify an output cv::Mat when calling imdecode() (Patch #2396)
Description
Allow users to specify output an output cv::Mat when calling imdecode(). The existing code creats a new cv::Mat each time imdecode() is called. We could save memory allocation when decoding multiple images of the same dimensions by specifying a destination cv::Mat.
Below is the suggested implementation:
highgui\highgui.hpp:
CV_EXPORTS_W Mat imdecode( InputArray buf, int flags, Mat* destination=0 );
highgui\src\loadsave.cpp:
Mat imdecode( InputArray _buf, int flags, Mat* destination ) { Mat buf = _buf.getMat(), img; Mat* decodeImg = (0 == destination) ? &img : destination; imdecode_( buf, flags, LOAD_MAT, decodeImg ); return *decodeImg; }
Associated revisions
Merge pull request #2396 from m3d:patch-1
History
Updated by Vadim Pisarevsky over 12 years ago
thanks! the feature has been implemented in c9f1490
- Status changed from Open to Done