Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8600783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:41:35+00:00 2026-06-12T01:41:35+00:00

I’m using cvBlobs to track some objects in a video. cvBlobs uses the older

  • 0

I’m using cvBlobs to track some objects in a video. cvBlobs uses the older C interface with types like IplImage, cvMat, .. and I’m using the C++ interface which uses cv::Mat.

So I have to convert between the 2 types in order to use the library. This works but I’m having trouble releasing the memory. The memory used by my program keeps growing.

This is my code and at the bottom you can see my attempt at releasing the memory (compiler error).

void Tracker::LabelConnectedComponents(Mat& Frame, Mat& Foreground)
{
    // Convert to old format, this is the method used in the opencv cheatsheet
    IplImage IplFrame = Frame;
    IplImage IplForeground = Foreground;

    IplImage *LabelImg = cvCreateImage(cvGetSize(&IplFrame), IPL_DEPTH_LABEL, 1);

    // Make blobs (IplForeground is the segmented frame, 1 is foreground, 0 background)
    unsigned int result = cvLabel(&IplForeground, LabelImg, Blobs);

    // Remove small blobs
    cvFilterByArea(Blobs, 500, 1000000);

    // Draw bounding box
    cvRenderBlobs(LabelImg, Blobs, &IplFrame, &IplFrame, CV_BLOB_RENDER_BOUNDING_BOX | CV_BLOB_RENDER_CENTROID);

    // Convert back to c++ format
    Frame = cvarrToMat(&IplFrame);

    // Here are the problems
    cvReleaseImage(&IplFrame); // error
    cvReleaseImage(&IplForeground); // error
    cvReleaseImage(&LabelImg); // ok
}

cvReleaseImage has as argument an IplImage** type and this is the compiler error:

tracker.cpp|35 col 33 error| cannot convert ‘IplImage* {aka _IplImage*}’ to ‘IplImage** {aka _IplImage**}’ for argument ‘1’ to ‘void cvReleaseImage(IplImage**)’

I know &IplFrame isn’t the right argument but &&IplFrame doesn’t work. How can I release those 2 IplImages?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:41:36+00:00Added an answer on June 12, 2026 at 1:41 am

    The problem is that you have created copies of your objects here:

    IplImage IplFrame = Frame;
    IplImage IplForeground = Foreground;
    

    Therefore, these calls:

    cvReleaseImage(IplFrame); 
    cvReleaseImage(IplForeground);
    

    wouldn’t release the original images even if this would compile. If you are already deleting the objects (i.e. changing them) why do you send them to the method as references instead of pointers? I am a bit confused as it seems that you are doing something like this:

    Mat frame = ...
    Mat fg = ...
    LabelConnectedComponents(frame, fg); // function releases the frame/fg memory
    // at this point you are left with invalid frame/fg
    

    I have check the documentation, and it says Mat::operator IplImage() doesn't copy data, which means thay IplFrame doesn’t own the memory, so it is not correct to release it.

    I think it depends on how Mat instance was created – if it was created from IplImage* with copyData set to false, then you would need to release the original IplImage instance. If it was created with copyData set to true, then Mat instance automatically takes care of it (unless you do it explicitly with Mat::release)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.