Detecting lines in a hand drawn canvas stroke

Go To


I have a drawing canvas and I would like break it apart into lines by finding the corners.

I'm collecting the stroke points using something similiar to this Google example:

I've been using to handle this in JavaScript. Does anyone know of an easy way to do this using Java on an Android device?

2012-04-04 06:45
by Josh


You can try something like a Hough Transform. It's a common way of finding shapes in Computer Vision applications. You might also want to combine it with an edge-detection algorithm, which is pretty simple to implement (maybe 20 or 30 lines of code).

2012-04-04 07:12
by Mike T
The seems to me like it's dealing more with images. Can it also be used to manually feed it points and have it return an array of lines - Josh 2012-04-04 07:23
Sorry, it seemed to me like you were trying to segment an image someone had already drawn. I don't think either of those is what you're looking for then. You could just try port the shortstraw javascript to Java. If you're willing to read a scientific paper to help you understand it, the algorithm is described hereMike T 2012-04-04 07:58
It's looking more and more like I'll be porting it. I guess I can't complain to much though, because in the process I'll learn something new haha - Josh 2012-04-04 08:03