Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
82 views
in Technique[技术] by (71.8m points)

c++ - How to erase cv::circle from display window

I use OpenCV library for drawing circles on image. I need to erase last circle which was drawn on window by clicking on right button click. Currently, I wrote workaround, I replace red circle by white. but seems there is another solution such as erase it. How I can update my UI?

std::vector<Point2f> right_image;    // stores 4 points that the user clicks(mouse left click) in the main image.


if (e == EVENT_RBUTTONDOWN && right_image.size() > 0) {
            float x0 = right_image[right_image.size()-1].x;
            float y0 = right_image[right_image.size()-1].y;
            cv::circle(dispImg, cv::Point(x0, y0), 10, cv::Scalar(255, 255, 255), 3);
            cv::imshow(cv::String(fullWindowName), dispImg);
            right_image.pop_back();
        }
question from:https://stackoverflow.com/questions/65651652/how-to-erase-cvcircle-from-display-window

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It will be faster to store image without any overlays, and redraw circles each frame. If you want to append, move or delete circle just remove it from the list of objects to plot.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...