From 38a87dc6ae7e58d30d3325e244f6eaffb40e35bc Mon Sep 17 00:00:00 2001 From: Harvie Date: Mon, 24 May 2010 20:39:15 +0200 Subject: [PATCH] Added PHP periodic-calendar and PERL Face detector --- perl/facedetect.pl | 52 ++++++++++++++++++++++++++++++++++++++++++++++ php/pcal.php | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100755 perl/facedetect.pl create mode 100755 php/pcal.php diff --git a/perl/facedetect.pl b/perl/facedetect.pl new file mode 100755 index 0000000..8139f6e --- /dev/null +++ b/perl/facedetect.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Imager; +use Image::ObjectDetect; + +my $file = '2.jpg'; +#my $file = 'input.jpg'; +my $image = Imager->new->read(file => $file); + +my @cascades = ( + #'/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml', + #'/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml', + '/usr/share/opencv/haarcascades/haarcascade_frontalface_alt2.xml', #less sensitive + #'/usr/share/opencv/haarcascades/haarcascade_frontalface_alt_tree.xml', + #'/usr/share/opencv/haarcascades/haarcascade_profileface.xml', + + #'/usr/share/opencv/haarcascades/haarcascade_upperbody.xml', + #'/usr/share/opencv/haarcascades/haarcascade_lowerbody.xml', + #'/usr/share/opencv/haarcascades/haarcascade_fullbody.xml', + + #'/usr/share/opencv/haarcascades/haarcascade_mcs_eyepair_small.xml', + #'/usr/share/opencv/haarcascades/haarcascade_mcs_eyepair_big.xml', +); + +my @faces; +foreach(@cascades) { + push (@faces, detect_objects($_, $file)); +} + +for my $face (@faces) { + my $file2 = 'paroubek.jpg'; + my $image2 = Imager->new->read(file => $file2); + $image2 = $image2->scale(xpixels => $face->{width}, ypixels => $face-> +{height}); + $image->paste(left => $face->{x}, top => $face->{y}, src => $image2); +} + +$image->write(file => 'output.jpg'); + +print "Content-type: text/html\n\n"; +print "\n"; +print "face detect\n"; +print "\n"; +print "\n"; +print "
\n"; +print "\n"; +print "\n"; +print "\n"; +print "\n"; +print "\n"; diff --git a/php/pcal.php b/php/pcal.php new file mode 100755 index 0000000..73aed37 --- /dev/null +++ b/php/pcal.php @@ -0,0 +1,46 @@ +PeriodiCalendar +

PeriodiCal

+Calendar with period highlighting ability + +
+ Last: + Periodicity: + Duration: + Months: + +
+ +'); +} else { +//init +error_reporting(0); +$day = 60*60*24; +//get numbers +$now = time(); $now = mktime(12, 0, 0, date('n',$now), 1, date('Y',$now)); +$last = date_parse_from_format('Y-m-d', $_GET['last']); +$last = mktime(12, 0, 0, $last['month'], $last['day'], $last['year']); +$period=28; if(isset($_GET['period'])) $period = $_GET['period']; +$length=7; if(isset($_GET['len'])) $length = $_GET['len']; +$months=12; if(isset($_GET['months'])) $months = $_GET['months']; + +echo(''); +$r = 0; +for($i=0;$i<$months;$i++) { + $lm = $m = date('m',$now); + $mo = date('M',$now); + echo(""); + while($m == $lm) { + if(round(($now-$last)/$day)%($period) == 0) $r = $length; + $c = ''; + if($r>0) $c = '#FF0000'; + if($r==1 || $r==$length) $c = '#FF7777'; + $r--; + echo("'); + $now += $day; + $m = date('m',$now); + } + echo(''); +} +echo('
$m ($mo)".date('d', $now).'
You can bookmark this page it will get updated automatically each month.'); +} -- 2.30.2