ATSketchKit icon indicating copy to clipboard operation
ATSketchKit copied to clipboard

Fix the problem of recognition when using different device resolution

Open e7711bbear opened this issue 9 years ago • 3 comments

The unistroke recognition gives different results depending on the device used. It seems related to the resolution.

e7711bbear avatar Jan 23 '16 05:01 e7711bbear

This is because you are printing out the point coordinates before they are resampled, scaled, rotated, etc... You want the sample array to be the same size as the template and at same scale.

In recognizedPath:

 // just before doing the best template loop
   
self.printTemplateSource(sample)

Added a simplified printout to the same file:

   func printTemplateSource(_ points: [CGPoint]) {

        var sourceCode = "\nnewTemplate.points = ["

        for point in points {

            sourceCode += "CGPoint(x:\(point.x), y:\(point.y)),\n"

       }

        sourceCode += "]"

        NSLog("\(sourceCode)")

    }

jerryhalstead avatar Feb 15 '17 20:02 jerryhalstead

Also, distance function had a bug, here's what it should be:

	func distance(_ point1: CGPoint, point2: CGPoint) -> CGFloat {
		let deltaX = point2.x - point1.x
		let deltaY = point2.y - point1.y
		
		return sqrt(deltaX * deltaX + deltaY * deltaY)
	}

jerryhalstead avatar Feb 15 '17 20:02 jerryhalstead

Thanks again, do you mind opening a PR?

e7711bbear avatar Feb 15 '17 21:02 e7711bbear