⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 image_sensor_api.m

📁 MatLab图像传感器网络仿真平台WiSNAP
💻 M
字号:
function result = image_sensor_api(device,command,argument);
%Image Sensor Application Program Interface.
%   RESULT = IMAGE_SENSOR_API(DEVICE,COMMAND,ARGUMENT);
%
%   Input Parameters:
%   ================
%
%      device ------------> Image sensor device (string):
%                           'ADCM-1670': Agilent ADCM-1670 camera module.
%                           'ADNS-3060': Agilent ADNS-3060 mouse sensor.
%      command -----------> API function (string):
%                           'open'  - Open communications session.
%                           'init'  - Initialize image sensor.
%                           'frame' - Capture current frame.
%                           'close' - Close communications session.
%      argument ----------> API function argument for
%                           'open'  - Communications port (string).
%                           'init'  - Device handle (positive integer).
%                           'frame' - Device handle (positive integer).
%                           'close' - Device handle (positive integer).
%
%   Output Parameters:
%   =================
%
%      result ------------> API function result for
%                           'open'  - Device handle (positive integer).
%                           'init'  - Success status (-1 = error, +1 = success).
%                           'frame' - Image array NxM, color depth D (NxMxD matrix).
%                           'close' - Success status (-1 = error, +1 = success).
%
%   See also N/A.

% Stephan Hengstler
% Stanford Wireless Sensor Networks Lab
% January 11, 2005
%
% Last modified: 01-22-2005

%********************** Image Sensor Application Program Interface ************************

% include device libraries in path
addpath adcm1670_library adns3060_library -end

%--- Section: Global Variables ------------------------------------------------------------

global		colorm;							% color map
global		handle;							% device handle
global		imager;							% image array
global 		PORT;								% communications port

%--- Command: Open Communications Session -------------------------------------------------

if (~isempty(strmatch('open',command,'exact')))
   
   % parse argument(s)
   PORT			= argument;

	% call device library function
	if (~isempty(strmatch('ADCM-1670',device,'exact')))
		status		= adcm1670_library(command);
	elseif (~isempty(strmatch('ADNS-3060',device,'exact')))
		status		= adns3060_library(command);
   end

   % return result(s)
   result		= handle;
   
%--- Command: Initialize Image Sensor -----------------------------------------------------

elseif (~isempty(strmatch('init',command,'exact')))

   % parse argument(s)
   handle		= argument;

	% call device library function
	if (~isempty(strmatch('ADCM-1670',device,'exact')))
		status		= adcm1670_library(command);
	elseif (~isempty(strmatch('ADNS-3060',device,'exact')))
		status		= adns3060_library(command);
   end

   % return result(s)
   result		= status;

%--- Command: Capture Current Frame -------------------------------------------------------

elseif (~isempty(strmatch('frame',command,'exact')))
   
   % parse argument(s)
   handle		= argument;

	% call device library function
	if (~isempty(strmatch('ADCM-1670',device,'exact')))
		status		= adcm1670_library(command);
	elseif (~isempty(strmatch('ADNS-3060',device,'exact')))
		status		= adns3060_library(command);
   end

   % return result(s)
   result		= imager;
   
%--- Command: Close Communications Session ------------------------------------------------

elseif (~isempty(strmatch('close',command,'exact')))

   % parse argument(s)
   handle		= argument;

	% call device library function
	if (~isempty(strmatch('ADCM-1670',device,'exact')))
		status		= adcm1670_library(command);
	elseif (~isempty(strmatch('ADNS-3060',device,'exact')))
		status		= adns3060_library(command);
   end

   % return result(s)
   result		= status;

%--- Command: Undefined -------------------------------------------------------------------

else

   % return result(s)
   result		= -1;

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -