Simple app for visual editing of Page XML files

Overview

Name

nw-page-editor - Simple app for visual editing of Page XML files.

Version: 2021.02.22

Description

nw-page-editor is an application for viewing/editing ground truth or predicted information for diverse purposes related to the areas of document processing and text recognition. The edition is done interactively and visually on top of images of scanned documents. Additionally the app supports many keyboard shortcuts to allow more efficient editing, see section Application usage shortcuts.

The app is available in two variants. The first variant is as a desktop application based on the NW.js framework thus making it cross-platform. The second variant is as a web application that allows remote editing by multiple users and can be easily setup via a docker container.

Supported formats

The format used for storing the information is the omni:us Pages Format hightly based on the PRImA Page XML schema, but only supports a subset of elements and has a few minor extensions.

New XML files created by the app are saved as the latest version of the omni:us schema. Modifications to existing XML files using older omni:us schemas or PRImA schemas since version 2013-07-15 are saved using the original schema. Note that this might mean that the saved XMLs are no longer valid according to that schema. Additionally the app supports importing XMLs from other formats, namely: PRImA 2010-03-19, alto v2 and v3, tet and poppler's pdftotext xhtml. Many details from imported formats might be lost and there is no functionality to export back to those formats.

Desktop variant

After correct installation of the desktop app, the standard way in Linux and Mac to start the app is through the command line, normally specifying which file(s) to open. In windows currently it is not possible to open files directly from the command line, so you need to start the app and then select a file to open.

Command line synopsis

nw-page-editor [*page.xml*]+ [*pages_dir*]+ [--list *pages_list*]+ [--css *file.css*]+ [--js *file.js*]+

Example Page XML files

You can find example Page XML files in the nw-page-editor source code repository, the directory examples. Thus, you can open the examples as:

nw-page-editor examples/*.xml

Desktop variant installation

Linux/Mac:

  1. Download the SDK version of the NW.js package appropriate for your platform from http://nwjs.io/downloads. Extract it to a location where you store applications and add to your PATH the directory containing the nw|nwjs binary: root of package in Linux or nwjs.app/Contents/MacOS in OSX. Alternatively to setting the PATH it is also possible to simply symlink the nw|nwjs executable to a directory already in your path.

  2. Clone the nw-page-editor repository (using the --recursive option) to a location where you store applications and add the package's bin directory to your PATH. Like in the previous step, alternatively you can simply symlink the bin/nw-page-editor executable to a directory already in your path.

Windows:

In the github repository's releases there are for selected version prebuilt packages for windows. To install, go to https://github.com/mauvilsa/nw-page-editor/releases and download and extract the latest nw-page-editor-win-x64.zip file. To open the app, execute the nw-page-editor.exe and for convenience create a shortcut to open the app.

If you are interested in the latest version for which there is no prebuilt package, follow the following instructions:

  1. Download the SDK version of the NW.js package appropriate for your platform from http://nwjs.io/downloads. Extract it to a location where you store applications renaming the base directory to nw-page-editor.

  2. Move, copy or clone the files of this github repository such that the file package.json is in the same directory as nw.exe. If cloning be sure that you use the --recursive option.

  3. For convenience rename the nw.exe executable to nw-page-editor.exe and create a shortcut to it in your desktop to ease opening the app.

Notes:

  • The reason to install the SDK version of NW.js is to allow inspection of elements using the Chrome DevTools and for example be able to do Page XML modifications not implemented in the app.

Desktop variant startup CSS and JavaScript files

The --css and --js command line options can be used to modify the appearance or execute custom code on startup. For example, the following JavaScript code changes the position, color and size of overlayed text, and prints to a pdf.

setTimeout( function() {
    $.stylesheet('#page_styles { #xpg .TextEquiv }').css( 'fill', 'green' ); /* Set font color to green */
    $.stylesheet('#page_styles { #xpg .TextEquiv }').css( 'font-size', '60px' ); /* Set font size to 60px */
    pageCanvas.cfg.textPositionOffset = [ 10, 0 ]; /* Set text position x and y offsets */
    pageCanvas.util.positionText(); /* Update text position */
    nw.Window.get().print({pdf_path:loadedFile.replace(/\.xml$/,'.pdf')}); /* Print to pdf */
}, 500 );

To run this example save this code snippet to a file test.js and start the editor from the command line as

nw-page-editor --js test.js examples/lorem.xml

Web server variant

The page editor can also be used as a web server allowing multiple users to edit page xmls remotely. Moreover, the server can be configured so that all the history of changes of the page xmls are saved in a git repository with commits associated to the respective users. To ease the installation and usage of the web server version, docker is used.

Web server variant installation

The steps for installation are the following:

  1. Install docker in the server and for convenience configure it so that sudo is not required to run containers.

  2. Either pull the latest image of nw-page-editor-web from docker hub by choosing one of the available tags or build the docker image from the source.

## Pull from docker hub ##
TAG="YOUR CHOSEN TAG HERE"
docker pull mauvilsa/nw-page-editor-web:$TAG

## Build docker image from source ##
TAG="local"
docker build -t mauvilsa/nw-page-editor-web:$TAG .
  1. Create a directory for the data and copy the images and page xml that will be available to access remotely. It is highly recommended to make the data directory a git repository so that change history is kept.
## Create directory for data ##
mkdir data

## Copy documents, e.g. the examples in nw-page-editor source ##
cp $NW_PAGE_EDITOR_SOURCE/examples/* data

## Create list of xmls if use of lists is needed ##
ls data/*.xml | sed 's|^data/||' | head -n 2 > data/xmls.lst

## Init data directory as git repo ##
git init data
  1. By default the web app can be accessed without authentication in which case all git commits are associated to the anonymous user. Alternatively you can create users with passwords to restrict the access to the app and associate commits to different people. This is done by creating the file data/.htpasswd using the htpasswd tool. This tool might not be available in the server, but it is included in the nw-page-editor-web docker image. To ease the usage of htpasswd within this image, it is recommended that you use the docker-cli script. Just download it into some directory included in your PATH and then do the following.
## Create users and passwords ##
docker-cli -- mauvilsa/nw-page-editor-web:$TAG htpasswd -cb data/.htpasswd us[email protected] pass1
docker-cli -- mauvilsa/nw-page-editor-web:$TAG htpasswd -b data/.htpasswd [email protected] pass2

## For more details on htpasswd usage ##
docker-cli -- mauvilsa/nw-page-editor-web:$TAG htpasswd --help
  1. Start a container exposing the web server port 80 to a port of your preference (e.g. 8080) and set the data directory as a volume.
docker run --rm -d -p 8080:80 \
  -v $(pwd)/data:/var/www/nw-page-editor/data \
  mauvilsa/nw-page-editor-web:$TAG
  1. The Page XMLs can be accessed using URLs like the example ones below. Three different GET parameters can be used to specify which documents to view. In all cases relative paths with respect to the data directory must be given. The three supported parameters are:
    • f: to specify a single xml file
    • l: to specify a list of xml files
    • d: to specify a directory
http://$SERVER_ADDRESS:8080/app?f=lorem.xml
http://$SERVER_ADDRESS:8080/app?l=xmls.lst
http://$SERVER_ADDRESS:8080/app?d=.

Data owner, group and permissions

By default the files created/modified by the web server will use a default umask and have the same owner and group as the data directory. These defaults can be overridden by defining the DATA_UMASK, DATA_UID and DATA_GID environment variables.

docker run --rm -d -p 8080:80 \
  -e DATA_UMASK=007 -e DATA_UID=1234 -e DATA_GID=5000 \
  -v $(pwd)/data:/var/www/nw-page-editor/data \
  mauvilsa/nw-page-editor-web:$TAG

Web server variant startup CSS and JavaScript files

Similar to the desktop variant, the web variant can also receive css and js files to modify the appearance or execute custom code on startup. To use this functionality the css and js files need to be included in some path inside the data directory. Then the docker container should be started setting as value to the CSS and JS environment variables, relative paths to the files separated by spaces. For example:

docker run --rm -d -p 8080:80 \
  -e CSS=mystyle.css -e JS=mycode.js \
  -v $(pwd)/data:/var/www/nw-page-editor/data \
  mauvilsa/nw-page-editor-web:$TAG

Application usage shortcuts

Shortcut Command
ctrl/cmd + q Quit application
ctrl/cmd + o Open file dialog
ctrl/cmd + s Save changes to file
ctrl/cmd + shift + s Save as new file dialog
ctrl/cmd + p Print
ctrl/cmd + enter Open/close menu
ctrl/cmd + n New window
pageup Load previous document
pagedown Load next document
shift + pageup Load previous 10th document
shift + pagedown Load next 10th document
ctrl/cmd + z Undo last change
ctrl/cmd + y Redo last change
mouse click Select or deselect element
esc Deselect the currently selected element
tab Select the next element
shift + tab Select the previous element
ctrl + tab Select the next dragpoint
ctrl + shift + tab Select the previous dragpoint
ctrl + f Enable/disable text filtering
mouse click Start creating or add point to polygon/polyline
ctrl/cmd + mouse click Add point to and finish creating polygon/polyline
ctrl/cmd + del Delete selected element
del Delete selected element (only when text not editable)
minus + . Delete selected dragpoint
plus + . Add dragpoint next to selected
ctrl/cmd + 0 View full document (initial zoom)
ctrl/cmd + 1 Zoom to page of selected element or hovered
ctrl/cmd + 2 Zoom to selected element or hovered
ctrl/cmd + plus/minus Zoom in/out
shift + mouse wheel Zoom in/out
ctrl/cmd + arrows Move (pan) the image in the respective direction
mouse wheel Move (pan) the image in the respective direction
mouse drag Move (pan) the image in the respective direction
ctrl + , Select the next edit mode element level
ctrl + shift + , Select the previous edit mode element level
ctrl + . Select the next edit mode type
ctrl + shift + . Select the previous edit mode type
ctrl/cmd + e Open property editor for selected element
ctrl/cmd + shift + pageup Increase bottom pane text font size
ctrl/cmd + shift + pagedown Decrease bottom pane text font size
ctrl/cmd + pageup Increase overlayed text font size
ctrl/cmd + pagedown Decrease overlayed text font size
ctrl/cmd + g Change gamma of image
alt + arrows Change table selected cell in the respective direction
plus + c/r Split selected table column/row
minus + c/r Remove selected table column/row
move dragpoint Modifies dragpoint and its opposite dragpoint(s)
shift+ move dragpoint Modifies only the dragpoint, not the opposite(s)
ctrl/cmd + r Toggle selected element protection

Copyright

The MIT License (MIT)

Copyright (c) 2015-present, Mauricio Villegas [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • other region types

    other region types

    Hi, if I understand correctly, the application validates against https://github.com/omni-us/pageformat/blob/fe1ca7f589dfd8aa9cc9abcc4a336e9afddd8aba/pagecontent_omnius.xsd

    I was wondering: The schema mentions several elements which I don’t find reflected in the editor’s GUI, namely ImageRegion, SeparatorRegion and CustomRegion. Especially ImageRegion would be very helpful for us. Are there plans to include these as well? Thank you!

    enhancement 
    opened by dasch124 8
  • Validation error on store

    Validation error on store

    We have installed the docker image mauvilsa/nw-page-editor-web:2019.01.28 from dockerhub (the latest image did not work), however when I try to edit a text box in the sample file at {ourmachine}/app/?f=lorem.xml&n=1 I receive the following validation error on saving:

    Problems saving file ../data/lorem.xml: 400: Page XML schema validation failed:
    ../data/lorem.xml~2:85: element Group: Schemas validity error : Element '{http://schema.primaresearch.org/PAGE/gts/pagecontent/2013-07-15}Group': This element is not expected. Expected is ( {http://schema.primaresearch.org/PAGE/gts/pagecontent/2013-07-15}Page ).
    ../data/lorem.xml~2 fails to validate
    SvgCanvas/[email protected]://page-editor.acdh-dev.oeaw.ac.at/js/svg-canvas.js?v=2019.01.28:248:15
    saveFile/<@https://page-editor.acdh-dev.oeaw.ac.at/js/web-app.js?v=2019.01.28:176:24
    [email protected]://page-editor.acdh-dev.oeaw.ac.at/js/jquery-3.2.1.min.js:2:28017
    [email protected]://page-editor.acdh-dev.oeaw.ac.at/js/jquery-3.2.1.min.js:2:28783
    [email protected]://page-editor.acdh-dev.oeaw.ac.at/js/jquery-3.2.1.min.js:4:14035
    c/<@https://page-editor.acdh-dev.oeaw.ac.at/js/jquery-3.2.1.min.js:4:16323
    

    Anything we can do about it?

    bug 
    opened by dasch124 5
  • Convert pdf to page-xml

    Convert pdf to page-xml

    On 2019/09/01 23:02, deepseek wrote:

    @mauvilsa Thank you for your hard word,

    Is there a way to convert a pdf file into a page-xml file. perhaps convert the pdf to svg first, then to page-xml?

    opened by ghost 4
  • support newer PAGE-XML versions

    support newer PAGE-XML versions

    AFAICS the latest version nw-page-editor can open/import is the 2017-07-15 schema (although the import transform does not seem to do anything really). When I open a 2018 or 2019 PAGE-XML, I get: Expected as input a Page document.

    What would be required to get them to work? (I have spawned a new xslt/page_from_2019-07-15.xslt from xslt/page_from_2017-07-15.xslt and added this to js/web-app.js as well as js/nw-app.js, but still get the same error.)

    Maybe the XSLT needs to actually remove (or rename/map) elements and attributes that have been added to the schema since 2013? See here for a summary of what has changed.

    enhancement 
    opened by bertsky 3
  • Installs and opens, but can't give any commands

    Installs and opens, but can't give any commands

    Hi, this might be a severe case of pebkac, in which case I apologize. After installing and opening nw-page-editor (trying with one of my own scans as well as your examples) I can neither create not modify any of the polygons. None of the commands from the README (except for Ctrl+O) seem to do anything at all. Wondering if the NW.JS version (83.0.4103.61) might be the problem?

    opened by sixtyfive 2
  • Add short-cut to go to single-page view in one go (without using the current zoom option).

    Add short-cut to go to single-page view in one go (without using the current zoom option).

    Viewing the separate pages of a multi-page document, is very slow on my computer. Could a short-cut be implemented, other than [ ctr/cmd +plus/minus / shift + mouse wheel ], to speed up the single-page view?

    enhancement 
    opened by didirus 1
  • nw-page-editor: error: unable to resolve the nw-page-editor app location on OSX

    nw-page-editor: error: unable to resolve the nw-page-editor app location on OSX

    OSX 10.12.5

    added path in ~/.zshrc .

    export PATH=$PATH:/Applications/nwjs.app/Contents/MacOS
    export PATH=$PATH:/Applications/nw-page-editor/bin
    
    echo $PATH
    /Users/crokobit/.rvm/gems/ruby-2.2.2/bin:/Users/crokobit/.rvm/gems/[email protected]/bin:/Users/crokobit/.rvm/rubies/ruby-2.2.2/bin:/Users/crokobit/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/nwjs.app/Contents/MacOS:/Applications/nw-page-editor/bin:/Users/crokobit/.rvm/bin
    

    When I execute nw-page-editor /Users/crokobit/Projects/test.xml there is following error message:

    readlink: illegal option -- f
    usage: readlink [-n] [file ...]
    nw-page-editor: error: unable to resolve the nw-page-editor app location
    

    Many Thanks.

    bug 
    opened by crokobit 1
  • Problems writing to temporal file

    Problems writing to temporal file

    Hi, I'm experiencing strange problem with the latest release of the web-version of the editor, namely on saving I receive the following error:

    Problems saving file ../data/lorem.xml: 400: Problems writing to temporal file
    SvgCanvas/[email protected]://page-editor.acdh-dev.oeaw.ac.at/js/svg-canvas.js?v=2021.02.22:254:15
    saveFile/<@https://page-editor.acdh-dev.oeaw.ac.at/js/web-app.js?v=2021.02.22:182:24
    [email protected]://page-editor.acdh-dev.oeaw.ac.at/js/jquery-3.2.1.min.js:2:28017
    [email protected]://page-editor.acdh-dev.oeaw.ac.at/js/jquery-3.2.1.min.js:2:28783
    [email protected]://page-editor.acdh-dev.oeaw.ac.at/js/jquery-3.2.1.min.js:4:14035
    c/<@https://page-editor.acdh-dev.oeaw.ac.at/js/jquery-3.2.1.min.js:4:16323
    

    Here's what the logs tell me:

    ==> error.log <==
    [Fri Apr 09 14:43:35.004832 2021] [php7:warn] [pid 26] [client 172.17.0.1:44382] PHP Warning:  DOMDocument::loadXML(): Start tag expected, '&lt;' not found in Entity, line: 1 in /var/www/nw-page-editor/app/saveFile.php on line 49, referer: https://page-editor.acdh-dev.oeaw.ac.at/app/?f=lorem.xml&n=1
    [Fri Apr 09 14:43:35.004937 2021] [php7:warn] [pid 26] [client 172.17.0.1:44382] PHP Warning:  XSLTProcessor::transformToXml() expects parameter 1 to be object, bool given in /var/www/nw-page-editor/app/saveFile.php on line 49, referer: https://page-editor.acdh-dev.oeaw.ac.at/app/?f=lorem.xml&n=1
    [Fri Apr 09 14:43:35.004953 2021] [php7:warn] [pid 26] [client 172.17.0.1:44382] PHP Warning:  DOMDocument::loadXML(): Empty string supplied as input in /var/www/nw-page-editor/app/saveFile.php on line 50, referer: https://page-editor.acdh-dev.oeaw.ac.at/app/?f=lorem.xml&n=1
    [Fri Apr 09 14:43:35.004960 2021] [php7:warn] [pid 26] [client 172.17.0.1:44382] PHP Warning:  XSLTProcessor::transformToXml() expects parameter 1 to be object, bool given in /var/www/nw-page-editor/app/saveFile.php on line 50, referer: https://page-editor.acdh-dev.oeaw.ac.at/app/?f=lorem.xml&n=1
    
    ==> access.log <==
    172.17.0.1 - user1:NvDjj+FV [09/Apr/2021:14:43:34 +0000] "POST /app/saveFile.php HTTP/1.1" 200 59 "https://page-editor.acdh-dev.oeaw.ac.at/app/?f=lorem.xml&n=1" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0"
    

    Do you have an idea what could be causing this? Thanks in advance!

    opened by dasch124 1
Owner
Mauricio Villegas
I am a postdoc researcher/developer currently working at omni:us
Mauricio Villegas
Code for CVPR 2022 paper "SoftGroup for Instance Segmentation on 3D Point Clouds"

SoftGroup We provide code for reproducing results of the paper SoftGroup for 3D Instance Segmentation on Point Clouds (CVPR 2022) Author: Thang Vu, Ko

Thang Vu 231 Dec 27, 2022
scantailor - Scan Tailor is an interactive post-processing tool for scanned pages.

Scan Tailor - scantailor.org This project is no longer maintained, and has not been maintained for a while. About Scan Tailor is an interactive post-p

1.5k Dec 28, 2022
A Python script to capture images from multiple webcams at once and save them into your local machine

Capturing multiple images at once from Webcam Using OpenCV Capture multiple image by accessing the webcam of your system and save it to your machine.

Fazal ur Rehman 2 Apr 16, 2022
PianoVisuals - Create background videos synced with piano music using opencv

Steps Record piano video Use Neural Network to do body segmentation (video matti

Solbiati Alessandro 4 Jan 24, 2022
[ICCV, 2021] Cloud Transformers: A Universal Approach To Point Cloud Processing Tasks

Cloud Transformers: A Universal Approach To Point Cloud Processing Tasks This is an official PyTorch code repository of the paper "Cloud Transformers:

Visual Understanding Lab @ Samsung AI Center Moscow 27 Dec 15, 2022
A curated list of papers and resources for scene text detection and recognition

Awesome Scene Text A curated list of papers and resources for scene text detection and recognition The year when a paper was first published, includin

Jan Zdenek 43 Mar 15, 2022
OpenGait is a flexible and extensible gait recognition project

A flexible and extensible framework for gait recognition. You can focus on designing your own models and comparing with state-of-the-arts easily with the help of OpenGait.

Shiqi Yu 335 Dec 22, 2022
Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.

EasyOCR Ready-to-use OCR with 80+ languages supported including Chinese, Japanese, Korean and Thai. What's new 1 February 2021 - Version 1.2.3 Add set

Jaided AI 16.7k Jan 03, 2023
Rest API Written In Python To Classify NSFW Images.

✨ NSFW Classifier API ✨ Rest API Written In Python To Classify NSFW Images. Fastest Solution If you don't want to selfhost it, there's already an inst

Akshay Rajput 23 Dec 30, 2022
A curated list of resources for text detection/recognition (optical character recognition ) with deep learning methods.

awesome-deep-text-detection-recognition A curated list of awesome deep learning based papers on text detection and recognition. Text Detection Papers

2.4k Jan 08, 2023
virtual mouse which can copy files, close tabs and many other features !

AI Virtual Mouse Controller Developed an AI-based system to control the mouse cursor using Python and OpenCV with the real-time camera. Fingertip loca

Diwas Pandey 23 Oct 05, 2021
Steve Tu 71 Dec 30, 2022
Train custom VR face tracking parameters

Pal Buddy Guy: The anipal's best friend This is a small script to improve upon the tracking capabilities of the Vive Pro Eye and facial tracker. You c

7 Dec 12, 2021
Discord QR Scam Code Generator + Token grab mobile device.

A Python script that automatically generates a Nitro scam QR code and grabs the Discord token when scanned.

Visual 9 Nov 22, 2022
Web interface for browsing arXiv papers

Currently, arxivbox considers only major computer vision and machine learning conferences

Ankan Kumar Bhunia 12 Sep 11, 2022
Super Mario Game With Python

Super_Mario Hello all this is a simple python program which tries to use our body as a controller for the super mario game Here I have used media pipe

Adarsh Badagala 219 Nov 25, 2022
A small C++ implementation of LSTM networks, focused on OCR.

clstm CLSTM is an implementation of the LSTM recurrent neural network model in C++, using the Eigen library for numerical computations. Status and sco

Tom 794 Dec 30, 2022
Script para controlar o movimento do mouse usando Python e openCV com câmera em tempo real que detecta pontos de referência da mão, rastreia padrões de gestos em vez de um mouse físico.

mouserController Script para controlar o movimento do mouse usando Python e openCV com câmera em tempo real que detecta pontos de referência da mão, r

Vinícius Azevedo 6 Jun 28, 2022
Code for the paper "Controllable Video Captioning with an Exemplar Sentence"

SMCG Code for the paper "Controllable Video Captioning with an Exemplar Sentence" Introduction We investigate a novel and challenging task, namely con

10 Dec 04, 2022
Generate a list of papers with publicly available source code in the daily arxiv

2021-06-08 paper code optimal network slicing for service-oriented networks with flexible routing and guaranteed e2e latency networkslicing multi-moda

79 Jan 03, 2023