1. Trang chủ
  2. » Luận Văn - Báo Cáo

thiết kế module ghép nối vs pc qua giao diện lpt điều khiển góc quay cua hệ thống quan sát gồm 4 camera

23 668 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 23
Dung lượng 208 KB

Nội dung

% hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data see GUIDATA % varargin command line arguments

Trang 1

MỤC LỤC

MỤC LỤC 1

CHƯƠNG I GIỚI THIỆU ĐỀ TÀI 2

1 Mục tiêu đề tài 2

2 Hoạt động 2

3 Thực hiện 2

CHƯƠNG II PHẦN CỨNG 4

1 Động cơ bước 4

2 Webcam 4

3 Mạch điều khiển động cơ 5

CHƯƠNG III PHẦN MỀM 7

1.Giao diện chương trình 7

2.Điều khiển động cơ bước 7

3.Code chương trình chính 9

4.Hướng phát triển 23

Trang 2

CHƯƠNG I GIỚI THIỆU ĐỀ TÀI

1 Mục tiêu đề tài

 Thiết kế camera an ninh bám theo chuyển động trong vùng không gian

xác định-có giao tiếp, điều khiển bằng máy tính.

 Xây dựng giao diện phần mềm có hiệu quả giám sát cao, dễ sử dụng,

nhiều tính năng.

2 Hoạt động

Camera có tác dụng giám sát chuyển động trong một phạm vi giới hạn, ví dụmột căn phòng kín

 Khi có đối tượng xâm nhập vào phạm vi giám sát của Camera thì lập tức

sẽ có tín hiệu báo động cho con người (còi báo động và đèn báo động)

 Khi đối tượng chuyển động, Camera được điều khiển bởi động cơ bướctiếp tục bám theo đối tượng, đưa tín hiệu báo động đồng thời liên tiếpchụp lại ảnh của đối tượng

3 Thực hiện

 Phần cứng

Camera (webcam) thu tín hiệu hình ảnh và gửi về cho máy tính xử lý.Webcam này kết nối với máy tính bằng cổng USB thông dụng Trước khi hoạtđộng, webcam cần được cài sẵn driver của nhà sản xuất

Để truyền động cho động cơ, ta sử dụng động cơ bước Theo đó, đế củaCamera được gắn trực tiếp lên trục động cơ đặt thẳng đứng Khi trục động cơquay, camera quay trong mặt phẳng ngang vuông góc với trục động cơ

Mạch điều khiển động cơ bước lấy xung từ cống LPT của máy tính quacách ly quang và IC đệm công suất để cấp xung cho các cuộn dây của động cơ

 Phần mềm

Lập trình điều khiển camera bằng ngôn ngữ visual studio 2010 với ưuđiểm là khả năng tính toán mạnh đồng thời hỗ trợ nhiều hàm thu thập và xử lýhình ảnh từ các thiết bị số như camera

Trang 3

Chương trình viết trên nền form của studio 2010, tạo ra giao diện ngườidùng-gần gũi với các ứng dụng windows, dễ vận hành, điều khiển, thao tác.

Giao diện sử dụng tiếng Việt

Trang 4

CHƯƠNG II PHẦN CỨNG

1 Động cơ bước

Để điều khiển chuyển động của

camera, ta sử dụng động cơ bước

loại nhỏ do Trung Quốc sản xuất

bước rất nhỏ này ta có thể điều khiển camera bám đối tượng khá chínhxác

2 Webcam

Để thu hình ảnh trong vùng giámsát, ta sử dụng webcam kí hiệuTako01 của hãng Tako Một sốđặc điểm kỹ thuật

 Độ phân giải ảnh : 300000pixels

 Có 6 đèn hồng ngoại có thểchụp ảnh vào ban đêm

 Kết nối máy tính qua cổngUSB

Trang 5

 Tốc độ chụp ảnh còn hạn chế, tuy nhiên đáp ứng khá tốt mục tiêu đã đặt

2

5 4

2

5 4

2

5 4

2

5 4

2

5 4

 Khối kết nối với cổng LPT máy tính

P 1

C O N N E C T O R D B 9

5 9 4 8 3 7 2 6

Trang 6

5 4

2

5 4

2

5 4

2

5 4

2

5 4

2

5 4

 Khối báo động: còi báo động và đèn báo động

Trang 7

CHƯƠNG III PHẦN MỀM

1 Giao diện chương trình

2 Điều khiển động cơ bước

Để điều khiển động cơ bước, ta cần phát xung qua cổng LPT của máy tính

Hỗ trợ việc này, matlab cần sử dụng 2 thư viện liên kết động là io32.dll và inpout32.dll

Đầu tiên, khai báo sử dụng thư viện này như sau:

Trang 9

%if status =0 thi cong da san sang

function varargout = myCameraGUI(varargin)

% MYCAMERAGUI M-file for myCameraGUI.fig

% MYCAMERAGUI, by itself, creates a new MYCAMERAGUI or raises the existing

Trang 10

% function named CALLBACK in MYCAMERAGUI.M with the given input arguments.

%

% MYCAMERAGUI('Property','Value', ) creates a new MYCAMERAGUI

or raises the

% existing singleton* Starting from the left, property value pairs are

% applied to the GUI before myCameraGUI_OpeningFunction gets called An

% unrecognized property name or invalid value makes property application

% stop All inputs are passed to myCameraGUI_OpeningFcn via varargin

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help myCameraGUI

% Last Modified by GUIDE v2.5 25-May-2009 03:24:48

% Begin initialization code - DO NOT EDIT

Trang 11

% End initialization code - DO NOT EDIT

% - Executes just before myCameraGUI is made visible

function myCameraGUI_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% varargin command line arguments to myCameraGUI (see VARARGIN)

%khai bao cong vao ra LPT

global obj_io address status temp tong_so_anh

tong_so_anh=str2double(get(handles.tong_so_anh,'String'));

temp=0;

obj_io=io32;

Trang 12

address=hex2dec('378');

% Choose default command line output for myCameraGUI

handles.output = hObject;

imaqreset; %reset webcam

%khai bao cac doi tuong anh

% - Outputs from this function are returned to the command line

function varargout = myCameraGUI_OutputFcn(hObject, eventdata, handles)

Trang 13

% 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)

% - Executes on button press in startStopCamera

%function startStopCamera_Callback(hObject, eventdata, handles)

% hObject handle to startStopCamera (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

%========================================================

==================

function startStopCamera_Callback(hObject, eventdata, handles)

% hObject handle to startStopCamera (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

global obj_io address bien_trai bien_phai nguong n so_anh tong_so_anh

% Start/Stop Camera

tong_so_anh=str2double(get(handles.tong_so_anh,'String'));

if strcmp(get(hObject,'String'),'Take Photo')

Trang 15

so_anh=1;

end

imwrite(Image2,strcat(num2str(so_anh),'.jpg'),'jpg');end

Trang 16

%=====================================================

%start(handles.video)

elseif strcmp(get(hObject,'String'),'Stop Camera')

% Camera is on Stop camera and change button string

set(handles.startStopCamera,'String','Start Camera');

%stop(handles.video);

%close all;

end

% - Executes on button press in automation

function automation_Callback(hObject, eventdata, handles)

% hObject handle to automation (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of automation

set(handles.automation,'Value',1);

set(handles.startStopCamera,'Enable','on');

set(handles.startStopCamera,'String','Stop Camera');

set(handles.direction,'Enable','off');

% - Executes on button press in manual

function manual_Callback(hObject, eventdata, handles)

% hObject handle to manual (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

Trang 17

% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of manual

% - Executes on slider movement

function direction_Callback(hObject, eventdata, handles)

% hObject handle to direction (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,'Value') returns position of slider

% get(hObject,'Min') and get(hObject,'Max') to determine range of sliderglobal obj_io address temp

quay=get(handles.direction,'Value')*100-temp;

temp=get(handles.direction,'Value')*100;

if (quay<0)

Trang 18

% hObject handle to MyCameraGUI (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% - 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

% - Executes during object creation, after setting all properties

function direction_CreateFcn(hObject, eventdata, handles)

% hObject handle to direction (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

Trang 19

% handles empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background

if isequal(get(hObject,'BackgroundColor'),

get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor',[.9 9 9]);

end

% - Executes on mouse press over figure background, over a disabled or

% - inactive control, or over an axes background

function MyCameraGUI_WindowButtonDownFcn(hObject, eventdata, handles)

% hObject handle to MyCameraGUI (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% - Executes on scroll wheel click while the figure is in focus

function MyCameraGUI_WindowScrollWheelFcn(hObject, eventdata, handles)

% hObject handle to MyCameraGUI (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% - Executes when user attempts to close MyCameraGUI

function MyCameraGUI_CloseRequestFcn(hObject, eventdata, handles)

% hObject handle to MyCameraGUI (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

Trang 20

% Hint: delete(hObject) closes the figure

% Get the current position of the GUI from the handles structure

% to pass to the modal dialog

pos_size = get(handles.MyCameraGUI,'Position');

% Call modaldlg with the argument 'Position'

user_response = modaldlg('Title','Confirm Close');

% hObject handle to MyCameraGUI (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% - Executes on button press in Exit

function Exit_Callback(hObject, eventdata, handles)

Trang 21

% hObject handle to Exit (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)close all;

% - Executes on button press in about

function about_Callback(hObject, eventdata, handles)

% hObject handle to about (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)about;

% - Executes on button press in Help

function Help_Callback(hObject, eventdata, handles)

% hObject handle to Help (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)help;

function tong_so_anh_Callback(hObject, eventdata, handles)

% hObject handle to tong_so_anh (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

Trang 22

% Hints: get(hObject,'String') returns contents of tong_so_anh as text

% str2double(get(hObject,'String')) returns contents of tong_so_anh as a double

% - Executes during object creation, after setting all properties

function tong_so_anh_CreateFcn(hObject, eventdata, handles)

% hObject handle to tong_so_anh (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 so_anh

function so_anh_Callback(hObject, eventdata, handles)

% hObject handle to so_anh (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

global tong_so_anh

tong_so_anh=str2double(get(handles.tong_so_anh,'String'));

Trang 23

4 Hướng phát triển

Từ đề tài này có thể phát triển lên, xây dựng nhiều ứng dụng giám sát an ninh có hiệu quả trong thực tế Chúng em đề xuất một số hướng phát triển sau:

tượng, giúp cho việc bám đối tượng thêm hiệu quả

hoạt, theo nhiều chiều trong không gian

Ngày đăng: 26/04/2014, 15:18

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w