diff
- NOTE: This is our beta version of handwriter
- For the most stable version of handwriter please use:
- install.packages("handwriter")
- to get handwriter from CRAN: https://CRAN.R-project.org/package=handwriter
This readme covers the functionality of the Python-based handwriter
routines.
Here are the step by step instructions for Python Word Separation:
handwriter
repository to your local machinepip install opencv-python matplotlib ipython jupyter
inst/python
directory of the handwriter
repository. For example, on MacOS, you would run cd /path/to/cloned/handwriter/inst/python
, replacing the path with the actual path on your local machine.The next set of steps depend on whether you (a) prefer to run the code natively in Python, (b) prefer to run the code from a Jupyter Notebook, or (c) prefer to run the code from R.
python
import word_separation as ws
input_image="images/w0001_s03_pPHR_r01.png"
# Split the lines
split_images = ws.detect_lines(input_image)
split_images
# Display each split image
for split_image in split_images:
ws.show_image(ws.separate_word(file_name=split_image))
# Get every word extracted as a contour
all_words = []
for split_image in split_images:
im1_contours = ws.separate_word(file_name=split_image, ret="contours")
all_words.append(ws.annotate_image(split_image, im1_contours))
# Let's take a look!
all_words
batched = ws.batch_process("images")
jupyter notebook
Open up word_separation.ipynb
Execute the cells of the notebook
reticulate
Execute the word_separation.R
script in the inst/python
directory:
# We will need reticulate to call the Python functions
library(reticulate)
# Make sure you're using the right version of Python
use_python("/Users/erichare/.pyenv/shims/python")
# Source in the word separation code from this directory!
source_python("word_separation.py")
# Configure the input image
input_image="images/w0001_s03_pPHR_r01.png"
# Split the lines
split_images = detect_lines(input_image)
split_images
# Display each split image
for (split_image in split_images) {
show_image(separate_word(file_name=split_image))
}
# Get every word extracted as a contour
all_words <- list()
for (split_image in split_images) {
im1_contours = separate_word(file_name=split_image, ret="contours")
all_words[[length(all_words) + 1]] <- annotate_image(split_image, im1_contours)
}
# Let's take a look!
all_words
###
# Batch Processing
###
batch_process("images")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.