Hello, im using opencv-python for image recognition, and i would like to use an algorythm based on recognized images being obstacles, what should i use for that context or how i would be going.
When I tackle a problem like this, I create a ‘mesh’ that avoids the obstacles. This is relatively simple. As I understand it, the ground is planar. This means you can build up the mesh quite finely. After that, you only need a ‘shortest path’ algorithm (Dijkstra’s algorithm, Bellman-Ford algorithm, A* search algorithm,
Floyd-Warshall algorithm, Johnson’s algorithm, Viterbi algorithm). When it comes to games, an A* algorithm is usually used. I myself prefer Dijkstra’s, which is implemented in an impressive way in boost::Graph)
Well the image is just an example but kinda misleading, it will go on the water surface but this wouldn’t change much right? and how will I create the mesh, for context im new to python and opencv
do you mean to do your path planning in image space or in a top-down view (map)?
I’d recommend that you seek out learning materials related to robotics, path planning, SLAM, etc. if you don’t, that’s equivalent to asking people to give you private classes.
I apologise for only getting back to you today. But I’m in South East Asia and I’m 5 hours ahead of CEST. OK, step by step.
Your question was quite general, but it deserves some clarification. Firstly, it is important to know whether a 3D scene is calculated from the photo or whether it remains with the planar photo. The procedure for the mesh (more later) is completely different.
As I understand it, the planarity is random. This indicates a 3D scene. In a 3D scene, you stretch a fine mesh over the highest Z value (in some systems Y value). You can construct the mesh in different ways. The simplest form is a rectangular mesh that is fine enough to allow a ‘soft’ path. Now calculate the intersection point of each vertex of the mesh
with your 3D scene by ‘shooting’ a ray in the direction of the scene with the vertex normal. You then correct the vertices with the intersection point of this calculation. Now you have a mesh that represents your terrain. Next, delete the vertices that lie within the obstacles you want to avoid. Maybe you also define a corona around these obstacles so that you don’t get too close to the obstacles.
scrape past the obstacles. Now choose your starting point and your destination point. The ‘shortest path’ algorithm follows and you have found your path.
However, if the path is searched for in the image, i.e. in the planar image, it is even easier. Here, too, you place a mesh over your overall image. You do not need to correct this in any way. Next, delete the vertices that lie within the obstacles you want to avoid. Maybe you also define a corona around these obstacles so that you don’t get too close to the obstacles.
scrape past the obstacles. Now choose your starting point and your destination point. This is followed by the ‘shortest path’ algorithm and you have found your path.
I don’t programme in python myself, but in C++. But there is a python programmer in my development team who I will ask today what kind of meshes he uses. But as today is Sunday, I can’t promise you whether he will get back to you today. In any case, I will get back to you as soon as he answers me.
My colleague recommended pyMesh or Open3D. Don’t worry. You can also create 2D meshes with 3D meshes.
Thank you for your feedback, i will look onto this.