How to remove drawing from sensor_msgs Image topic?

asked 2019-03-11 04:13:56 -0500

dinesh gravatar image

updated 2019-03-11 04:39:23 -0500

gvdhoorn gravatar image

I have to draw few rectangles in image in such a way than when new rectangles arrives the previous rectangles i.e drawings has to be gone from the Mat. I tried to use image.release() but its not working. This is the line of code which is executed multiple time for different object detected in image.

Here is the code i'm trying:

cv::Mat OrigImg;
OrigImg = cv::Mat( cv_ptr->image.rows, cv_ptr->image.cols, CV_8UC3 );
while ( ... ) 

   for(auto v : obj_pixel)
        cv::rectangle(cv_ptr->image,cv::Point( v.x-0.5,v.y-

0.5),cv::Point( v.x+0.5,v.y+0.5),cv::Scalar( 255, 0, 0 ),cv::FILLED);
for(auto v : edge_pixel)
        cv::rectangle(cv_ptr->image,cv::Point( v.x-0.5,v.y-0.5),cv::Point( v.x+0.5,v.y+0.5),cv::Scalar( 0, 255, 0 ),cv::FILLED);

so how to solve this problem in every iteration of while loop new drawings had to be drawn in image.

edit retag flag offensive close merge delete