Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor] (WIP) Add a new tool in order to add an handwritten signature to a pdf (bug 1942343) #19339

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

calixteman
Copy link
Contributor

This patch is adding some code in order to extract a drawing as curves from an image. The algorithm is basically the following:

  • reduce the dimensions
  • make it gray
  • apply a bilateral filter in order to add some blurryness while keeping the edges
  • compute the histogram
  • guess what's the background color which should contain a large majority of the pixels
  • make a binary image
  • extract the contours in using the Suzuki algorithm
  • apply the Douglas-Peucker algorithm in order to reduce the number of points

The algorithm is improvable but it should work pretty well if there's a clear difference between the background and the drawing.
In a v2 we could use a ML model in order to improve the extraction.

There's few changes related to the UI in order to make the tool usable, but they're very basic for the moment.

@calixteman
Copy link
Contributor Author

/botio-linux preview

@mozilla mozilla deleted a comment from moz-tools-bot Jan 17, 2025
@mozilla mozilla deleted a comment from moz-tools-bot Jan 17, 2025
@calixteman
Copy link
Contributor Author

/botio-linux preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_preview from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/cfe6a210281f1ba/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/cfe6a210281f1ba/output.txt

Total script time: 0.86 mins

Published

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not reviewed signaturedraw.js in any detail, but overall the patch seems reasonable.

src/display/editor/drawers/signaturedraw.js Outdated Show resolved Hide resolved
src/display/editor/drawers/signaturedraw.js Outdated Show resolved Hide resolved
src/display/editor/drawers/signaturedraw.js Outdated Show resolved Hide resolved
src/display/editor/drawers/signaturedraw.js Outdated Show resolved Hide resolved
src/display/editor/drawers/signaturedraw.js Outdated Show resolved Hide resolved
web/editor_undo_bar.js Show resolved Hide resolved
web/images/toolbarButton-editorSignature.svg Outdated Show resolved Hide resolved
web/viewer.html Outdated Show resolved Hide resolved
web/viewer.html Outdated Show resolved Hide resolved
src/display/editor/signature.js Show resolved Hide resolved
…e to a pdf (bug 1942343)

This patch is adding some code in order to extract a drawing as curves from an image.
The algorithm is basically the following:
 - reduce the dimensions
 - make it gray
 - apply a bilateral filter in order to add some blurryness while keeping the edges
 - compute the histogram
 - guess what's the background color which should contain a large majority of the pixels
 - make a binary image
 - extract the contours in using the Suzuki algorithm
 - apply the Douglas-Peucker algorithm in order to reduce the number of points

The algorithm is improvable but it should work pretty well if there's a clear difference between
the background and the drawing.
In a v2 we could use a ML model in order to improve the extraction.

There's few changes related to the UI in order to make the tool usable, but they're very basic
for the moment.
Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, thanks.

@calixteman
Copy link
Contributor Author

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/42fef60dbe9d78a/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/51fcb1308f967fb/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/42fef60dbe9d78a/output.txt

Total script time: 10.92 mins

  • Integration Tests: FAILED

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/51fcb1308f967fb/output.txt

Total script time: 27.72 mins

  • Integration Tests: FAILED

@calixteman calixteman merged commit 42c2b7b into mozilla:master Jan 30, 2025
9 checks passed
@calixteman calixteman deleted the signature_tools branch January 30, 2025 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants