Beruflich Dokumente
Kultur Dokumente
El ltimo paso del procesamiento digital consiste en convertir la salida del bloque
procesador a una seal analgica, lo que ocurre en el llamado convertidor digitalanalgico (D/A). En aplicaciones de anlisis de seal, la ltima etapa puede no ser
necesaria, cuando la informacin a extraer se obtiene directamente de las
representaciones digitales.
Materiales
-
Arduino
Matlab
Servomotor
Algn objeto de color
Cmara
Cables
%
%
%
%
%
value as the object being recreated, then we will reuse the object.
If more than one existing video input object contains that
AdaptorName value, then the first object found will be reused. If
there are no existing objects with the AdaptorName value, then the
video input object will be created.
% Query through each existing object and check that their adaptor
name
% matches the adaptor name of the object being recreated.
for i = 1:length(existingObjs1)
% Get the object's device information.
objhwinfo = imaqhwinfo(existingObjs1{i});
% Compare the object's AdaptorName value with the AdaptorName
value
% being recreated.
if strcmp(objhwinfo.AdaptorName, adaptorName)
% The existing object has the same AdaptorName value as the
% object being recreated. So reuse the object.
vidObj1 = existingObjs1{i};
% There is no need to check the rest of existing objects.
% Break out of FOR loop.
break;
elseif(i == length(existingObjs1))
% We have queried through all existing objects and no
% AdaptorName values matches the AdaptorName value of the
% object being recreated. So the object must be created.
vidObj1 = videoinput(adaptorName, deviceID, vidFormat);
end %if
end %for
end %if
% Configure properties whose values are saved in
C:\Users\Jhonalexander\Desktop\Demos Proy\MyVid.mat.
if (MATLoaded)
% MAT-file loaded successfully. Configure the properties whose values
% are saved in the MAT-file.
set(vidObj1, 'ErrorFcn', MATvar.errorfcn1);
else
% MAT-file could not be loaded. Configure properties whose values were
% saved in the MAT-file to their default value.
set(vidObj1, 'ErrorFcn', @imaqcallback);
end
% Configure vidObj1 properties.
set(vidObj1, 'FramesPerTrigger', 1);
set(vidObj1, 'ReturnedColorSpace', 'rgb');
% Configure vidObj1's video source properties.
srcObj1 = get(vidObj1, 'Source');
set(srcObj1(1), 'Brightness', 64);
set(srcObj1(1), 'Saturation', 84);
out = vidObj1 ;
Este cdigo bsicamente lo que har ser analizar la ubicacin o coordenadas del
color que estemos analizando y cuando este color se mueva de lugar nos
calculara las nuevas coordenadas o nueva ubicacin y de esa manera podremos
enviarle la seal al arduino para que mueva al servomotor en la direccin correcta.
Una vez seleccionado el color que deseamos analizar en este caso el color rojo,
ya el servomotor se movera desde 0 - 180 . La idea es que el servomotor gire
cada ves que movamos el color que elejimos.
Una aplicacin que podriamos dar a este ejemplo es mover un brazo robotico o un
humanoide.
a=arduino('COM7');
a.servoAttach(9);
start(vid);
%hold on;
%pause(1);
while(vid.FramesAcquired<=200)% Stop after 1000 frames
data = getdata(vid,1);
b = data(:,:,:,1);
immult=colorseg('euclidean',b,50,m);% segment ime using multiples of
T=25 for threshold
[i,j]=RapidCentroid(immult);
imshow(b);
X=floor(i*0.5114);
a.servoWrite(9,X);
%hold on
text(i-5,j-20,num2str(X),'Color','w','FontSize',12,...
'BackgroundColor',(m()')/255)
end
a.servoWrite(9,0);
stop(vid);
Conclusiones:
o Para lograr una ptima segmentacin en una imagen a color, es
recomendable tomar un nmero considerable de muestras representativas;
entre ms muestras representativas mejores resultados obtendremos.
o En los resultados logramos una mejor segmentacin del objeto con el
mtodo de la Distancia Euclidiana. Debido a que con este mtodo se tiene
una mayor flexibilidad, modificando levemente la distancia umbral para
determinar la pertenencia del pxel al objeto deseado.
o El mtodo de la Distancia permiten llevar a cabo la segmentacin de una
imagen a color, el uso exclusivo depende de la imagen y de las situaciones,