1、前记:在MATLAB论坛下载了个源码(具体如下),主要功能是利用MATLAB打开摄像头识别红色物体,获取坐标值,然后传给有robotics toolbox 建立的机器人使其模型运动。
2、源码如下:(down下来的代码运行时出错)看别人在YouTube上传的视频没有错啊!
clear all;
t3r=[0 1 0 0;0 1 0 0;0 1 0 0];
r3bot=robot(t3r);
a = imaqhwinfo;
%[camera_name, camera_id, format] = getCameraInfo(a);
f1=figure;
f2=figure;
% Capture the video frames using the videoinput function
% You have to replace the resolution & your installed adaptor name.
vid = videoinput('winvideo',1);
%sls=videoinput('winvideo',1)
% Set the properties of the video object
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb')
vid.FrameGrabInterval = 1;
%start the video aquisition here
start(vid)
n=50;
% Set a loop that stop after 100 frames of aquisition
while(vid.FramesAcquired |