Skip to content

Commit

Permalink
get pointer-only name, etc from hdr_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Mar 6, 2023
1 parent 05d98f5 commit 36b48f9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
14 changes: 13 additions & 1 deletion Imgproc/classes.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,17 @@
following the algorithm described at @cite Rafael12 .

@note Implementation has been removed from OpenCV version 3.4.6 to 3.4.15 and version 4.1.0 to 4.5.3 due original code license conflict.
restored again after [Computation of a NFA](https://github.com/rafael-grompone-von-gioi/binomial_nfa) code published under the MIT license.'],
restored again after [Computation of a NFA](https://github.com/rafael-grompone-von-gioi/binomial_nfa) code published under the MIT license.',1,'cv::createLineSegmentDetector',[['int','refine','LSD_REFINE_STD',[]],['double','scale','0.8',[]],['double','sigma_scale','0.6',[]],['double','quant','2.0',[]],['double','ang_th','22.5',[]],['double','log_eps','0',[]],['double','density_th','0.7',[]],['int','n_bins','1024',[]]],'@brief Creates a smart pointer to a LineSegmentDetector object and initializes it.

The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want
to edit those, as to tailor it for their own application.

@param refine The way found lines will be refined, see #LineSegmentDetectorModes
@param scale The scale of the image that will be used to find the lines. Range (0..1].
@param sigma_scale Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
@param quant Bound to the quantization error on the gradient norm.
@param ang_th Gradient angle tolerance in degrees.
@param log_eps Detection threshold: -log10(NFA) \\> log_eps. Used only when advance refinement is chosen.
@param density_th Minimal density of aligned region points in the enclosing rectangle.
@param n_bins Number of bins in pseudo-ordering of gradient modulus.'],
);
9 changes: 5 additions & 4 deletions genpp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ sub genheader {
my ($last) = @_;
local $@; my @classdata = !-f 'classes.pl' ? () : do ''. catfile curdir, 'classes.pl'; die if $@;
my %class2doc = map +($_->[0]=>$_->[1]), @classdata;
my %class2info = map +($_->[0]=>[@$_[4..$#$_]]), @classdata;
my @classes = sort keys %class2doc;
my $descrip_label = @classes ? join(', ', @classes) : $last;
pp_addpm({At=>'Top'},<<"EOPM");
Expand Down Expand Up @@ -341,13 +342,13 @@ =head1 NAME
for my $c (@classes) {
pp_bless(my $fullclass = "PDL::OpenCV::$c");
pp_addhdr(qq{typedef ${c}Wrapper *PDL__OpenCV__$c;\n});
my $extra_args = $extra_cons_args{$c} || [];
my $extra_args = ($class2info{$c}||[])->[0] || $extra_cons_args{$c} || [];
my @cons_pars = map PP::OpenCV->new(0, @$_), ['char *', 'klass'], @$extra_args;
my $doc = $class2doc{$c} // '';
$doc = text_trim doxy2pdlpod(doxyparse($doc)) if $doc;
my $cons_doc = "\@brief Initialize OpenCV $c object.";
my $cons_doc = ($class2info{$c}||[])->[1] || "\@brief Initialize OpenCV $c object.";
my $cons_doxy = doxyparse($cons_doc);
$cons_doxy->{brief}[0] .= make_example('new', 1, \@cons_pars, [{name=>'obj'}], $fullclass, 1);
$cons_doxy->{brief}[0] .= make_example('new', 1, \@cons_pars, [{name=>'obj'}], $fullclass);
$cons_doc = text_trim doxy2pdlpod($cons_doxy);
pp_addpm(<<EOD);
=head1 METHODS for PDL::OpenCV::$c\n\n
Expand All @@ -359,7 +360,7 @@ =head2 new
pp_addxs(<<EOF);
MODULE = ${main::PDLMOD} PACKAGE = PDL::OpenCV::$c PREFIX=cw_${c}_
\nPDL__OpenCV__$c cw_${c}_new(@{[join ', ', map $_->xs_par, @cons_pars]})
CODE:\n cw_error CW_err = cw_${c}_new(&RETVAL@{[ map ", $_->{name}", @cons_pars ]});
CODE:\n cw_error CW_err = cw_${c}_new(&RETVAL@{[ join '', map ", $_->{name}", @cons_pars ]});
PDL->barf_if_error(*(pdl_error *)&CW_err);
OUTPUT:\n RETVAL
\nvoid cw_${c}_DESTROY(PDL__OpenCV__$c self)
Expand Down
4 changes: 2 additions & 2 deletions genwrap.pl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ sub gen_wrapper {
my $wrapper = "$vector_str${class}Wrapper";
my %tdecls = (
new => qq{cw_error cw_$vector_str${class}_new($wrapper **cw_retval, char *klass@{[
map ", @$_", @$extra_args
join '', map ", @$_[0,1]", @$extra_args
]})},
dest => qq{void cw_$vector_str${class}_DESTROY($wrapper *wrapper)},
dim0 => qq{ptrdiff_t cw_$vector_str${class}_dim0()},
Expand Down Expand Up @@ -369,7 +369,7 @@ sub writefile {
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]=>[[], $ptr_only{$_->[0]}, $ptr_only{$_->[0]}, $extra_cons_args{$_->[0]}]), @classlist}
+{map +($_->[0]=>[[], $_->[2]||$ptr_only{$_->[0]}, $_->[3]||$ptr_only{$_->[0]}, $_->[4]||$extra_cons_args{$_->[0]}]), @classlist}
};
my $vectorspecs = $filegen eq 'opencv_wrapper' ? \%VECTORTYPES : +{};
my @cvheaders = grep length, split /,/, $ARGV[1]||'';
Expand Down
12 changes: 11 additions & 1 deletion maint/genlists
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if (@ARGV) {
print Dumper $json_data;
exit;
}
my (%dest2enums, %dest2func2name2defs, %dest2classdefs);
my (%dest2enums, %dest2func2name2defs, %dest2classdefs, %dest2class2create);
for (@$json_data) {
my ($file, $d) = @$_;
my $dest = $file =~ /core/ ? "" : basename($file, ".hpp");
Expand All @@ -109,6 +109,10 @@ print "enum: $name\n";
next if !$class{$cname};
print "class: $cname\n";
push @{$dest2classdefs{$dest}}, [$cname, $doc];
} elsif ($ret =~ /^Ptr_/ and $name =~ /^cv\.(create(.*))/) {
my ($full, $cname) = ($1, $2);
print "classcreate: $cname\n";
$dest2class2create{$dest}{$cname} = [1, "cv::$full", $args, $doc];
} elsif ($force{$name}) {
my (undef, @n) = split /\./, $name;
unshift @n, '' if @n == 1;
Expand Down Expand Up @@ -193,4 +197,10 @@ EOF

writefile($_, 'funclist.pl', genfile($dest2funcs{$_})) for keys %dest2funcs;

for my $dest (keys %dest2classdefs) {
for my $c (@{$dest2classdefs{$dest}}) {
next unless my $extra = $dest2class2create{$dest}{$c->[0]};
push @$c, @$extra;
}
}
writefile($_, 'classes.pl', genfile($dest2classdefs{$_})) for keys %dest2classdefs;

0 comments on commit 36b48f9

Please sign in to comment.