How to remove drawing from sensor_msgs Image topic?
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 );
cv_ptr->image.copyTo(OrigImg);
while ( ... )
OrigImg.copyTo(cv_ptr->image)
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);
}
obj_count++;
image_pub_.publish(cv_ptr->toImageMsg());
so how to solve this problem in every iteration of while loop new drawings had to be drawn in image.
Asked by dinesh on 2019-03-11 04:13:56 UTC
Comments