The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

名前

Cv::Pango - 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 は、Pango を使用して、いろいろな文字を描きます。 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() を参照してください。

$font->getTextSize($text, my $size, my $baseline)

文字列のサイズとベースラインを求めます。サイズは幅と高さです。このサブ ルーチンは Pango::FontDescription に配置されます。行儀が悪いと思うので すが、どうすればいいのか分っていません。

エクスポート

ありません。

バグ

  • いまのところ、CV_8UC1 と CV_8UC4 しか使えません。

  • このパッケージは、フォントが Pango::FontDescription のオブジェクトにな るので、この名前空間に cvGetTextSize() を置きます。もっと上手なパッチの あて方をご存知の方は教えてください。

参考

Cv::Nihongo

著作権

Yuta MASUDA <yuta.masuda@newdaysys.co.jp>

Copyright (c) 2010, 2011, 2012 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.