

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 2
This page cannot be seen from the preview
Don't miss anything!


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