This OpenCV Bitmap blending application can be optimized, meaning the issues it is having with poor memory allocations that are resulting in the memory leaks can be fixed. There is an OpenCV API called cvReleaseImage(IplImage **img) that can be used to release memory that is no longer needed by an Bitmap image that has already been processed (blended). Where would you place this API in the source code to fix the application's memory leak issues?
- [Instructor] Go ahead and open up…the exercise files folder for this video.…We're going to double click on BlendBitmaps,…then let's double click on Source, and then…double click on BlendBitmaps Visual Studio solution.…If you don't have access to the exercise files,…follow along inside your own Visual Studio solution.…Once the project is loaded, let's click on main.cpp…and at the very top, you will see…a #define SAFE_RELEASE.…This is used for properly releasing memory…that is no longer needed by the application.…
We can fix our memory leak issue by using this #define,…the question is, where do we place this?…SAFE_RELEASE takes in a single argument.…It then uses the open CV function cvReleaseImage…to free the memory being consumed by an image.…We want to pass an image as the argument…x that we want released.…Where do we use this?…That I will leave up to you as part of a challenge.…Take a few minutes to tinker around…and then we can compare solutions.…
- Setting up the application
- Looking at the source code
- Gathering memory leak evidence
- Optimizing the application