Skip to main content
miyagawanize Yusukebe YAPC::Asia 2009 Lighting Talk
Tatsuhiko Miyagawa One of Super Geeks! Every Perl Mongers want to write a code like him. But… We can’t be Tatsuhiko. Because we lose the  “PURPLE THING” .
PURPLE THING
 
What’s This?? I don’t know what is this purple thing. But we need this to be like Tatsuhiko! So, I made a “miyagawanize” script. Like “geek face generator” by Yappo-san.
How to make “miyagawanize” Make a image of purple thing. Install OpenCV library. Install “Imager” and “Image::ObjectDetect” modules from CPAN. Write a short script. Run a script.
#!/usr/bin/perl use strict; use warnings; use Imager; use Image::ObjectDetect;
my $file = shift or die "image file path is required!"; my $image  = Imager->new->read( file => $file ); my $cascade  = './haarcascade_frontalface_alt2.xml'; my $detector = Image::ObjectDetect->new($cascade); my @faces  = $detector->detect($file); my $purple_source =  Imager->new->read(file => './purple.png'); my $aspect = 1.5;
for my $face (@faces) { my $purple = $purple_source->scale( xpixels => $face->{width} / $aspect, ypixels => $face->{height} / $aspect, ); $image->rubthrough( tx  => $face->{width} / $aspect / 2 + $face->{x}, ty  => $face->{height} / $aspect + $face->{y}, src => $purple, ); } $image->write( file => './output.jpg' );
DEMO
Let’s “miyagawanize”, And write a great code! Thanks to Tatsuhiko Miyagawa!!