Skip to content

Commit

Permalink
no generate wrappers for constructors if none from hdr_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Mar 19, 2023
1 parent 0f9dbef commit 8ffc0f0
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 21 deletions.
3 changes: 2 additions & 1 deletion Imgproc/classes.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
@param clipLimit Threshold for contrast limiting.
@param tileGridSize Size of grid for histogram equalization. Input image will be divided into
equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column.'],
['Subdiv2D',[],''],
['Subdiv2D',[],'',0,'cv::Subdiv2D',[],'creates an empty Subdiv2D object.
To create a new empty Delaunay subdivision you need to use the #initDelaunay function.'],
['LineSegmentDetector',['Algorithm'],'@brief Line segment detector class
following the algorithm described at @cite Rafael12 .
Expand Down
4 changes: 2 additions & 2 deletions Objdetect/classes.pl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(
['CascadeClassifier',[],'@brief Cascade classifier class for object detection.'],
['CascadeClassifier',[],'@brief Cascade classifier class for object detection.',0,'cv::CascadeClassifier',[],''],
['QRCodeDetector',[],'@brief Groups the object candidate rectangles.
@param rectList Input/output vector of rectangles. Output vector includes retained and grouped rectangles. (The Python list is not modified in place.)
@param weights Input/output vector of weights of rectangles. Output vector includes weights of retained and grouped rectangles. (The Python list is not modified in place.)
@param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it.
@param eps Relative difference between sides of the rectangles to merge them into a group.'],
@param eps Relative difference between sides of the rectangles to merge them into a group.',0,'cv::QRCodeDetector',[],''],
);
12 changes: 10 additions & 2 deletions Videoio/classes.pl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@
- (Python) A multi threaded video processing sample can be found at
`OPENCV_SOURCE_CODE/samples/python/video_threaded.py`
- (Python) %VideoCapture sample showcasing some features of the Video4Linux2 backend
`OPENCV_SOURCE_CODE/samples/python/video_v4l2.py`'],
`OPENCV_SOURCE_CODE/samples/python/video_v4l2.py`',0,'cv::VideoCapture',[],'@brief Default constructor
@note In @ref videoio_c "C API", when you finished working with video, release CvCapture structure with
cvReleaseCapture(), or use Ptr\\<CvCapture\\> that calls cvReleaseCapture() automatically in the
destructor.'],
['VideoWriter',[],'@brief Video writer class.
The class provides C++ API for writing video files or image sequences.'],
The class provides C++ API for writing video files or image sequences.',0,'cv::VideoWriter',[],'@brief Default constructors
The constructors/functions initialize video writers.
- On Linux FFMPEG is used to write videos;
- On Windows FFMPEG or MSWF or DSHOW is used;
- On MacOSX AVFoundation is used.'],
);
14 changes: 10 additions & 4 deletions classes.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
neighborhood that needs to be taken into account), orientation and some other parameters. The
keypoint neighborhood is then analyzed by another algorithm that builds a descriptor (usually
represented as a feature vector). The keypoints representing the same object in different images
can then be matched using %KDTree or another method.'],
can then be matched using %KDTree or another method.',0,'cv::KeyPoint',[],''],
['DMatch',[],'@brief Class for matching keypoint descriptors
query descriptor index, train descriptor index, train image index, and distance between
descriptors.'],
descriptors.',0,'cv::DMatch',[],''],
['Algorithm',[],'@brief This is a base class for all more or less complex algorithms in OpenCV
especially for classes of algorithms, for which there can be multiple implementations. The examples
Expand All @@ -24,7 +24,10 @@
Here is example of SimpleBlobDetector use in your application via Algorithm interface:
@snippet snippets/core_various.cpp Algorithm'],
['FileStorage',[],'@brief XML/YAML/JSON file storage class that encapsulates all the information necessary for writing or
reading data to/from a file.'],
reading data to/from a file.',0,'cv::FileStorage',[],'@brief The constructors.
The full constructor opens the file. Alternatively you can use the default constructor and then
call FileStorage::open.'],
['FileNode',[],'@brief File Storage Node class.
The node is used to store each and every element of the file storage opened for reading. When
Expand All @@ -35,5 +38,8 @@
accessed by index. Type of the file node can be determined using FileNode::type method.
Note that file nodes are only used for navigating file storages opened for reading. When a file
storage is opened for writing, no data is stored in memory after it is written.'],
storage is opened for writing, no data is stored in memory after it is written.',0,'cv::FileNode',[],'@brief The constructors.
These constructors are used to create a default file node, construct it from obsolete structures or
from the another file node.'],
);
11 changes: 7 additions & 4 deletions genpp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ sub genheader {
local $@; my @classdata = !-f 'classes.pl' ? () : do ''. catfile curdir, 'classes.pl'; die if $@;
my %class2super = map +($_->[0]=>[map "PDL::OpenCV::$_", @{$_->[1]}]), @classdata;
my %class2doc = map +($_->[0]=>$_->[2]), @classdata;
my %class2info = map +($_->[0]=>[@$_[5..$#$_]]), @classdata;
my %class2info = map +($_->[0]=>[@$_[4..$#$_]]), @classdata;
my @classes = sort keys %class2doc;
if (@classes) {
require ExtUtils::Typemaps;
Expand Down Expand Up @@ -355,6 +355,9 @@ =head1 NAME
}
for my $c (@classes) {
pp_bless(my $fullclass = "PDL::OpenCV::$c");
pp_addxs(<<EOF); # work around PP bug
MODULE = ${main::PDLMOD} PACKAGE = ${main::PDLOBJ}
EOF
my $doc = $class2doc{$c} // '';
$doc = text_trim doxy2pdlpod(doxyparse($doc)) if $doc;
pp_addpm(<<EOD);
Expand All @@ -363,10 +366,10 @@ =head1 METHODS for $fullclass\n\n
=cut\n
\@${fullclass}::ISA = qw(@{$class2super{$c}});
EOD
my $extra_args = ($class2info{$c}||[])->[0] || $extra_cons_args{$c} || [];
my $cons_doc = ($class2info{$c}||[])->[1] || "\@brief Initialize OpenCV $c object.";
my $extra_args = ($class2info{$c}||[])->[1] || $extra_cons_args{$c} || [];
my $cons_doc = ($class2info{$c}||[])->[2] || "\@brief Initialize OpenCV $c object.";
my $cons_def = [$c, 'new', $cons_doc, 0, $c, ['char *', 'klass'], @$extra_args];
genpp(@$_) for $cons_def, grep $_->[0] eq $c, @flist;
genpp(@$_) for ($class2info{$c}[0] ? $cons_def : ()), grep $_->[0] eq $c, @flist;
}
pp_export_nothing();
pp_add_exported(map ref($_->[1])?$_->[1][1]:$_->[1], grep !$_->[0], @flist);
Expand Down
28 changes: 20 additions & 8 deletions genwrap.pl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ sub gen_wrapper {
dim0 => qq{ptrdiff_t cw_$vector_str${class}_dim0()},
pdlt => qq{int cw_$vector_str${class}_pdltype()},
);
my $no_cons = !$is_vector && !defined($cons_func);
delete @tdecls{qw(new dest)} if $no_cons;
my $hstr = <<EOF . join '', map "$_;\n", @tdecls{sort keys %tdecls};
typedef struct $wrapper $wrapper;
#ifdef __cplusplus
Expand All @@ -218,14 +220,14 @@ sub gen_wrapper {
#endif
EOF
my $cstr = <<EOF;
@{[$constructor_override{$class} && !$is_vector ? '' :
@{[$no_cons || ($constructor_override{$class} && !$is_vector) ? '' :
"$tdecls{new} {\n TRY_WRAP(" . ($no_ptr ? " *cw_retval = new $wrapper;" :
"\n (*cw_retval = new $wrapper)->held = @{[$cons_func || qq{cv::makePtr<cv::$class>}]}(@{[
"\n (*cw_retval = new $wrapper)->held = @{[($ptr_only ? '' : qq{cv::makePtr<}).$cons_func.($ptr_only ? '' : qq{>})]}(@{[
join ', ', map +(code_type(@$_))[3], @$extra_args
]});\n"
) . " )\n}"]}
$tdecls{dest} { delete wrapper; }
$tdecls{dim0} { return @{[0+@fields]}; }
@{[$no_cons ? '' : "$tdecls{dest} { delete wrapper; }\n"
]}$tdecls{dim0} { return @{[0+@fields]}; }
$tdecls{pdlt} { return @{[
@fields ? $REALCTYPE2NUMVAL{$fields[0][0]} // die "Unknown ctype '$fields[0][0]' for '$class'" :
$REALCTYPE2NUMVAL{$type_overrides{$class} ? $type_overrides{$class}[1] : $class} // '-1'
Expand Down Expand Up @@ -363,12 +365,22 @@ sub writefile {
print $fh $new;
}

sub readclasses {
return +{} if !-f 'classes.pl';
my @classlist = do ''. catfile curdir, 'classes.pl'; die if $@;
+{map +($_->[0]=>[
[], $_->[3]||$ptr_only{$_->[0]},
$_->[4]||$ptr_only{$_->[0]}, $_->[5]||$extra_cons_args{$_->[0]}
]), @classlist
};
}

my $filegen = $ARGV[0] || die "No file given";
my $extras = $filegen eq 'opencv_wrapper' ? [$HBODY_GLOBAL,gen_gettype().$CBODY_GLOBAL] : [qq{#include "opencv_wrapper.h"\n},""];
my $typespec = $filegen eq 'opencv_wrapper' ? { map +($_=>[$GLOBALTYPES{$_}, undef, undef, $extra_cons_args{$_}]), keys %GLOBALTYPES } : !-f 'classes.pl' ? +{} : do {
my @classlist = do ''. catfile curdir, 'classes.pl'; die if $@;
+{map +($_->[0]=>[[], $_->[3]||$ptr_only{$_->[0]}, $_->[4]||$ptr_only{$_->[0]}, $_->[5]||$extra_cons_args{$_->[0]}]), grep !$VECTORTYPES{$_->[0]}, @classlist}
};
my $localclasses = readclasses();
my $globalclasses = +{ map +($_=>[$GLOBALTYPES{$_}, undef, "cv::$_", $extra_cons_args{$_}]), keys %GLOBALTYPES };
$globalclasses->{$_} = delete $localclasses->{$_} for grep exists $localclasses->{$_}, keys %$globalclasses;
my $typespec = $filegen eq 'opencv_wrapper' ? $globalclasses : $localclasses;
my $vectorspecs = $filegen eq 'opencv_wrapper' ? \%VECTORTYPES : +{};
my @cvheaders = grep length, split /,/, $ARGV[1]||'';
my $funclist = $filegen eq 'opencv_wrapper' ? [] : \@funclist;
Expand Down
5 changes: 5 additions & 0 deletions maint/genlists
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ print "class::create: $cname\n";
my ($full, $cname) = ($1, $2);
print "classcreate: $cname\n";
$dest2class2create{$dest}{$cname} = [1, "cv::$full", $args, $doc];
} elsif ($name =~ /^cv\.([^.]+)\.\1/) { # Python constructors
my $cname = $1;
print "class.class: $cname\n";
print(" skipping with @{[0+@$args]}\n"), next if @$args; # temporary
$dest2class2create{$dest}{$cname} = [0, "cv::$cname", $args, $doc];
} elsif ($force{$name}) {
my (undef, @n) = split /\./, $name;
unshift @n, '' if @n == 1;
Expand Down

0 comments on commit 8ffc0f0

Please sign in to comment.