Skip to main content

pie-chart-ocr

A tool to extract tabular data from pie charts, developed as a component of the CryptoSearchTools toolkit.

Note: The original repository was moved to https://git.ehtec.co/research/pie-chart-ocr. https://github.com/ehtec/pie-chart-ocr is a mirror.

Installation

Install via PyPi

You can install all tagged versions of piechartocr from PyPi:

python3 -m pip install --upgrade piechartocr

Note: You cannot run tests and examples from the PyPi installation. The required files need to be downloaded from Gitlab.

Build from source

Install Boost and Tesseract:

sudo apt install libboost-system-dev tesseract-ocr build-essential git

Clone this repository including submodules:

git clone --recursive https://github.com/ehtec/pie-chart-ocr.git
cd pie-chart-ocr

Install Python requirements:

python3 -m pip install -r requirements.txt

Compile libraries:

python3 setup.py build_ext

Create temporary directories:

mkdir temp
mkdir temp1
mkdir temp2

Unpack test charts:

unzip data/charts_steph.zip -d data
unzip data/charts_steph_upsampled.zip -d data
unzip data/generated_pie_charts_legend.zip -d data
unzip data/generated_pie_charts_without_legend.zip -d data

Usage

Run unit tests:

python3 -m nose2 --start-dir tests/ --with-coverage

Run legacy tests / examples:

python3 run_examples.py

Generate test data (mock pie charts):

python3 run_generate_test_data.py

To extract data from any pie chart:

from piechartocr import pie_chart_ocr

# Path to pie chart
path = "/path/to/my/chart.png"

# Extract data
data = pie_chart_ocr.main(path, interactive=False)

# Print the extracted list of tuples of the form [(percentage / 100, label)]
print(data["res"])

Metrics

These metrics are autogenerated by the CI-pipeline.

Metrics for mock pie charts with legend:

chart

Metrics for mock pie charts without legend:

chart

Metrics for real world pie charts (many of them in awful quality, some even unreadable for humans):

chart

Metadata

Release files for piechartocr 0.6.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for piechartocr 0.6.6
File Size Uploaded
piechartocr-0.6.6.tar.gz 95.1 MB Details

Release files / piechartocr-0.6.6.tar.gz

Download URL piechartocr-0.6.6.tar.gz
Size 95.1 MB
Tags Source
SHA-256 checksum
How to use checksums
dceda30533b8db3c614f44fc9202d571dac305d9c62d683784c1add7f8d4b498
BLAKE2b-256 checksum
How to use checksums
40b1e68d1b3f89b82f2e1bee5af43c2a8f762ace4b9ef64143f92e0437ded264
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

This release

0.6.6 This release

1 release file

0.6.5

1 release file

0.6.4

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.5.7

1 release file

0.5.6

1 release file

0.5.5

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page