www.gusucode.com > IPCV_Eval_Kit_R2019a_0ce6858工具箱matlab程序源码 > IPCV_Eval_Kit_R2019a_0ce6858/code/demo_files/I5_03_1_myOCR_stop.m

    clear;clc;close all;imtool close all

%% 夋憸偺撉崬傒
I = imread('I5_03_1_ocr\IMG_2537_stop.JPG');
figure;imshow(I);

%% 僌儗乕僗働乕儖夋憸傊曄姺
G = rgb2gray(I);
figure;imshow(G);

%% 儌儖僼僅儘僕乕張棟偱丄帤偺晹暘偺傒傪巆偡
G2 = imbothat(G, ones(13));   imshow(G2); %崟偄暥帤傪巆偡丗Close - 尨夋
G3 = im2bw(G2,graythresh(G2));imshow(G3); %擇抣壔
G4 = imopen(G3, ones(5));     imshow(G4); %嵶偄慄傪彍嫀
G5 = bwareaopen(G4,200);                  %彫偝偄偛傒傪彍嫀
imshow(G5);
     
%% 暥帤擣幆
results = ocr(G5, 'Language','Japanese')

%% 寢壥傪昞帵
I1 = insertShape(I, 'Rectangle', results.WordBoundingBoxes, 'LineWidth', 3);
figure;imshow(I1);
text(results.WordBoundingBoxes(1), results.WordBoundingBoxes(2)-50, results.Words(1),'FontSize',12,'BackgroundColor',[1 1 0]);


%% 撉傒忋偘 (擔杮岅壒惡崌惉僄儞僕儞偼暿搑擖庤梫)
NET.addAssembly('System.Speech');   %.NET傾僙儞僽儕偺撉崬傒
speak = System.Speech.Synthesis.SpeechSynthesizer;
speak.Volume = 100;
speak.SelectVoice('偗偄偙');

speak.Speak([results.Words{1} ' 偟偰壓偝偄']);


%% 撉傒忋偘 (塸岅壒惡崌惉僄儞僕儞偼Windows偵晅懏)
NET.addAssembly('System.Speech');   %.NET傾僙儞僽儕偺撉崬傒
speak = System.Speech.Synthesis.SpeechSynthesizer;
speak.Volume = 100;
speak.Speak('stop');


%% 廔椆











%% 擔杮岅偺撉傒忋偘偵偼丄暿搑擔杮岅壒惡崌惉僄儞僕儞偑昁梫
%  塸岅偵娭偟偰偼Windows偵撪憻

%% ocr幚峴慜偵丄娭悢撪晹偱Otu朄偵傛傝2抣壔偝傟偰偄傑偡
%G = rgb2gray(I);imtool(im2bw(G,graythresh(G)))

% Copyright 2014 The MathWorks, Inc.