Luận văn Camera dùng mạng Nơron trong Matlab giao tiếp PLC

Mục Lục

Chương 1 giới thiêu. 6

Chương 2 nội dung 7

I lý thuyet co ban 7

1 mạng noron 7

1.1 câu trúc và mô hình mạng noron 7

1.2 câu tạo và Phuong thưc làm việc của mạng noron 11

1.3 các luật học 20

1.4 Thuật toán lan truyền ngược 24

1.5 Kết luận 32

2 xử lý ảnh trong matlab 33

2.1 một số lẹnh cơ bản trong xử lý ảnh 34

2.2 Các bước thu thập ảnh cỏ bản 38

2.3 Tao giao diện gui 41

3 kết nối matlab và PLC 46

3.1 tạo kết nối với PC Access 46

3.2 các bước tạo kết nôi OPC 48

II Thiết kế và thi công mô hình 53

1 Phần Cứng . .53

2 Nguyên Lý Hoạt Động .54

3 Sơ đồ khối 55

3.1 khối camera 56

3.2Khối cảm biến 56

3.3 Khối máy tính 57

4 Học và huấn luyện mạng Noron 57

4.1 Ma trận dữ liệu 57

4.2 Tạo ma trận dữ liệu ra 59

4.3 tao mạng noron qua công cu network nẻual 60

5 Phần mềm 66

5.1 Lưu đồ chương trình chính 66

5.2 Lưu đồ xử lý ảnh 67

III Thực nghiệm 69

1 Thiết lập thực nghiệm 69

2 kết quả 69

3 đánh giá 69

IV kết luận và hướng phát triển 70

1 kết luân 70

2 hướng phát triên 70

Phụ lục 71

 

docx83 trang | Chuyên mục: MATLAB | Chia sẻ: dkS00TYs | Lượt xem: 2798 | Lượt tải: 2download
Tóm tắt nội dung Luận văn Camera dùng mạng Nơron trong Matlab giao tiếp PLC, để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
,'TimerPeriod', 0.05, ...
'TimerFcn',['if(~isempty(gco)),'...
'handles=guidata(gcf);'... % Update handles
'image(getsnapshot(handles.video));'... % Get picture using GETSNAPSHOT and put it into axes using IMAGE
'set(handles.cameraaxes,''ytick'',[],''xtick'',[]),'... % Remove tickmarks and labels that are inserted when using IMAGE
'else '...
'delete(imaqfind);'... % Clean up - delete any image acquisition objects
'end']);
triggerconfig(handles.video,'manual');
handles.video.FramesPerTrigger = Inf; % Capture frames until we manually stop it
% Update handles structure
guidata(hObject, handles);
guidata(handles.figure1, handles);
global hand han
hand=handles;
han=handles;
% UIWAIT makes test2 wait for user response (see UIRESUME)
uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = test2_OutputFcn(hObject, eventdata, handles) 
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
%varargout{1} = handles.output;
function Data_Group_Callback(hObject, eventdata, handles)
global ngat tin_hieu_1 tin_hieu_2 n p m
global hand han k v
%guidata(hObject, handles);
y=0;
try
global nn mm
if (nn==0)
 x = read(handles.data);
 y = x.Value;
 drawnow;
end
end
if (y == 1)
 nn=1;
 k=0
end
if (k==0)
 clear O;
%v=%=1000000;
 s = videoinput('winvideo', 1);
%v=2;
%end
 thuhinh = getsnapshot(s);
 mm=mm+1
%imwrite(frame,'d.jpg');
%save data
for vv=1:v
 kk=2;
end
 set(han.bao,'String','co vat,dang xu ly');
 set(han.vat,'String',' ');
 load('C:\Program Files\MATLAB\R2010b\bin\neural');
%I = imread('d.jpg');
 J = rgb2gray(thuhinh);
%figure, imshow(frame)%, figure, imshow(J);
 H = im2bw(J,0.15);
%figure, imshow(H);
 G = imresize(H,0.25);
%figure, imshow(G);
 K=bwmorph(G,'branchpoints');
 figure, imshow(K);
%imwrite(K,'t1.bmp');
%N=imread('C:\Users\Admin\Downloads\New folder (2)\t1.bmp');
%figure, imshow(N)
 o=reshape(K,4800,1);
O =net(o)
a=[1 0 0]%ma tran 1.3*3.1=1.1
aa=a*O
 b=[0 1 0]
 bb=b*O
 ccc=[0 0 1]
 cc=ccc*O
if (aa>=bb)
if (aa>=cc)
 dd=aa
else
 dd=cc
end
else
if (bb>=cc)
 dd=bb
else
 dd=cc
end
end
if (dd==aa)
 n = n+1;
 set(han.vat,'String','hinh tron');
 set(han.slvuong,'String',n);
 write(tin_hieu_1,1);
 write(tin_hieu_2,1);
 set(han.bao,'String','khong co vat');
end
if (dd==bb)
 m = m+1;
 set(han.vat,'String','hinh tam giac');
 set(han.sltron,'String',m);
 write(tin_hieu_1,0);
 write(tin_hieu_2,1);
 set(han.bao,'String','khong co vat');
end
if (dd==cc)
 p = p+1;
 set(han.vat,'String','hinh vuong');
 set(han.sldagiac,'String',p);
 write(tin_hieu_1,1);
 write(tin_hieu_2,0);
 set(han.bao,'String','khong co vat');
end
 k=1;
 nn=0;
 stop(s);
%start(s);
end
%handles.output = hObject;
% --- Executes on button press in ngat.
function ngat_Callback(hObject, eventdata, handles)
% hObject handle to ngat (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%global handl
%chup=handles;
start(handles.video);
%chup.video=handles.video;
set(handles.state,'String','camera, mang neural va ket noi OPC thanh cong');
% --- Executes during object creation, after setting all properties.
function cameraaxes_CreateFcn(hObject, eventdata, handles)
% hObject handle to cameraaxes (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate cameraaxes
function state_Callback(hObject, eventdata, handles)
% hObject handle to state (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of state as text
% str2double(get(hObject,'String')) returns contents of state as a double
% --- Executes during object creation, after setting all properties.
function state_CreateFcn(hObject, eventdata, handles)
% hObject handle to state (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
 set(hObject,'BackgroundColor','white');
end
function vat_Callback(hObject, eventdata, handles)
% hObject handle to vat (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of vat as text
% str2double(get(hObject,'String')) returns contents of vat as a double
% --- Executes during object creation, after setting all properties.
function vat_CreateFcn(hObject, eventdata, handles)
% hObject handle to vat (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
 set(hObject,'BackgroundColor','white');
end
function sltron_Callback(hObject, eventdata, handles)
% hObject handle to sltron (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of sltron as text
% str2double(get(hObject,'String')) returns contents of sltron as a double
% --- Executes during object creation, after setting all properties.
function sltron_CreateFcn(hObject, eventdata, handles)
% hObject handle to sltron (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
 set(hObject,'BackgroundColor','white');
end
function slvuong_Callback(hObject, eventdata, handles)
% hObject handle to slvuong (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of slvuong as text
% str2double(get(hObject,'String')) returns contents of slvuong as a double
% --- Executes during object creation, after setting all properties.
function slvuong_CreateFcn(hObject, eventdata, handles)
% hObject handle to slvuong (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
 set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in xoa.
function xoa_Callback(hObject, eventdata, handles)
% hObject handle to xoa (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global m n p v
v=1;
m=0;
p=0;
n=0;
set(handles.sltron,'String',0);
set(handles.slvuong,'String',0);
set(handles.sldagiac,'String',0);
function bao_Callback(hObject, eventdata, handles)
% hObject handle to bao (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of bao as text
% str2double(get(hObject,'String')) returns contents of bao as a double
% --- Executes during object creation, after setting all properties.
function bao_CreateFcn(hObject, eventdata, handles)
% hObject handle to bao (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
 set(hObject,'BackgroundColor','white');
end
function sldagiac_Callback(hObject, eventdata, handles)
% hObject handle to sldagiac (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of sldagiac as text
% str2double(get(hObject,'String')) returns contents of sldagiac as a double
% --- Executes during object creation, after setting all properties.
function sldagiac_CreateFcn(hObject, eventdata, handles)
% hObject handle to sldagiac (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
 set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in test.
function test_Callback(hObject, eventdata, handles)
% hObject handle to test (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
TÀI LIỆU THAM KHẢO
1	Matlab Va Ứng Dụng Trong Điều Khiển Của Ngyễn Đức Thành
2	
3	
4	help trong matlab
5	

File đính kèm:

  • docxLuận văn Camera dùng mạng Nơron trong Matlab giao tiếp PLC.docx