I can not write text on an image by insertText
Ältere Kommentare anzeigen
I have been trying to write text on generated figure using the insertText function. Even when using the following example code given in the Mathworks website:
I=imread('peppers.png');
position=[1 50; 100 50];
value=['55' '66'];
RGB=insertText(I,position,value);
and I keep getting the error:
Error using +
Invalid type of input arguments (should be uint64)
Error in insertText>populateGlyphBuffer_sim (line 832)
thisValue = uint16(fontHashTable.Count+1);
Error in insertText (line 146)
populateGlyphBuffer_sim(font,fontFileName,faceIndex,fontSize);
Error in Untitled5 (line 4)
RGB=insertText(I,position,value);
I've changed the format of figure from uint8 to uint 16 but it doesn't help. Is there any mistake I missed? or is it the version issue? I'm using 2021b Matlab.
4 Kommentare
I just tested in 2021b, no issues.
I=imread('peppers.png');
position=[1 50; 100 50];
value=['55' '66'];
RGB=insertText(I,position,value);
imshow(RGB)
Can you type the following?
which insertText -all
Walter Roberson
am 13 Jan. 2022
That is strange. I am having trouble finding any circumstances under which that is a possible message.
I would suggest putting in a breakpoint at line 832 of insertText, and checking what class(fontHashTable.Count) is, and trying
fontHashTable.Count+1
at the command line. Also, for debugging purposes, please show us
typecast(fontHashTable.Count, 'uint8')
Question: would you just happen to be using a custom JAVA configuration ?
Zhangziyi Zhou
am 28 Jan. 2022
@Walter Roberson I'm experiencing the same issue.
Map with properties:
Count: 0
KeyType: char
ValueType: uint16
fontHashTable.Count
ans =
uint64
0
typecast(fontHashTable.Count, 'uint8')
ans =
1×8 uint8 row vector
0 0 0 0 0 0 0 0
Hi,
I'm having exactly the same issue described in this question. i have a new installation of Matlab R2023b on a new windows machine, and I get exactly the error messages described here
I=imread('peppers.png');
position=[1 50; 100 50];
value=['55' '66'];
RGB=insertText(I,position,value);
Error using +
Invalid type of input arguments (should be uint64)
Error in insertText>populateGlyphBuffer_sim (line 800)
thisValue = uint16(fontHashTable.Count+1);
Error in insertText (line 149)
populateGlyphBuffer_sim(font,fontFileName,faceIndex,fontSize);
>>
I've also tried some of the checks recommended
>> which insertText -all
C:\Program Files\MATLAB\R2023b\toolbox\vision\vision\insertText.m
and I've followed the suggestion from @Walter Roberson to edit the code, so I get the result below which looks pretty bizarre but it really happened.

what else can I do?
Antworten (1)
Geoff Hayes
am 13 Jan. 2022
2 Stimmen
@Xiaoai Chen - should the value input parameter be a cell array of strings rather than an array? Please see text (of insertText0 for details.
Kategorien
Mehr zu Tracking and Motion Estimation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
