Cv::Pango::JA - Pango を使って様々な文字を描きます。
use Cv; use Cv::Pango; my $img = Cv::Mat->new([240, 320], CV_8UC4); $img->putText( "\x{03A0}\x{03B1}\x{03BD}\x{8A9E}", # "Παν語", [20, 200], 'Sans Serif 42', ); $img->showImage; $img->waitKey;
Cv::Pango は、日本語のような Cv では扱えない文字を Pango を使って描くた めのパッケージです。CV_8UC1, CV_8UC3, CV_8UC4 が扱えます。
Cv::Arr::PutText() を上書きします。
$img->PutText($text, $org, $font, $color)
$img は Cv::Arr のオブジェクトです。$font は Pango::FontDescription の オブジェクトかフォントを識別するための文字列を指定します。InitFont() で 作成したフォントも使えます。PutText のその他のパラメータの詳細は OpenCV の cvPutText() を参照してください。
フォントを識別するための文字列は次のとおり。
"[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]"
たとえば、
"sans bold 12" "serif,monospace bold italic condensed 16" "normal 10"
詳細は pango.FontDescription() を参照してください。
Cv->GetTextSize($text, $font, my $size, my $baseline);
文字列を描画したとき、その文字列が含まれる矩形の大きさとベースラインを 求めます。
このメソッドは、Cv 0.25 以前は、Pango::FontDescription に置いていました。 しかし、行儀が悪いので、Cv 0.26 で Cv に移しました。従って、0.25 以前は できた次の書き方では getTextSize() を呼ぶことができません。
my $font = Pango::FontDescription->from_string('Sans Serif 12'), $font->getTextSIze($text, my $size, my $baseline); # 呼べない
ありません。
CV_8UC1、CV_8UC3、CV_8UC4 以外の形式は扱えません。
Yuta MASUDA <yuta.masuda@newdaysys.co.jp>
Copyright (c) 2013 by Yuta MASUDA.
All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Cv::Pango, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Cv::Pango
CPAN shell
perl -MCPAN -e shell install Cv::Pango
For more information on module installation, please visit the detailed CPAN module installation guide.