Detecting if a handwritten signature is in a Bitmap



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("Signed document");
            ((TextView) findViewById("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?


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


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).