WillNilges / inkpath

A plugin for transcribing hand-drawn notes, diagrams, and tables onto xournalpp documents
GNU General Public License v2.0
18 stars 1 forks source link

Determine stroke width through outline tracing #12

Open WillNilges opened 2 years ago

WillNilges commented 2 years ago

An important next step is to decide how the strokes and splines should be passed from Lua to the API function. I'm not quite happy how it is done now. Keep in mind that the API should be used by everyone who wants to add strokes and splines to a Xournal++ document from a Lua plugin. In particular assuming that points have no pressure and that the stroke width is 1.5 is unacceptable.

Suggestion for drawStroke (in final form):

stroke = {
x = {[1] = number, [2] = number, ...., [N] = number}
y = {[1] = number, [2] = number, ...., [N] = number}
pressure = {[1] = number, [2] = number, ...., [N] = number}
width = number
color = integer
fill = integer
tool = string
lineStyle = string
}

I'm not 100% sure whether it is better to have the x-coordinates, y-coordinates and pressure values separated, or to create a table of points, where each point is a table consisting of x, y-coordinates and pressure-value. The first approach is the one used by the Google IME API and other handwriting recognition software.

It is not necessary to implement all of that at once, but at least everything that is assigned explicitly (like the stroke width) should be implemented.

Originally posted by @rolandlo in https://github.com/xournalpp/xournalpp/issues/3688#issuecomment-1002210890

This just gave me a (completely unrelated to the conversation) idea, for how to maybe use Potrace in order to deduce stroke width. It's pretty good at finding the outline of shapes, so I'm wondering if it'd be possible to somehow deduce the distance between opposing sides of a stroke to set the stroke width, then somehow trace the centerline. There's some OpenCV math out there that might make this possible. Further investigation is (obviously) required.