Detecting if a handwritten signature is in a Bitmap

from the CommonsWare Community archives

At April 4, 2019, 10:52am, Raptor asked:

Hello,

I have an app where I am trying to determine if there is a handwritten text in a bitmap (a signature). This must not be done using a cloud solution, only locally (I’m using Google Vision, locally, to also scan a QR and detect an “end of document” through OCR at the same time, and it works decently well. The resulting bitmap needs to be checked if the person hand-signed the paper in the bitmap.

My solution looks like this:

public void createPaletteAsync(Bitmap bitmap) {
        Palette.from(bitmap).maximumColorCount(40).generate(p -> {
            // Use generated instance
            List<Palette.Swatch> swatches = p.getSwatches();
            for (Palette.Swatch swatch : swatches) {
                float[] hslForCurrentSwatch = swatch.getHsl();
                Log.i(TAG, "HSL value is: " + Float.toString(hslForCurrentSwatch[0])
                        + "with a pixel population of: " + swatch.getPopulation());
                if (Math.round(hslForCurrentSwatch[0]) >= 210 && Math.round(hslForCurrentSwatch[0]) <= 240) {
                    ((TextView) findViewById(R.id.semnat)).setText("Signed document");
                    return;
                }
            }
            ((TextView) findViewById(R.id.semnat)).setText("Unsigned document");
        });
    }

So basically, I check if there are any swatches in the Bitmap that contain blue hues from 210 to 240 and if there are, I consider the document as “signed”. Obviously, this is problematic, as it only works for documents signed with a blue pen, and it requires the Bitmap only to contain the signed paper, with no “blue objects” in the photo.

Can you imagine any other way in which, locally (without any cloud-based solution), one could determine if the document is signed or not?


At April 4, 2019, 11:04am, mmurphy replied:

I have no idea, sorry. Image recognition is well outside my area of expertise.


At April 4, 2019, 11:46am, Raptor replied:

Yeah, mine’s too. Fortunately, it works pretty well in its current form if you use a blue pen to write your signature on the document (and capture the monochrome document only in your frame).