The difference between cvcloneimage () and Cvcopy ()

Source: Internet
Author: User
Tags memory usage

Cvcloneimage () The compiler allocates new memory space each time it is used, does not overwrite the previous content, so if memory usage in the loop is reduced quickly, it needs to be freed with cvrelease each time it is exhausted.

The workaround is to use the Cvcopy function instead.
Cvcopy (Psrcimg,pimg,null); Instead of pImg = Cvcloneimage (psrcimg);
PIMG must allocate space when initializing, otherwise the function above cannot be executed.
PIMG = Cvcreateimage (Cvsize (imgwidht,imgheight), ipl_depth_8u, 3);

The difference between cvcopy () and Cvcloneimage () in OpenCV:

The prototype of Cvcopy is:
void cvcopy (const cvarr* SRC, cvarr* DST, const cvarr* mask=null);
Before using this function, you must first open a memory with a function of cvcreateimage () and pass it to DST. The cvcopy will copy the data in SRC into DST memory.

The prototype of Cvcloneimage is:
iplimage* cvcloneimage (const iplimage* image);
There is no need to open up memory before using the function. This function will open a memory for itself, then copy the data in the image, and then return the memory of the data to you.

Clone is to copy all of them, that is, whether you set Roi,coi and other parameters that affect copy, clone will be intact clone.
Copy is different, only the ROI region is copied.

After copying with clone, the copied image changes when the source image disappears in memory, and the copied image does not change after the source image disappears with copy.
Citation: http://hi.baidu.com/gilbertjuly/blog/item/9e78f511fd0938f7c2ce7978.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.