Guest User

Untitled

a guest
Jan 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. void Tracker::LabelConnectedComponents(Mat& Frame, Mat& Foreground)
  2. {
  3. // Convert to old format, this is the method used in the opencv cheatsheet
  4. IplImage IplFrame = Frame;
  5. IplImage IplForeground = Foreground;
  6.  
  7. IplImage *LabelImg = cvCreateImage(cvGetSize(&IplFrame), IPL_DEPTH_LABEL, 1);
  8.  
  9. // Make blobs (IplForeground is the segmented frame, 1 is foreground, 0 background)
  10. unsigned int result = cvLabel(&IplForeground, LabelImg, Blobs);
  11.  
  12. // Remove small blobs
  13. cvFilterByArea(Blobs, 500, 1000000);
  14.  
  15. // Draw bounding box
  16. cvRenderBlobs(LabelImg, Blobs, &IplFrame, &IplFrame, CV_BLOB_RENDER_BOUNDING_BOX | CV_BLOB_RENDER_CENTROID);
  17.  
  18. // Convert back to c++ format
  19. Frame = cvarrToMat(&IplFrame);
  20.  
  21. // Here are the problems
  22. cvReleaseImage(&IplFrame); // error
  23. cvReleaseImage(&IplForeground); // error
  24. cvReleaseImage(&LabelImg); // ok
  25. }
  26.  
  27. tracker.cpp|35 col 33 error| cannot convert ‘IplImage* {aka _IplImage*}’ to ‘IplImage** {aka _IplImage**}’ for argument ‘1’ to ‘void cvReleaseImage(IplImage**)’
  28.  
  29. IplImage IplFrame = Frame;
  30. IplImage IplForeground = Foreground;
  31.  
  32. cvReleaseImage(IplFrame);
  33. cvReleaseImage(IplForeground);
  34.  
  35. Mat frame = ...
  36. Mat fg = ...
  37. LabelConnectedComponents(frame, fg); // function releases the frame/fg memory
  38. // at this point you are left with invalid frame/fg
  39.  
  40. IplImage* pimg= cvLoadImage();
  41. ...
  42. cvReleaseImage(pimg);
  43.  
  44. IplImage img;
  45. ...
  46. cvReleaseImage(&&img);
Add Comment
Please, Sign In to add comment