Description :
\'Cv\' is the Perl interface to the OpenCV computer vision library that originally developed by Intel. I\'m making this module to use the computer vision more easily like a slogan of perl _\"Easy things should be easy, hard things should be possible.\"_
The features are as follows.
* *
\'Cv\' was made along the online reference manual of C in the OpenCV documentation. For details, please refer to the http://opencv.willowgarage.com/.
* *
You can use \'CreateSomething()\' as a constructors.
my $img = Cv->CreateImage([ 320, 240 ], IPL_DEPTH_8U, 3); my $mat = Cv->CreateMat([ 240, 320 ], CV_8UC3);
* *
You can also use \'new\' as a constructor. \'Cv::Image->new\' is \'Cv->CreateImage()\', \'Cv::Mat->new\' is \'Cv->CreateMat()\'. In the calling parameters, there are some difference in CreateImage() and CreateMat(). But there are no difference in \'Cv::Something->new\'. This is because we create same object without knowing about original object in the \'Cv::Arr\'.
my $img = Cv::Image->new([ 240, 320 ], CV_8UC3); my $mat = Cv::Mat->new([ 240, 320 ], CV_8UC4);
You can omit parameters and that will be inherited.
my $sameone = $img->new; my $gray = $color->new(CV_8UC1);
* *
You have to call cvReleaseImage() when you\'ll destroy the image object in the OpenCV application programs. But in the \'Cv\', you don\'t have to call cvReleaseImage() because Perl calls \'DESTROY\' for cleanup. So the subroutine \'DESTROY\' has often been defined as an alias of cvReleaseImage(), cvReleaseMat(), ... and cvReleaseSomething().
Some functions, eg. cvQueryFrame() return a reference but that cannot be destroyed. In this case, the reference is blessed with \'Cv::Somthing::Ghost\', and identified. And disable destroying.
* *
You can use name of method, omitting \"cv\" from the OpenCV function name, and also use lowercase name beginning. For example, you can call \'cvCreateMat()\' as:
my $mat = Cv->CreateMat(240, 320, CV_8UC3); my $mat = Cv->createMat(240, 320, CV_8UC3);
* *
When you omit the destination image or matrix (often named \"dst\"), \'Cv\' creates new destination if possible.
my $dst = $src->Add($src2); my $dst = $src->Add($src2, $mask); # can\'t omit dst
in this case, you can create $dst as follows:
my $dst = $src->Add($src2, $src->new, $mask);
* *
Some functions in the OpenCV can handle inplace that use source image as destination one. To tell requesting inplace, you can use \'\\0\' as \'NULL\' for the destination.
my $dst = $src->Flip(\\0);
* *
The members of structure are same as function.
my ($c, $d) = ($img->channels, $img->depth); my ($h, $w) = ($img->height, $img->width); my ($r, $c) = ($img->rows, $img->cols); my AATTsz = $img->sizes;
But we can\'t use as lvalue.
my $roi = $img->roi; # GetImageROI($img) $img->roi($roi); # SetImageROI($img, $roi) my $coi = $img->coi; # GetImageCOI($img) $img->coi($coi); # SetImageCOI($img, $coi)
* *
There are functions Get() and Set(). They access an elements. You can call Get() as cvGetND(), and Set() as cvSetND(). So, you have to to call Fill() instead of calling the cvSetND().
my $x = $mat->Get($i, $j); # cvGetND($mat, [$i, $j]) my $x = $mat->Get(\\AATTidx); # cvGetND($mat, \\AATTidx);
When the number of indexes is less than the number of the dimensions, 0 is complemented as indexes.
$mat->Set([$i, $j, ...], $x); # cvSetND($mat, [$i, $j, ...], $x) $mat->Set(\\AATTidx, $x); # cvSetND($mat, \\AATTidx, $x) $mat->Fill($x); # cvSet($mat, $x)
* *
Ptr() returns a string that from specified element up to the end of the line. Parameters are same as Get().
my $str = $mat->Ptr($row, $col); # cvPtrND($mat, [$row, $col]); my $str = $mat->Ptr($row); # cvPtrND($mat, [$row]);
* *
There are functions to split per channel and merge them.
$rgb->Split($r, $g, $b); # cvSplit($rgb, $r, $g, $b) my ($r, $g, $b) = $rgb->Split; # cvSplit($rgb, $r, $g, $b) my $rgb = Cv->Merge($r, $g, $b); # cvMerge([$r, $g, $b], $rgb);
* *
cvAddS() and cvAdd() are integrated into Add(). The function which can be identified by the argument.
my $ar2 = Cv->CreateImage(); # ref Cv::Image my $sc2 = cvScalar(); # ref ARRAY my $d = $ar->Add($ar2); # cvAdd($ar, $ar2) my $d = $ar->Add($sc2); # cvAddS($ar, $sc2)
The integrated function as follows.
AbsDiff(), Add(), And(), Cmp(), InRange(), Max(), Min(), Or(), Sub(), Xor()
|