Geometric Shape Recognition

Is there any way to recognize geometric shapes in Unity? I suppose there is some properties of the object that can lead you to detect it’s geometric shape with a script.

Geometric shapes are defined as a set of positions in space conformig to a rule usually expressed by math function. In unity geometric shapes defined via mesh class. You can check all vertices in mesh to conform that rule or not and see if that’s the shape you want or not.

1 Like

Thanks for the reply. I try to create a script to dynamically detect objects’ geometric shapes. As i understood from your reply, i should create a script that takes as input the vertices an object and generate tha data of it’s shape, that will give us the necessary information for recognizing it.

do you have images of example shapes that you want to detect?

1 Like

No. You need to take vertices of object and check if they conform an equation for that shape. You do not need to generate any data, just test existing data. Let’s use simple ellipse as an example. The equation for ellispe is

xx / aa + yy / bb = 1

You need to check all points of the shape fits this equation.

1 Like

The think is that the script should detect & recognize any object. Not a particular one. The script should be used in any scene and detect dyanamically any possible object.

So with this approach, i could detect dynamically any kind of object (not only basic shapes, but more complex) that appears on the scene? Even if i the script has not been written for this particular scene (possibly a managed plugin)?

Thanks for the replies :slight_smile:

do you mean object detection like,
https://github.com/mbaske/yolo-unity

1 Like

Yep. Be careful though and do not forget about discrete nature of those shapes.
For instance, ellipse approximated with 4 points is rectangle in computer graphics. You might have seen rectangular pipes in Half-Life 1. You need to define some kind of accuracy for shapes representation.
Also It may turs out what some vertices do fit your equations for like a 0,001 so you should define some accuracy for comparsions when calculating functions.

1 Like

Yes, something like this. Have you tried this one?

Ok, i’ ll try to implement this approach. Thanks a lot for all your replies. Amazing community :slight_smile:

not yet, but interested also… there should be other options too,
opencv probably can do that (there’s plugins for unity),
seen this also GitHub - Syn-McJ/TFClassify-Unity: An example of using Tensorflow with Unity for image classification and object detection. and others.

1 Like

Using AI to detect simple geometric shapes looks somewhat like overengineering, its more about detecting real life objects from textures that shapes from meshes.

1 Like

yeah, just suggesting alternatives, since its not clear whats the purpose here is (and where the objects come from etc)

1 Like

I agree. It could be a solution using AI/ML, but i think it could be a simpler solution for somehting like this.

The think here is that a fire should detect/recognize objects and spread according to the objects which getting in touch. So, i need to find a way recognize the geometry of every object, a scene could possible have.

ok if its for a game, and just for fire spreading… then forget those AI stuff.

Since its your scene, you should already know what objects are spawned/placed into level?

those objects can already contain information about what material (or shape) they are, how well they burn etc.
(can have data in attached script, or tagging objects, or saving data into mesh vertex colors/attributes, or having special burn_mask texture that it reads etc.)

see also,

1 Like

It’s not my scene. It should adapt in any scene. I 've already checked the fire propagation asset, but i think it has some issues with the new unity terrain. Although, it’s algorithms may be helpful.

so it could be used as a plugin that people might use anywhere, or could be used in moddable games with user generated content?

just trying to get the idea how it will be used… i mean normally people would know whats in their scenes,
so they can tag objects or do other preprocessing to make object burning properties to work.

what do you actually want to recognize from the object?
i mean, you could have a 3d metal chair and 3d wooden chair (painted with wood color),
where the mesh is pretty much same shape, but burning properties are different… so thats why i’m suggesting some meta data in objects…

sorry, more questions than answers :slight_smile:
(but its interesting topic, i need to implement free fire in one game later also)

1 Like

To spread a fire over unknown scene, I would bet on materials and polygons. I would require my users to configure list of burnable materials, their burning speed temperature and fire resistance. I would set mesh as particle emitter and add triangles to that mesh from neighbor objects when they start burning. I would give 1 burn point to every object touched by fire particle and start burning that object from most often touched triangle when the object got enough burning points based on material or materials used for that object.

1 Like