Clear Filters
Clear Filters

How can this code be modernized?

1 view (last 30 days)
Francisco Sanchez
Francisco Sanchez on 5 Apr 2018
Answered: Prajit T R on 9 Apr 2018
So currently I came across a really interesting code which I want to implement in a school project.
While running it, I have come across the issue with vision.TextInserter. I know that the modern way to insert text is to use the function insertText but I cannot seem to figure out how to correctly execute that function. Can someone help me solve that issue?

Answers (1)

Prajit T R
Prajit T R on 9 Apr 2018
Hi Francisco
Here is an example of how you can modify the code to incorporate 'insertText':
%rgbFrame = step(vidDevice);
text_str= 'Red'
position = [5 2];
box_color = 'red'
htextinsRed = insertText(rgbFrame,position,text_str,'FontSize',18,'BoxColor',box_color,'BoxOpacity',0.4,'TextColor','white');
imshow(htextinsRed);
text_str= 'Green'
position = [5 18];
box_color = 'green'
htextinsGreen = insertText(rgbFrame,position,text_str,'FontSize',18,'BoxColor',box_color,'BoxOpacity',0.4,'TextColor','white');
imshow(htextinsGreen);
text_str= 'Blue'
position = [5 34];
box_color = 'blue'
htextinsBlue = insertText(rgbFrame,position,text_str,'FontSize',18,'BoxColor',box_color,'BoxOpacity',0.4,'TextColor','white');
For more details, you check out the folowing documentation link: https://www.mathworks.com/help/releases/R2017b/vision/ref/inserttext.html If any further changes are to be made, you can refer the above link for syntax and other information.
Hope this helps
Cheers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!