Matlab 我正在尝试通过oCR功能进行文本识别。但它给我的第一行错误,不能从单元格转换到数组 columnNames=string({'Aricept'、'Donepezil'、'deminia'、'tpicerA'、'ROOMS'、'BRICK'); stary=char(列名称); %加载图像 %I=imread('product_aricept_10mg.jpg'); %cd('E:\saba_study\7th sem\New folder\task3\*.jpg'); [mat,dirc]=uigetfile('*.jpg','选择一个文件'); I=imread(完整文件(dirc,mat)); %执行OCR 投资回报率=[360 118 384 560]; 结果=ocr(I); %disp(结果); disp(results.Text); %显示一个已识别的单词 %对于i=1:结果 单词=结果。单词{3}; disp(word); com=字符(word); %结束 % %单词在I中的位置 wordBBox=results.WordBoundingBox(3,:); 图形 Iname=插入对象注释(I,‘矩形’、字框、字); img=imcrop(Iname); imshow(img); x=验证字符串(com、列名称); 如果(x==stary) disp(x); 其他的 disp(“未识别”); 结束 %寻找信心不足的角色 lowConfidenceIdx=结果。性格自信

Matlab 我正在尝试通过oCR功能进行文本识别。但它给我的第一行错误,不能从单元格转换到数组 columnNames=string({'Aricept'、'Donepezil'、'deminia'、'tpicerA'、'ROOMS'、'BRICK'); stary=char(列名称); %加载图像 %I=imread('product_aricept_10mg.jpg'); %cd('E:\saba_study\7th sem\New folder\task3\*.jpg'); [mat,dirc]=uigetfile('*.jpg','选择一个文件'); I=imread(完整文件(dirc,mat)); %执行OCR 投资回报率=[360 118 384 560]; 结果=ocr(I); %disp(结果); disp(results.Text); %显示一个已识别的单词 %对于i=1:结果 单词=结果。单词{3}; disp(word); com=字符(word); %结束 % %单词在I中的位置 wordBBox=results.WordBoundingBox(3,:); 图形 Iname=插入对象注释(I,‘矩形’、字框、字); img=imcrop(Iname); imshow(img); x=验证字符串(com、列名称); 如果(x==stary) disp(x); 其他的 disp(“未识别”); 结束 %寻找信心不足的角色 lowConfidenceIdx=结果。性格自信,matlab,ocr,Matlab,Ocr,我希望当选择任何图像并应用ocr函数时,通过使用validate属性的字符串值比较该函数返回的值,以检查其是否与值匹配,然后显示值,否则不返回匹配值。请帮助我如何处理因为 columnNames = string({'Aricept','Donepezil','Dementia','tpicerA','ROOMS','BRICK'}); stary=char(columnNames); % Load an image % I = imread('product_aricept_10mg.jpg

我希望当选择任何图像并应用ocr函数时,通过使用validate属性的字符串值比较该函数返回的值,以检查其是否与值匹配,然后显示值,否则不返回匹配值。请帮助我如何处理因为

columnNames = string({'Aricept','Donepezil','Dementia','tpicerA','ROOMS','BRICK'});

stary=char(columnNames);
% Load an image
% I = imread('product_aricept_10mg.jpg');
% cd('E:\saba_study\7th sem\New folder\task3\*.jpg');
 [mat, dirc] = uigetfile('*.jpg', 'Select a  file');
I= imread( fullfile(dirc, mat) );
% Perform OCR
roi = [360 118 384 560];
results = ocr(I);
% disp(results);
disp(results.Text);

% Display one of the recognized words
% for i=1:results

word = results.Words{3};
disp(word);
com=char(word);
% end
% 
% Location of the word in I
wordBBox = results.WordBoundingBoxes(3,:);
figure;
Iname = insertObjectAnnotation(I, 'rectangle', wordBBox, word);
img=imcrop(Iname);
imshow(img);



x=validatestring(com,columnNames);
if(x==stary)
disp(x);
else
    disp('not recognized');
end

% Find characters with low confidence
lowConfidenceIdx = results.CharacterConfidences < 0.6;

% Get the bounding box locations of the low confidence characters
lowConfBBoxes = results.CharacterBoundingBoxes(lowConfidenceIdx, :);

% Get confidence values
lowConfVal = results.CharacterConfidences(lowConfidenceIdx);

% Annotate image with character confidences
str      = sprintf('confidence = %f', lowConfVal);
Ilowconf = insertObjectAnnotation(I, 'rectangle', lowConfBBoxes, str);

figure;
imshow(Ilowconf);
title('you need to take this medicine 3 times a day');`
已经是一个单元了,在matlab中几乎没有一个操作符可以将一个单元作为输入。 然而

是有效的输入,因为名称{1}包含字符串。

这是因为

columnNames = string({'Aricept','Donepezil','Dementia','tpicerA','ROOMS','BRICK'});

stary=char(columnNames);
% Load an image
% I = imread('product_aricept_10mg.jpg');
% cd('E:\saba_study\7th sem\New folder\task3\*.jpg');
 [mat, dirc] = uigetfile('*.jpg', 'Select a  file');
I= imread( fullfile(dirc, mat) );
% Perform OCR
roi = [360 118 384 560];
results = ocr(I);
% disp(results);
disp(results.Text);

% Display one of the recognized words
% for i=1:results

word = results.Words{3};
disp(word);
com=char(word);
% end
% 
% Location of the word in I
wordBBox = results.WordBoundingBoxes(3,:);
figure;
Iname = insertObjectAnnotation(I, 'rectangle', wordBBox, word);
img=imcrop(Iname);
imshow(img);



x=validatestring(com,columnNames);
if(x==stary)
disp(x);
else
    disp('not recognized');
end

% Find characters with low confidence
lowConfidenceIdx = results.CharacterConfidences < 0.6;

% Get the bounding box locations of the low confidence characters
lowConfBBoxes = results.CharacterBoundingBoxes(lowConfidenceIdx, :);

% Get confidence values
lowConfVal = results.CharacterConfidences(lowConfidenceIdx);

% Annotate image with character confidences
str      = sprintf('confidence = %f', lowConfVal);
Ilowconf = insertObjectAnnotation(I, 'rectangle', lowConfBBoxes, str);

figure;
imshow(Ilowconf);
title('you need to take this medicine 3 times a day');`
已经是一个单元了,在matlab中几乎没有一个操作符可以将一个单元作为输入。 然而


是有效的输入,因为名称{1}包含字符串。

是的,您可能需要在代码中添加一些循环。每次您需要单元格中的一个字符串时,用stary{i}调用它。是的,您可能需要在代码中添加一些循环。每次你需要单元格中的一个字符串时,用stary{i}调用它
string(names{1})