builtree / handwrite Goto Github PK
View Code? Open in Web Editor NEWHandwrite generates a custom font based on your handwriting sample.
Home Page: https://pypi.org/project/handwrite/
License: MIT License
Handwrite generates a custom font based on your handwriting sample.
Home Page: https://pypi.org/project/handwrite/
License: MIT License
The above input didn't work, tried with increased exposure:
The font was generated fine using handwrite-web (handwrite 0.2.1), but it had 2 issues:
cc @programmer290399
Found while testing: #67
Related: #62
Hello, I was making font file and got following error
Command I used
handwrite Handwrite.jpg ./
Error I got
Traceback (most recent call last):
File "/home/ganesh314159/.local/bin/handwrite", line 8, in <module>
sys.exit(main())
File "/home/ganesh314159/.local/lib/python3.9/site-packages/handwrite/cli.py", line 56, in main
converters(
File "/home/ganesh314159/.local/lib/python3.9/site-packages/handwrite/cli.py", line 34, in converters
run(sheet, output_directory, directory, config, metadata)
File "/home/ganesh314159/.local/lib/python3.9/site-packages/handwrite/cli.py", line 12, in run
SHEETtoPNG().convert(sheet, characters_dir, config)
File "/home/ganesh314159/.local/lib/python3.9/site-packages/handwrite/sheettopng.py", line 44, in convert
characters = self.detect_characters(
File "/home/ganesh314159/.local/lib/python3.9/site-packages/handwrite/sheettopng.py", line 116, in detect_characters
x, y, w, h = cv2.boundingRect(contours[i])
IndexError: list index out of range
Currently it does it on the default branch which is now dev, we need to explicitly checkout main branch for releases.
The above input didn't work, tried with increased exposure:
The font was generated fine using handwrite-web (handwrite 0.2.1), but it had 2 issues:
cc @programmer290399
Found while testing: #67
We need a final sheet structure and need finalized scaling parameter for each input.
Options:
(Running at Windows x64)
I followed the installation guide from the documentation and confirmed each install. But somehow, when I run
handwrite ./handwrite.jpg ./
in the terminal I get this error:
Traceback (most recent call last): File "c:\users\acer\anaconda3\envs\resnet\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\acer\anaconda3\envs\resnet\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\acer\Anaconda3\envs\Resnet\Scripts\handwrite.exe\__main__.py", line 7, in <module> File "c:\users\acer\anaconda3\envs\resnet\lib\site-packages\handwrite\cli.py", line 28, in main SVGtoTTF().convert(directory, args.output, args.config) File "c:\users\acer\anaconda3\envs\resnet\lib\site-packages\handwrite\svgtottf.py", line 23, in convert outfile, File "c:\users\acer\anaconda3\envs\resnet\lib\subprocess.py", line 423, in run with Popen(*popenargs, **kwargs) as process: File "c:\users\acer\anaconda3\envs\resnet\lib\subprocess.py", line 729, in __init__ restore_signals, start_new_session) File "c:\users\acer\anaconda3\envs\resnet\lib\subprocess.py", line 1017, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified
Related: #3
We should do this thresholding in sheettopng during the cropping process.
handwrite/handwrite/pngtosvg.py
Lines 69 to 76 in adca270
Realized after ec476e4 that we should explicitly pin dependencies, we were depending on setup.py which isn't good.
Implement helpful error messages/options to understand how and why things went wrong.
We dont have kerning and bearing for any of the special characters.
If the packaging isn't done till 0.2.0, we need to update users to install fontforge from the AppImage rather than the PPA.
PPA would work for Ubuntu >= 19.04 but since official support is gone, we should drop it too.
Probably will be done after #7
cod-ed.github.io/handwrite/ should be for master and cod-ed.github.io/handwrite/dev for dev.
Hi,
Thanks for this wonderful tool.
I am trying to use it on Windows Home 10.
I have installed fontforge in usual program files (x86) folder by download the installer.
Potrace is downloaded as zip and added the path to it in PATH env var.
Then from cmd I am running handwrite --directory "temp" "inputscan.jpg" "outputfont/"
In temp dir it creates all the folders per char.png (folder 59 is empty)
Then program throws error in sheettopng.py > cv2.inwrite() as below:
File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\Scripts\handwrite.exe\__main__.py", line 7, in <module> File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\site-packages\handwrite\cli.py", line 56, in main converters( File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\site-packages\handwrite\cli.py", line 34, in converters run(sheet, output_directory, directory, config, metadata) File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\site-packages\handwrite\cli.py", line 12, in run SHEETtoPNG().convert(sheet, characters_dir, config) File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\site-packages\handwrite\sheettopng.py", line 47, in convert self.save_images( File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\site-packages\handwrite\sheettopng.py", line 158, in save_images cv2.imwrite( cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp:801: error: (-215:Assertion failed) !_img.empty() in function 'cv::imwrite'
I am new to python, please let me know if I am missing anything.
Thanks,
Tushar
We won't probably test on windows for first release
We can move useful sheets to assets repo.
Way for generating font without numbers/symbols (this can still be done but will generate font with blanks if any box is left blank)
PS C:\Users\Gayashan\Desktop\hand> handwrite .\sample.jpg .\asd.ttf Traceback (most recent call last): File "C:\Users\Gayashan\miniconda3\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Gayashan\miniconda3\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Gayashan\miniconda3\Scripts\handwrite.exe\__main__.py", line 7, in <module> File "C:\Users\Gayashan\miniconda3\lib\site-packages\handwrite\cli.py", line 56, in main converters( File "C:\Users\Gayashan\miniconda3\lib\site-packages\handwrite\cli.py", line 34, in converters run(sheet, output_directory, directory, config, metadata) File "C:\Users\Gayashan\miniconda3\lib\site-packages\handwrite\cli.py", line 14, in run SVGtoTTF().convert(characters_dir, output_directory, config, metadata) File "C:\Users\Gayashan\miniconda3\lib\site-packages\handwrite\svgtottf.py", line 28, in convert subprocess.run( File "C:\Users\Gayashan\miniconda3\lib\subprocess.py", line 505, in run with Popen(*popenargs, **kwargs) as process: File "C:\Users\Gayashan\miniconda3\lib\subprocess.py", line 951, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Gayashan\miniconda3\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified
❯ handwrite Downloads/sa\ handwrite\ font_1\ \(1\).jpg .
Traceback (most recent call last):
File "/home/saahil/anaconda3/envs/handwrite/bin/handwrite", line 8, in <module>
sys.exit(main())
File "/home/saahil/anaconda3/envs/handwrite/lib/python3.7/site-packages/handwrite/cli.py", line 57, in main
args.input_path, args.output_directory, args.directory, args.config, metadata
File "/home/saahil/anaconda3/envs/handwrite/lib/python3.7/site-packages/handwrite/cli.py", line 34, in converters
run(sheet, output_directory, directory, config, metadata)
File "/home/saahil/anaconda3/envs/handwrite/lib/python3.7/site-packages/handwrite/cli.py", line 12, in run
SHEETtoPNG().convert(sheet, characters_dir, config)
File "/home/saahil/anaconda3/envs/handwrite/lib/python3.7/site-packages/handwrite/sheettopng.py", line 49, in convert
characters_dir,
File "/home/saahil/anaconda3/envs/handwrite/lib/python3.7/site-packages/handwrite/sheettopng.py", line 160, in save_images
images[0],
cv2.error: OpenCV(4.5.4) /tmp/pip-req-build-3129w7z7/opencv/modules/imgcodecs/src/loadsave.cpp:799: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
❯ fontforge -v
Copyright (c) 2000-2021. See AUTHORS for Contributors.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
Version: 20201107
Based on sources from 2021-11-27 12:18 UTC-ML-D-GDK3.
Based on source from git with hash: 58238cc173c80379d0d4616971fc793da26c6aa4
fontforge 20201107
build date: 2021-11-27 12:18 UTC
❯ potrace -v
potrace 1.16. Copyright (C) 2001-2019 Peter Selinger.
Library version: potracelib 1.16
Default unit: inches
Default page size: letter
❯ conda list
# packages in environment at /home/saahil/anaconda3/envs/handwrite:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
_openmp_mutex 4.5 1_gnu
ca-certificates 2021.10.26 h06a4308_2
certifi 2021.10.8 py37h06a4308_0
handwrite 0.3.0 pypi_0 pypi
ld_impl_linux-64 2.35.1 h7274673_9
libffi 3.3 he6710b0_2
libgcc-ng 9.3.0 h5101ec6_17
libgomp 9.3.0 h5101ec6_17
libstdcxx-ng 9.3.0 hd4cf53a_17
ncurses 6.3 h7f8727e_2
numpy 1.21.4 pypi_0 pypi
opencv-python 4.5.4.60 pypi_0 pypi
openssl 1.1.1l h7f8727e_0
pillow 8.4.0 pypi_0 pypi
pip 21.2.2 py37h06a4308_0
python 3.7.11 h12debd9_0
readline 8.1 h27cfd23_0
setuptools 58.0.4 py37h06a4308_0
sqlite 3.36.0 hc218d9a_0
tk 8.6.11 h1ccaba5_0
wheel 0.37.0 pyhd3eb1b0_1
xz 5.2.5 h7b6447c_0
zlib 1.2.11 h7b6447c_3
Fitted to A4 size using Adobe Scan
Original image scanned using Adobe Scan
❯ neofetch
██████████████████ ████████ saahil@saahil-gl638rd
██████████████████ ████████ ---------------------
██████████████████ ████████ OS: Manjaro Linux x86_64
██████████████████ ████████ Host: GL63 8RD REV:1.0
████████ ████████ Kernel: 5.10.79-1-MANJARO
████████ ████████ ████████ Uptime: 4 hours, 59 mins
████████ ████████ ████████ Packages: 1564 (pacman)
████████ ████████ ████████ Shell: bash 5.1.8
████████ ████████ ████████ Resolution: 1920x1080
████████ ████████ ████████ WM: i3
████████ ████████ ████████ Theme: Matcha-dark-sea [GTK2], Numix [G
████████ ████████ ████████ Icons: Papirus-Dark [GTK2/3]
████████ ████████ ████████ Terminal: kitty
████████ ████████ ████████ CPU: Intel i7-8750H (12) @ 4.100GHz
GPU: NVIDIA GeForce GTX 1050 Ti Mobile
GPU: Intel CoffeeLake-H GT2 [UHD Graphi
Memory: 3189MiB / 15850MiB
This could have happened in multiple other places:
We had given up on trimming the PNG file after converting to BMP, we need explore this more if this would be helpful now.
We also need to remove the redundant config inputs and clean up svgtotff.py
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.