Added first revision of experimental MPmix software - DJ player using Mplayer, PERL...
[mirrors/Programs.git] / perl / facedetect.pl
... / ...
CommitLineData
1#!/usr/bin/perl
2use strict;
3use warnings;
4
5use Imager;
6use Image::ObjectDetect;
7
8my $file = '2.jpg';
9#my $file = 'input.jpg';
10my $image = Imager->new->read(file => $file);
11
12my @cascades = (
13 #'/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml',
14 #'/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml',
15 '/usr/share/opencv/haarcascades/haarcascade_frontalface_alt2.xml', #less sensitive
16 #'/usr/share/opencv/haarcascades/haarcascade_frontalface_alt_tree.xml',
17 #'/usr/share/opencv/haarcascades/haarcascade_profileface.xml',
18
19 #'/usr/share/opencv/haarcascades/haarcascade_upperbody.xml',
20 #'/usr/share/opencv/haarcascades/haarcascade_lowerbody.xml',
21 #'/usr/share/opencv/haarcascades/haarcascade_fullbody.xml',
22
23 #'/usr/share/opencv/haarcascades/haarcascade_mcs_eyepair_small.xml',
24 #'/usr/share/opencv/haarcascades/haarcascade_mcs_eyepair_big.xml',
25);
26
27my @faces;
28foreach(@cascades) {
29 push (@faces, detect_objects($_, $file));
30}
31
32for my $face (@faces) {
33 my $file2 = 'paroubek.jpg';
34 my $image2 = Imager->new->read(file => $file2);
35 $image2 = $image2->scale(xpixels => $face->{width}, ypixels => $face->
36{height});
37 $image->paste(left => $face->{x}, top => $face->{y}, src => $image2);
38}
39
40$image->write(file => 'output.jpg');
41
42print "Content-type: text/html\n\n";
43print "<head>\n";
44print "<TITLE>face detect</TITLE>\n";
45print "</HEAD>\n";
46print "<BODY>\n";
47print "<br>\n";
48print "<img src='input.jpg'>\n";
49print "<img src='face.jpg'>\n";
50print "<img src='output.jpg'>\n";
51print "</BODY>\n";
52print "</HTML>\n";
This page took 0.122042 seconds and 4 git commands to generate.