Allow users to specify an output cv::Mat when calling imdecode() (Patch #2396)


Added by Roy Reapor over 12 years ago. Updated over 12 years ago.


Status:Done Start date:2012-09-28
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:highgui-images
Target version:2.4.3
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

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

Revision 3572ee27
Added by Roman Donchenko almost 11 years ago

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

Also available in: Atom PDF