I'm at home not on a computer with code, but I believe you can use Mat in the old cv functions as follows Mat planes = ... from bridge or wherever. (whereever an IplImage is produced, you can just assign it to a Mat). . . . IplImage cv_planes_0 = planes; Then use IplImage as normal in the old cv functions. The memory will do the right thing. On Sat, May 22, 2010 at 5:20 PM, Patrick Mihelich wrote: > In your example, im_left is owned by left_bridge and should not be > released. However any images you create yourself do need to be released. The > memory leak is from not releasing "test". > > The original OpenCV C APIworks with IplImage's. The new C++ > API cv::Mat > is easier to use and avoids having to release memory manually. > > cv_bridge only uses IplImage because it predates the OpenCV C++ API. The > next revision of cv_bridge will likely use cv::Mat, precisely to avoid this > sort of confusion. > > Patrick > > > On Sat, May 22, 2010 at 4:54 PM, chriss lei wrote: > >> >> Hello Radu, >> >> I'm well aware of using cvReleaseImage.. >> Memory leak happens even if I use a single function on IplImage converted >> from sensor_msgs. >> Here's my callback function to illustrate. Usage of cvCopy here introduces >> memory blowup problem. >> >> void callback(const sensor_msgs::CameraInfo::ConstPtr& info, >> const sensor_msgs::ImageConstPtr& left, >> const stereo_msgs::DisparityImageConstPtr& >> disparity_msg) >> { >> >> im_left = left_bridge.imgMsgToCv(left, "passthrough"); >> >> disp_bridge.fromImage(disparity_msg->image, "passthrough"); >> dispImg = disp_bridge.toIpl(); >> >> cvShowImage("left", im_left); >> >> IplImage* test = NULL; >> test = cvCreateImage(cvGetSize(dispImg), dispImg->depth, >> 1); >> cvCopy(dispImg, test); >> cvShowImage("disp", test); >> } >> >> Also, I'm not supposed to deallocate any IplImages that are converted from >> sensor_msgs as described in cvBridge tutorial. >> Is there a way to use opencv functions on IplImages and not use cv::Mat ? >> >> -- >> View this message in context: >> http://ros-users.122217.n3.nabble.com/cvBridge-opencv-memory-leak-problem-tp837144p837162.html >> Sent from the ROS-Users mailing list archive at Nabble.com. >> >> >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> ros-users mailing list >> ros-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/ros-users >> _______________________________________________ >> ros-users mailing list >> ros-users@code.ros.org >> https://code.ros.org/mailman/listinfo/ros-users >> > > > _______________________________________________ > ros-users mailing list > ros-users@code.ros.org > https://code.ros.org/mailman/listinfo/ros-users > >