Parallel Port Initialization and Image Processing using Python and MATLAB, Study Guides, Projects, Research of Control Systems

A matlab script that initializes the parallel port, captures video frames, processes the rgb values, and sends a signal based on the maximum rgb value found. The script uses digital i/o and videoinput functions to interact with the parallel port and video input.

Typology: Study Guides, Projects, Research

2011/2012

Uploaded on 07/30/2012

badsha
badsha 🇮🇳

4.3

(28)

213 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
% Parallel Port Initialization
dio = digitalio('parallel','LPT1');
addline(dio,0:7,'out');
dio=dio.Line(1:8);
vid = videoinput('winvideo');
preview(vid)
start(vid)
v=[];
for i = 1:1000 % For Grabbing fames
v = getsnapshot(vid);
figure,image(v)
final = [];
% Taking RGB value of central pixels:
for i = 150:300
for j = 200:400
r = v(i,j,1);
g = v(i,j,2);
b = v(i,j,3);
RGB = [r g b];
check = find(RGB==max(RGB));
final = [final check];
end
end
c = v(150:300,200:400,1:3);
figure, image(c)
final2 = [];
% Selecting RGB with maximum value:
red = find(final==1);
green = find(final==2);
blue = find(final==3);
% Length Check:
check2 = [length(red) length(green) length(blue)];
mx = max(check2);
mx = find(check2==mx);
if mx == 1
putvalue(dio,1); % result = ['red']
end
if mx == 2
putvalue(dio,2); % result = ['green']
end
if mx == 3
putvalue(dio,4); % result = ['blue']
end
docsity.com
pf2

Partial preview of the text

Download Parallel Port Initialization and Image Processing using Python and MATLAB and more Study Guides, Projects, Research Control Systems in PDF only on Docsity!

% Parallel Port Initialization dio = digitalio('parallel','LPT1'); addline(dio,0:7,'out'); dio=dio.Line(1:8); vid = videoinput('winvideo'); preview(vid) start(vid) v=[]; for i = 1:1000 % For Grabbing fames v = getsnapshot(vid); figure,image(v) final = []; % Taking RGB value of central pixels: for i = 150: for j = 200: r = v(i,j,1); g = v(i,j,2); b = v(i,j,3); RGB = [r g b]; check = find(RGB==max(RGB)); final = [final check]; end end c = v(150:300,200:400,1:3); figure, image(c) final2 = []; % Selecting RGB with maximum value: red = find(final==1); green = find(final==2); blue = find(final==3); % Length Check: check2 = [length(red) length(green) length(blue)]; mx = max(check2); mx = find(check2==mx); if mx == 1 putvalue(dio,1); % result = ['red'] end if mx == 2 putvalue(dio,2); % result = ['green'] end if mx == 3 putvalue(dio,4); % result = ['blue'] end

docsity.com

end

docsity.com