Cov txheej txheem:

MATLAB Yooj Yim Nrhiav Lub Ntsej Muag: 4 Kauj Ruam
MATLAB Yooj Yim Nrhiav Lub Ntsej Muag: 4 Kauj Ruam

Video: MATLAB Yooj Yim Nrhiav Lub Ntsej Muag: 4 Kauj Ruam

Video: MATLAB Yooj Yim Nrhiav Lub Ntsej Muag: 4 Kauj Ruam
Video: Yuav ua li cas thiaj khiav dim lub ntiajteb no 2024, Kaum ib hlis
Anonim
MATLAB Yooj Yim Nrhiav Lub Ntsej Muag
MATLAB Yooj Yim Nrhiav Lub Ntsej Muag

Lub hom phiaj tseem ceeb ntawm cov lus qhia no yog qhia kom yooj yim npaum li cas, kev ua cov duab yuav yog, Nrog kev pab los ntawm MATLAB

Kev txheeb xyuas lub ntsej muag thiab taug qab tau yog qhov tseem ceeb thiab nquag tshawb fawb, yog li ntawd kuv yuav piav qhia tias nws tuaj yeem ua tiav nrog Matlab li cas.

Hauv cov lus qhia hauv qab no kuv yuav ua cov khoom hauv qab no:

1.tseem pom lub ntsej muag hauv daim duab thiab suav.

2.detecting tib neeg ob lub qhov muag nyob rau hauv ib tug duab thiab suav.

3.detecting tib neeg lub qhov ncauj nyob rau hauv ib daim duab thiab suav.

4.detecting ntsej muag hauv Video thiab suav.

5.detecting tib neeg lub qhov muag nyob rau hauv ib tug yees duab thiab suav.

6.detecting tib neeg lub qhov ncauj hauv Video thiab suav.

Kauj Ruam 1: Tshawb Pom Lub ntsej muag hauv Duab thiab Suav

Tshawb Pom Lub ntsej muag hauv Duab thiab Suav
Tshawb Pom Lub ntsej muag hauv Duab thiab Suav

MATLAB SCRIPT:

tshem tag nrho % tshem tag nrho cov khoom clc % ntshiab screen

FDetect = vision. CascadeObjectDetector; %Txheeb xyuas cov khoom siv Viola-Jones Algorithm

%Nyeem cov duab nkag

duab = imread ('c: / Deskotp / HarryPotter.jpg'); %thauj cov duab los ntawm kev siv imread ('file location / name.jpg')

BB = kauj ruam (FDetect, duab); %Rov Rov Los Cuam Tshuam Lub thawv qhov tseem ceeb raws tus lej ntawm cov khoom

daim duab, imshow (I);

tuav

rau kuv = 1: loj (BB, 1)

duab plaub ('Txoj Haujlwm', BB (i,:), 'LineWidth', 5, 'LineStyle', '-', 'EdgeColor', 'r'); %r -red, g-ntsuab, b-blue

kawg

title ('Tshawb Pom Lub Ntsej Muag'); %lub npe ntawm daim duab tawm;

Qhov tshwm sim yuav zoo li cov duab uas tau txuas rau hauv cov theem no nws tus kheej

Kom suav tus naj npawb ntawm lub ntsej muag pom:

tshem tag nrho % tshem tag nrho cov khoom clc % ntshiab screen

FDetect = vision. CascadeObjectDetector; %Txheeb xyuas cov khoom siv Viola-Jones Algorithm %Nyeem cov duab nkag

duab = imread ('c: / Deskotp / HarryPotter.jpg'); %thauj cov duab los ntawm kev siv imread ('file location / name.jpg')

BB = kauj ruam (FDetect, duab); %Rov Rov Los Cuam Tshuam Lub thawv qhov tseem ceeb raws tus lej ntawm cov khoom

daim duab,

imshow (kuv);

tuav

rau kuv = 1: loj (BB, 1)

duab plaub ('Txoj Haujlwm', BB (i,:), 'LineWidth', 5, 'LineStyle', '-', 'EdgeColor', 'r'); %r -red, g-ntsuab, b-blue

kawg

text (10, 10, strcat ('\ color {red} No of faces =', num2str (ntev (BB))))); Kab no muab rau koj suav

title ('Tshawb Pom Lub Ntsej Muag'); %lub npe ntawm daim duab

tuav tseg;

Kauj Ruam 2: Txheeb Xyuas Tib Neeg Qhov Muag hauv Duab thiab Suav

Txheeb Xyuas Tib Neeg Qhov Muag hauv Duab thiab Suav
Txheeb Xyuas Tib Neeg Qhov Muag hauv Duab thiab Suav

MATLAB SCRIPT:

tshem tag nrho;

clc;

%Txhawm rau txheeb xyuas EyesEyeDetect = vision. CascadeObjectDetector ('EyePairBig');

%Nyeem cov tswv yim

duab = imread ('c: / Deskotp / HarryPotter.jpg'); %thauj cov duab los ntawm kev siv imread ('file location / name.jpg')

BB = qib (EyeDetect, duab);

daim duab,

imshow (duab);

duab plaub ('Txoj Haujlwm', BB, 'LineWidth', 4, 'LineStyle', '-', 'EdgeColor', 'b');

title ('Pom Qhov Muag');

Qhov txiaj ntsig yuav zoo li cov duab uas tau txuas rau hauv cov theem no nws tus kheej

Kom suav tus naj npawb ntawm qhov muag pom:

tshem tag nrho; clc; %Kom paub qhov muag

EyeDetect = vision. CascadeObjectDetector ('EyePairBig');

duab = imread ('c: / Deskotp / HarryPotter.jpg'); %thauj cov duab los ntawm kev siv imread ('file location / name.jpg')

BB = qib (EyeDetect, duab); daim duab, imshow (duab); duab plaub ('Txoj Haujlwm', BB, 'LineWidth', 4, 'LineStyle', '-', 'EdgeColor', 'b');

text (10, 10, strcat ('\ color {red} No of eyes =', num2str (ntev (BB)))));

title ('Pom Qhov Muag');

Kauj Ruam 3: Txheeb Xyuas Tib Neeg Lub Qhov Ncauj hauv Duab thiab Suav

Txheeb Xyuas Tib Neeg Lub Qhov Ncauj hauv Duab thiab Suav
Txheeb Xyuas Tib Neeg Lub Qhov Ncauj hauv Duab thiab Suav

MATLAB SCRIPT:

tshem tag nrho;

clc;

%Kom paub qhov ncauj

MouthDetect = vision. CascadeObjectDetector ('Qhov ncauj', 'MergeThreshold', 16);

%Nyeem cov duab nkag = imread ('c: / Deskotp / HarryPotter.jpg'); %thauj cov duab los ntawm kev siv imread ('file location / name.jpg')

BB = kauj ruam (MouthDetect, duab);

daim duab, imshow (duab);

tuav

rau kuv = 1: loj (BB, 1)

duab plaub ('Txoj Haujlwm', BB (i,:), 'LineWidth', 4, 'LineStyle', '-', 'EdgeColor', 'r');

kawg

title ('Tshawb Pom Qhov Ncauj');

tuav tseg;

Qhov txiaj ntsig yuav zoo li cov duab uas tau txuas rau hauv cov theem no nws tus kheej

Kom suav tus naj npawb ntawm Qhov Ncauj pom:

tshem tag nrho; clc; %Kom paub qhov ncauj

MouthDetect = vision. CascadeObjectDetector ('Qhov ncauj', 'MergeThreshold', 16); %Nyeem cov tswv yim

duab = imread ('c: / Deskotp / HarryPotter.jpg'); %thauj cov duab los ntawm kev siv imread ('file location / name.jpg') BB = step (MouthDetect, duab);

daim duab, imshow (duab);

tuav

rau kuv = 1: loj (BB, 1)

duab plaub ('Txoj Haujlwm', BB (i,:), 'LineWidth', 4, 'LineStyle', '-', 'EdgeColor', 'r');

kawg

text (10, 10, strcat ('\ color {red} Tsis muaj qhov ncauj =', num2str (ntev (BB))));

title ('Tshawb Pom Qhov Ncauj');

tuav tseg;

Kauj Ruam 4: Tshawb Pom Lub ntsej muag, qhov muag, qhov ncauj hauv Video thiab Suav

tshem tag nrho;

kaw tag nrho;

clc;

% Capture cov vis dis aus siv cov vis dis aus muaj nuj nqi % Koj yuav tsum hloov qhov kev daws teeb meem & koj lub npe teeb tsa teeb tsa.

a = vision. CascadeObjectDetector; %kom pom lub ntsej muag

% a = vision. CascadeObjectDetector ('Qhov ncauj', 'MergeThreshold', 16); %kom ntes lub qhov ncauj

% a = vision. CascadeObjectDetector ('EyePairBig'); %kom pom qhov muag

%tsuas yog siv ib qho (ntsej muag/qhov muag/qhov ncauj)

vid = videoinput ('winvideo', 1, 'yuy2_320x240'); % Teeb cov khoom ntawm cov yeeb yaj kiab video

teeb (vid, 'FramesPerTrigger', Inf);

teeb (vid, 'ReturnedColorspace', 'rgb');

vid. FrameGrabInterval = 5; %pib ua cov vis dis aus ntawm no

pib (vid) % Teem lub voj uas nres tom qab 100 ntas ntawm kev yuav khoom

thaum (vid. FramesAcquired <= 200) % Tau txais cov duab ntawm tus ncej tam sim no

data = taunapshot (vid);

imshow (cov ntaub ntawv);

b = kauj ruam (a, cov ntaub ntawv);

tuav

rau kuv = 1: loj (b, 1)

duab plaub ('txoj haujlwm', b (i,:), 'kab ntawv dav', 2, 'linestyle', '-', 'EdgeColor', 'r');

kawg

tuav tseg

ntawv (10, 10, strcat ('\ xim {ntsuab} Tsis muaj ntsej muag =', num2str (ntev (b)))));

kawg

nres (vid); Nres qhov kev nrhiav cov vis dis aus

Pom zoo: