Info
This question is closed. Reopen it to edit or answer.
Webcam video, live figure calculations are showing on top of themselves instead of replacing
1 view (last 30 days)
Show older comments
Hi, so I have written code for color object traking of 2 different tags, one red one yellow, and my code is able to run on a live webcam, showing the border and calculating the distances between the two tags.
I had done this previously on a sinlge image and had worked perfectly, now with the webcam it still works, however, the distances that are labelled on the image, instead of each distance figure removing and replacing when I move the tags, it places the new number over the top of the previous number. This means after a couple iterations you cannot see the text as the repeated placement of new numbers over old means you cannot see the current figure.
The following is a section of the code for displaying the figure with the border and centroid and distances. For context, RGB is the snapshot taken for the video, rj/ri/yj/yi are the i & j coordinates for red and yellow tags, redYellowOverlay is the code for the border.
imshow(RGB);
hold on;
plot(rjMean,riMean, 'g-x', 'LineWidth',5)
plot(yjMean,yiMean, 'g-x', 'LineWidth',5)
plot([rjMean,yjMean],[riMean,yiMean],'b','LineWidth',2);
dim = [0.15 0.3 0.3 0];
str = {['Red Tag Centroid i coordinates = ',num2str(riMean)],['Red Tag Centroid j coordinates = ',num2str(rjMean)],['Yellow Tag Centroid i coordinates = ',num2str(yiMean)],['Yellow Tag Centroid j coordinates = ',num2str(yjMean)],['City Block Distance = ',num2str(dCityBlock)],['Chessboard Distance = ',num2str(dChessboard)],['Euclidean Distance = ',num2str(dEuclidean)]};
annotation('textbox',dim,'String',str,'FitBoxToText','on','EdgeColor','green','Color','green');
imshow(redYellowOverlay);
For more context this is the output of this code on a still image:
And this is the output of the same code in the video, as you can see the text is unreadable due to so many iterations of the distances being placed ontop of each other:
Is there something I have missed or I can add so that the centroid/distance figure replace the old figures instead of adding them ontop of previous iterations?
Thanks in advance for any help.
0 Comments
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!