Skip to content

Commit

Permalink
- Fixes to general readme.
Browse files Browse the repository at this point in the history
- Improvements to git pre-commit hook.
- Split crop function into two overloaded versions, one receives a vector of nodes and the other receives an xpath string.
- The crop function base_xpath parameter can now be any expression, even relative to Coords node.
  • Loading branch information
mauvilsa committed Apr 26, 2019
1 parent 3f5ea81 commit b16c042
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 82 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Check [py-pagexml/README.rst](py-pagexml/README.rst) and/or [docker/Dockerfile_b

# Contents

- [lib](lib): Directory containing the C++ PageXML library.
- [lib](lib): Directory containing the C++ PageXML and TextFeatExtractor libraries.
- [py-pagexml](py-pagexml): Swig-based python wrapper for the PageXML library.
- [py-textfeat](py-textfeat): Swig-based python wrapper for the PageXML library.
- [py-textfeat](py-textfeat): Swig-based python wrapper for the TextFeatExtractor library.

# Documentation

Expand Down
6 changes: 3 additions & 3 deletions docs/py-pagexml/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Overview: module code &mdash; pagexml 2019.4.23 documentation</title>
<title>Overview: module code &mdash; pagexml 2019.4.26 documentation</title>



Expand Down Expand Up @@ -58,7 +58,7 @@


<div class="version">
2019.4.23
2019.4.26
</div>


Expand All @@ -83,7 +83,7 @@


<ul>
<li class="toctree-l1"><a class="reference internal" href="../pagexml.html">pagexml API (version 2019.4.23)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../pagexml.html">pagexml API (version 2019.4.26)</a></li>
<li class="toctree-l1"><a class="reference external" href="https://omni-us.github.io/pageformat/pagecontent_omnius.html">OPF XSD schema documentation</a></li>
</ul>

Expand Down
6 changes: 3 additions & 3 deletions docs/py-pagexml/_modules/pagexml.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>pagexml &mdash; pagexml 2019.4.23 documentation</title>
<title>pagexml &mdash; pagexml 2019.4.26 documentation</title>



Expand Down Expand Up @@ -58,7 +58,7 @@


<div class="version">
2019.4.23
2019.4.26
</div>


Expand All @@ -83,7 +83,7 @@


<ul>
<li class="toctree-l1"><a class="reference internal" href="../pagexml.html">pagexml API (version 2019.4.23)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../pagexml.html">pagexml API (version 2019.4.26)</a></li>
<li class="toctree-l1"><a class="reference external" href="https://omni-us.github.io/pageformat/pagecontent_omnius.html">OPF XSD schema documentation</a></li>
</ul>

Expand Down
40 changes: 32 additions & 8 deletions docs/py-pagexml/_modules/pagexml/pagexml.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>pagexml &mdash; pagexml 2019.4.23 documentation</title>
<title>pagexml &mdash; pagexml 2019.4.26 documentation</title>



Expand Down Expand Up @@ -58,7 +58,7 @@


<div class="version">
2019.4.23
2019.4.26
</div>


Expand All @@ -83,7 +83,7 @@


<ul>
<li class="toctree-l1"><a class="reference internal" href="../../pagexml.html">pagexml API (version 2019.4.23)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../pagexml.html">pagexml API (version 2019.4.26)</a></li>
<li class="toctree-l1"><a class="reference external" href="https://omni-us.github.io/pageformat/pagecontent_omnius.html">OPF XSD schema documentation</a></li>
</ul>

Expand Down Expand Up @@ -10494,24 +10494,46 @@ <h1>Source code for pagexml</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">_pagexml</span><span class="o">.</span><span class="n">PageXML_getNodeName</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">node</span><span class="p">,</span> <span class="n">base_node</span><span class="p">)</span></div>


<div class="viewcode-block" id="PageXML.crop"><a class="viewcode-back" href="../../pagexml.html#pagexml.PageXML.crop">[docs]</a> <span class="k">def</span> <span class="nf">crop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">xpath</span><span class="p">,</span> <span class="n">margin</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">opaque_coords</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">transp_xpath</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">base_xpath</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<div class="viewcode-block" id="PageXML.crop"><a class="viewcode-back" href="../../pagexml.html#pagexml.PageXML.crop">[docs]</a> <span class="k">def</span> <span class="nf">crop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="sd"> Overloaded function with 2 signatures.</span>

<span class="sd"> **Signature 1**</span>

<span class="sd"> ``std::vector&lt; NamedImage &gt; PageXML::crop(const char *xpath, cv::Point2f *margin=NULL, bool opaque_coords=true, const char *transp_xpath=NULL, const char *base_xpath=NULL)``</span>

<span class="sd"> Crops images using its Coords polygon, regions outside the polygon are set to transparent.</span>

<span class="sd"> Arguments:</span>
<span class="sd"> xpath (const char *): Selector for Coord nodes to crop.</span>
<span class="sd"> margin (cv::Point2f *): Margins, if &gt;1.0 it is considered pixels, otherwise percentage of maximum between crop width and height.</span>
<span class="sd"> opaque_coords (bool): Whether to include an alpha channel with the polygon interior in opaque.</span>
<span class="sd"> transp_xpath (const char *): Selector for semi-transparent elements.</span>
<span class="sd"> base_xpath (const char *): Expression to construct sample name, overriding the default IMGBASE.ELEMID.</span>

<span class="sd"> Returns:</span>
<span class="sd"> std::vector&lt; NamedImage &gt;: An std::vector containing NamedImage objects of the cropped images.</span>

<span class="sd"> **Signature 2**</span>

<span class="sd"> ``std::vector&lt; NamedImage &gt; PageXML::crop(std::vector&lt; xmlNodePt &gt; elems_coords, cv::Point2f *margin=NULL, bool opaque_coords=true, const char *transp_xpath=NULL, const char *base_xpath=NULL)``</span>

<span class="sd"> Crops images using its Coords polygon, regions outside the polygon are set to transparent.</span>

<span class="sd"> Arguments:</span>
<span class="sd"> xpath (const char *): Selector for polygons to crop.</span>
<span class="sd"> margin (cv::Point2f *): Margins, if &gt;1.0 pixels, otherwise percentage of maximum of crop width and height.</span>
<span class="sd"> elems_coords (std::vector&lt; xmlNodePt &gt;): Vector of Coord nodes to crop.</span>
<span class="sd"> margin (cv::Point2f *): Margins, if &gt;1.0 it is considered pixels, otherwise percentage of maximum between crop width and height.</span>
<span class="sd"> opaque_coords (bool): Whether to include an alpha channel with the polygon interior in opaque.</span>
<span class="sd"> transp_xpath (const char *): Selector for semi-transparent elements.</span>
<span class="sd"> base_xpath (const char *): Selector for base node to use to construct the sample name.</span>
<span class="sd"> base_xpath (const char *): Expression to construct sample name, overriding the default IMGBASE.ELEMID.</span>

<span class="sd"> Returns:</span>
<span class="sd"> std::vector&lt; NamedImage &gt;: An std::vector containing NamedImage objects of the cropped images.</span>


<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">_pagexml</span><span class="o">.</span><span class="n">PageXML_crop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">xpath</span><span class="p">,</span> <span class="n">margin</span><span class="p">,</span> <span class="n">opaque_coords</span><span class="p">,</span> <span class="n">transp_xpath</span><span class="p">,</span> <span class="n">base_xpath</span><span class="p">)</span></div>
<span class="k">return</span> <span class="n">_pagexml</span><span class="o">.</span><span class="n">PageXML_crop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span></div>


<div class="viewcode-block" id="PageXML.stringToPoints"><a class="viewcode-back" href="../../pagexml.html#pagexml.PageXML.stringToPoints">[docs]</a> <span class="k">def</span> <span class="nf">stringToPoints</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">):</span>
Expand Down Expand Up @@ -11148,6 +11170,7 @@ <h1>Source code for pagexml</h1><div class="highlight"><pre>
<span class="sd"> elem (xmlNodePt): Element to move.</span>
<span class="sd"> node (const xmlNodePt): Reference element for insertion.</span>
<span class="sd"> itype (PAGEXML_INSERT): Type of insertion.</span>
<span class="sd"> bugimpl (bool): </span>

<span class="sd"> Returns:</span>
<span class="sd"> xmlNodePt: Pointer to moved element.</span>
Expand All @@ -11166,6 +11189,7 @@ <h1>Source code for pagexml</h1><div class="highlight"><pre>
<span class="sd"> elems (const std::vector&lt; xmlNodePt &gt; &amp;): Elements to move.</span>
<span class="sd"> node (const xmlNodePt): Reference element for insertion.</span>
<span class="sd"> itype (PAGEXML_INSERT): Type of insertion.</span>
<span class="sd"> bugimpl (bool): </span>

<span class="sd"> Returns:</span>
<span class="sd"> int: Pointer to moved element.</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/py-pagexml/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '2019.4.23',
VERSION: '2019.4.26',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
Expand Down
6 changes: 3 additions & 3 deletions docs/py-pagexml/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Index &mdash; pagexml 2019.4.23 documentation</title>
<title>Index &mdash; pagexml 2019.4.26 documentation</title>



Expand Down Expand Up @@ -59,7 +59,7 @@


<div class="version">
2019.4.23
2019.4.26
</div>


Expand All @@ -84,7 +84,7 @@


<ul>
<li class="toctree-l1"><a class="reference internal" href="pagexml.html">pagexml API (version 2019.4.23)</a></li>
<li class="toctree-l1"><a class="reference internal" href="pagexml.html">pagexml API (version 2019.4.26)</a></li>
<li class="toctree-l1"><a class="reference external" href="https://omni-us.github.io/pageformat/pagecontent_omnius.html">OPF XSD schema documentation</a></li>
</ul>

Expand Down
12 changes: 6 additions & 6 deletions docs/py-pagexml/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>py-pagexml: Python wrapper for the PageXML C++ library &mdash; pagexml 2019.4.23 documentation</title>
<title>py-pagexml: Python wrapper for the PageXML C++ library &mdash; pagexml 2019.4.26 documentation</title>



Expand All @@ -35,7 +35,7 @@
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="pagexml API (version 2019.4.23)" href="pagexml.html" />
<link rel="next" title="pagexml API (version 2019.4.26)" href="pagexml.html" />
</head>

<body class="wy-body-for-nav">
Expand All @@ -59,7 +59,7 @@


<div class="version">
2019.4.23
2019.4.26
</div>


Expand All @@ -84,7 +84,7 @@


<ul>
<li class="toctree-l1"><a class="reference internal" href="pagexml.html">pagexml API (version 2019.4.23)</a></li>
<li class="toctree-l1"><a class="reference internal" href="pagexml.html">pagexml API (version 2019.4.26)</a></li>
<li class="toctree-l1"><a class="reference external" href="https://omni-us.github.io/pageformat/pagecontent_omnius.html">OPF XSD schema documentation</a></li>
</ul>

Expand Down Expand Up @@ -302,7 +302,7 @@ <h3>Crop an element and save image to disk<a class="headerlink" href="#crop-an-e
<h2>Documentation Contents<a class="headerlink" href="#documentation-contents" title="Permalink to this headline"></a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="pagexml.html">pagexml API (version 2019.4.23)</a><ul>
<li class="toctree-l1"><a class="reference internal" href="pagexml.html">pagexml API (version 2019.4.26)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pagexml.html#module-pagexml">pagexml module</a></li>
</ul>
</li>
Expand All @@ -327,7 +327,7 @@ <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Pe

<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">

<a href="pagexml.html" class="btn btn-neutral float-right" title="pagexml API (version 2019.4.23)" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="pagexml.html" class="btn btn-neutral float-right" title="pagexml API (version 2019.4.26)" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>


</div>
Expand Down
Binary file modified docs/py-pagexml/objects.inv
Binary file not shown.
Loading

0 comments on commit b16c042

Please sign in to comment.