Systems and methods for recognizing hand-drawn shapes
Described herein is a computer implemented method. The method includes receiving, via an input device, first user input drawing an input shape and generating, based on the first user input, original drawing data that includes an ordered set of points that define the input shape. The original drawing is processed to generate an input vector which also includes an ordered set of points. The input shape is then classified as a first template shape by processing the input vector using a machine learning model. A new shape is then generated based on the first template shape and the original drawing data.
1 . A computer implemented method for generating a new shape based on a template shape and an input shape, wherein:
the template shape is defined by template shape data that includes an ordered set of template shape points;
the ordered set of template shape points has a defined number of template shape points;
the input shape is defined by input shape data that includes an ordered set of input shape points;
the ordered set of input shape points has the defined number of input shape points; and
the method includes:
receiving original shape data that includes an ordered set of original shape points, wherein the ordered set of original shape points has a first number of original shape points, the first number being different to the defined number;
processing, by a processing unit, the original shape data to generate the input shape data that has the defined number of input shape points;
determining a plurality of test rotation values;
for each test rotation value in the plurality of test rotation values, performing a test that includes:
generating a test shape based on the template shape and the test rotation value; and
calculating a dissimilarity score for the test shape, the dissimilarity score being a measure of dissimilarity between the input shape and the test shape;
determining, based on the dissimilarity scores, a particular test shape that most closely matches the input shape; and
generating the new shape based on the particular test shape.
2 . The computer implemented method of claim 1 , wherein generating the new shape includes:
performing a first test corresponding to a first test rotation value of the plurality of test rotation values, the first test including:
generating a first test shape by rotating the template shape according to the first test rotation value; and
calculating a first dissimilarity score for the first test shape.
3 . The computer implemented method of claim 2 , wherein generating the first test shape further includes translating the template shape.
4 . The computer implemented method of claim 2 , wherein generating the first test shape further includes translating the template shape by:
calculating an input shape centroid;
calculating a template shape centroid; and
translating the template shape so that the template shape centroid equals the input shape centroid.
5 . The computer implemented method of claim 2 , wherein generating the first test shape further includes stretching the template shape.
6 . The computer implemented method of claim 2 , wherein generating the first test shape further includes stretching the template shape in two orthogonal directions.
7 . The computer implemented method of claim 6 , wherein stretching the template shape in two orthogonal directions includes stretching the template shape so an x-coordinate variance of the stretched template shape matches an x-coordinate variance of the input shape and a y-coordinate variance of the stretched template shape matches a y-coordinate variance of the input shape.
8 . The computer implemented method of claim 2 , wherein performing the first test further includes:
generating a plurality of test shape variants, each test shape variant based on the first test shape;
calculating a dissimilarity sub-score for each of the test shape variants, the dissimilarity sub-score for a selected test shape variant being a measure of dissimilarity between the input shape and the selected test shape variant;
and wherein generating the new shape based on the particular test shape includes:
determining, based on the dissimilarity sub-scores, a particular test shape variant that most closely matches the input shape; and
generating the new shape based on the particular test shape variant.
9 . The computer implemented method of claim 8 , wherein generating the plurality of test shape variants based on the first test shape includes generating a first variant by point-order rotating the first test shape.
10 . The computer implemented method of claim 1 , wherein the first number is greater than the defined number.
11 . The computer implemented method of claim 1 , further including processing a vector graphic to generate the template shape data.
12 . The computer implemented method of claim 11 , wherein processing the vector graphic to generate the template shape data includes generating a linear approximation of the vector graphic.
13 . A computer processing system including:
a processing unit; and
a non-transitory computer-readable storage medium storing instructions, which when executed by the processing unit, cause the processing unit to perform a method for generating a new shape based on a template shape and an input shape, wherein:
the template shape is defined by template shape data that includes an ordered set of template shape points;
the ordered set of template shape points has a defined number of template shape points;
the input shape is defined by input shape data that includes an ordered set of input shape points;
the ordered set of input shape points has the defined number of input shape points; and
the method includes:
receiving original shape data that includes an ordered set of original shape points, wherein the ordered set of original shape points has a first number of original shape points, the first number being different to the defined number;
processing the original shape data to generate the input shape data that has the defined number of input shape points;
determining a plurality of test rotation values;
for each test rotation value in the plurality of test rotation values, performing a test that includes:
generating a test shape based on the template shape and the test rotation value; and
calculating a dissimilarity score for the test shape, the dissimilarity score being a measure of dissimilarity between the input shape and the test shape;
determining, based on the dissimilarity scores, a particular test shape that most closely matches the input shape; and
generating the new shape based on the particular test shape.
14 . The computer processing system of claim 13 , wherein generating the new shape includes:
performing a first test corresponding to a first test rotation value of the plurality of test rotation values, the first test including:
generating a first test shape by rotating the template shape according to the first test rotation value; and
calculating a first dissimilarity score for the first test shape.
15 . The computer processing system of claim 14 , wherein generating the first test shape further includes translating the template shape.
16 . The computer processing system of claim 13 , wherein the method further includes processing a vector graphic to generate the template shape data.
17 . A non-transitory storage medium storing instructions executable by processing unit to cause the processing unit to perform a method for generating a new shape based on a template shape and an input shape, wherein:
the template shape is defined by template shape data that includes an ordered set of template shape points;
the ordered set of template shape points has a defined number of template shape points;
the input shape is defined by input shape data that includes an ordered set of input shape points;
the ordered set of input shape points has the defined number of input shape points; and
the method includes:
receiving original shape data that includes an ordered set of original shape points, wherein the ordered set of original shape points has a first number of original shape points, the first number being different to the defined number;
processing the original shape data to generate the input shape data that has the defined number of input shape points;
determining a plurality of test rotation values;
for each test rotation value in the plurality of test rotation values, performing a test that includes:
generating a test shape based on the template shape and the test rotation value; and
calculating a dissimilarity score for the test shape, the dissimilarity score being a measure of dissimilarity between the input shape and the test shape;
determining, based on the dissimilarity scores, a particular test shape that most closely matches the input shape; and
generating the new shape based on the particular test shape.
18 . The non-transitory storage medium of claim 17 , wherein generating the new shape includes:
performing a first test corresponding to a first test rotation value of the plurality of test rotation values, the first test including:
generating a first test shape by rotating the template shape according to the first test rotation value; and
calculating a first dissimilarity score for the first the test shape.
19 . The non-transitory storage medium of claim 18 , wherein generating the first test shape further includes translating the template shape.
20 . The non-transitory storage medium of claim 17 , wherein the method further includes processing a vector graphic to generate the template shape data.