We are currently experiencing some mishaps with the image manip setCenterCrop function :
We are using a OAK-D lite with stereo image input resolution of 480p; We then wanted to center crop the image by a ratio of 0.95 and a whRatio of 1.0.

Here is the following input image :

We then apply the following manip :
manip_right = pipeline.create(depthai.node.ImageManip)
manip_right.initialConfig.setCenterCrop(ratio=0.95,whRatio=1)
manip_right.initialConfig.setResize(640, 480)

here is the output :

The operation seems wrong so we use opencv to do the same operation :

The result with opencv is more coherent with a ratio=0.95

Is this the correct behavior of the image manip function ?

    jakaskerl
    thanks for your response. What is the difference between setResizeThumbnail and setResize please ? Is it possible to remove the black border when we do setResizeThumbnail please ?

      Hi AnhTuNguyen
      The setResizeThumbnail method resizes the image while maintaining the aspect ratio. This means that the resized image will have the same width-to-height ratio as the original image. If the specified size does not have the same aspect ratio as the original image, the method will resize the image to the maximum size that fits within the specified size and maintains the aspect ratio. This can result in the resized image being smaller than the specified size, and the remaining area will be filled with black pixels, creating a black border around the image.

      On the other hand, the setResize method resizes the image to the exact specified size. If the specified size does not have the same aspect ratio as the original image, the method will distort the image to fit the specified size.

      The whRatio=1 (square) does not reflect the latter 640 by 480 ratio, thats why you get black borders.

      Hope this helps ,
      Jaka

        jakaskerl
        Thanks !
        I understand the principle behind each resize, but that doesnt explain why the image cropped by the luxonis has a much smaller FoV than one cropped with opencv.

          Hi AnhTuNguyen
          I checked locally and it looks fine here. The setCenterCrop does crop the image to 0.95 the amount of pixels of the original image. When resizing an image the VFOV gets lowered because the input image is 1:1, but the HFOV remains the same. Perhaps there is something else going on in your pipeline? Can you check the W and H after applying centerCrop?

          Thanks,
          Jaka

            jakaskerl
            Thanks !
            However, the behavior of the resize is still very strange to me. I just did a simple test:

            • I used Luxonis Pro W, set resolution of Left camera at THE_400_P.
            • I didn't do any cropping, just simply resized to a random size, in this case i chose 480x640. I tested 2 types of resize: normal resize and resize with thumbnail. I received 2 different FoVs. You can see clearly that the FoV given by Normal resize is smaller than thumbnail resize (look at the right size of images, in the thumbnails you can see the image on the wall which doesnt appear in normal resize). That being said that your normal resize doesnt do only the resize but also other operations (crop maybe ?) ?

            With normal resize

            With thumbnail resize

              Hi AnhTuNguyen
              I see, any chance you could add the code you are using for this example so we can take a look?

              Thanks,
              Jaka