I am working on an application in Android, wherein I have to get android.graphics.path values and compare them.
Consider the following images :

and

The first image shows a straight line and the generated Path value. Similarly, the second image,also shows a similar straight line, with a different Path value.
I’m unable to understand the value that is generated. Can anyone explain as to what exactly the generated values mean? Can I approximately take a wild guess about a path value from the screen coordinates?
Also, in my application, I would like to compare path values. The lines shown in the above figure are similar. And in my application, I would like to compare them and render them as same lines. And I’m not just going to compare lines, there’ll be curves and all such drawable shapes. For comparison do I first have to normalize my path values (maybe calling getMatrix for my current canvas?), so as to have the same effect for different screen sizes?
There is one other way of comparison that will be much simpler,finding centroids of the paths of figures. Obviously lines will have a centroid at a different position compared to curves,etc. But this sort of comparison won’t be so accurate. I wanted to store some value and then compare the generated path value to the stored value, along with comparing the centroids, so as to have a better accuracy. But for that, I need to understand the generated path values!
Please help or guide! Thanks! 🙂
Edit:
The code that I’m using for converting my path values to String. My path values are stored in an ArrayList (called pointsToDraw ). Here’s the code :
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
synchronized(pointsToDraw){
for(Path path : pointsToDraw)
{
stringPoints.add(String.valueOf(path));
}
}
TextView b1Text = (TextView) findViewById(R.id.GText);
for(String s : stringPoints)
{
b1Text.setText(s);
}
}
A
Pathobject is an object that encapsulates a series of geometric paths. If you want to programmatically compare one path to another, then the place I think you have to start is to usePathMeasureon thatPathobject in order to pull out all of the co-ordinates. UsingPathMeasureyou can obtain a series of co-ordinates that the path follows, by supplying a distance argument.PathMeasure
Then, in order to determine whether one given path is similar to another in terms of the size and its path along the screen, I would perhaps suggest using
PathMeasureon them both and comparing the co-ordinates they produce given incremental distance arguments. Then use some comparison algorithm, which may be as simple as determining whether each set of compared co-ordinates are within a distance from each other (with relative starting co-ordinates taken into account).So I can’t help with the algorithm you would use, but as a starting point, I think it’s
PathMeasurethat you have to use in order to inspect and analyse the data within thePathto begin with. Or, you might want to render them tobitmapand use some kind of image recognition library to compare those bitmaps, perhaps?