Get the distance of the closet point

hi there!
I am wondering if it is possible for zed2i cam to give me the distance of the closet point while running the custom detector?
what I am doing is that I am detecting and tracking objects, then avoid them. But, my system can not avoid the wall! I want to include a closet point to the camera in the detector file, please!
could you give help me please
to sum up
how to get the closet point distance ?
any tutorial for that please

and another one please?
is there any way to get a specific reign in the image or Image Masking with zed?

thanks a lot

        distances = []
        for i in range(image_left.get_width()):                                      
        	for j in range(image_left.get_height()):
        #x = round(image_left.get_width() / 2)
        #y = round(image_left.get_height() / 2)
        		err, point_cloud_value = point_cloud.get_value(i, j)
        		distance = math.sqrt(point_cloud_value[0] * point_cloud_value[0] +
                 	point_cloud_value[1] * point_cloud_value[1] +
                 	point_cloud_value[2] * point_cloud_value[2])

        		if distance !=0:
        		   if distance <= minz:

        print("Minimum Distance to Camera at ({0}, {1}): {2} m".format(minx, miny, minz), end="\r")

I got the idea! But it is slow
any idea to make faster please help

There are indeed a lot of ways to go faster. You can combine them to get even faster.

  • The double for loop is very inefficient in python. using C++ will help a lot.
  • You can multithread your for loop so that it runs in parallels. In C++, you’d be using #pragma omp parallel for for example.
  • Even better, you can run this calculation on the GPU, if you know how to use CUDA. That would be the most efficient method, but also the most advanced one.
  • You can reduce the resolution of the image
  • You can skip half the point, if you guess that if a single point is very close his neighbour will be too (this is pretty much the same as reducing the resolution)
  • …etc.



I crop the image then do that

thanks a lot