Ask Your Question

amaharajh's profile - activity

2013-03-26 14:19:13 -0600 received badge  Scholar (source)
2013-03-26 14:17:08 -0600 commented answer Destroying Windows in Separate Functions

Ahhh, so silly of me. I forgot to return an exit code from runProcessing() and check the exit code to break the for loop. Thank you for the assistance.

2013-03-26 14:16:20 -0600 received badge  Editor (source)
2013-03-26 13:36:15 -0600 asked a question Destroying Windows in Separate Functions

Hi everyone,

This may seem like a newbie question but I hope I can get some assistance with this problem I'm having.

I have an initialize function that sets up my cvCapture object to start capturing from a video file named initialize(). The cvCapture object named capture is created as a global variable just for testing purposes.

I have one function that creates three windows named A,B and C and this function does some processing with the windows showing their progress. Let's call this function runProcessing()

I want to destroy windows A,B and C in a separate function named releaseMemory() after runProcessing() has executed. However, when I try to call cvDestroyWindow() or cvDestroyAllWindows(), the program freezes and does not terminate correctly.

How do I go about destroying the windows properly seeing that they are created in another function instance in order to correctly exit my program?

Example source code:

int intialize(){
  ......
  capture = cvCreateFileCapture(filename);
  ......
}

int runProcessing(){
  ......
  cvNamedWindow("A", 1);
  cvNamedWindow("B", 2);
  cvNamedWindow("C", 3);
  ........
}

void releaseMemory(){
  cvReleaseCapture(&capture);
  cvDestroyWindow("A");
  cvDestroyWindow("B");
  cvDestroyWindow("C");
}

int main(){
  initialize();
  for(;;){
    runProcessing();
  }
  releaseMemory();
  return 0;
}