Skip to content

Commit c9abca8

Browse files
authored
Merge pull request #636 from luxonis/max_fov_update_docs
Max fov update docs
2 parents c3131d3 + b65e2e1 commit c9abca8

File tree

5 files changed

+50
-19
lines changed

5 files changed

+50
-19
lines changed
-233 KB
Binary file not shown.
253 KB
Loading

docs/source/components/nodes/color_camera.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ For IMX378 (12MP), the **post-processing** works like this:
6969
│ ISP ├────────────────►│ video ├───────────────►│ preview │
7070
└─────┘ max 3840x2160 └─────────┘ and cropping └──────────┘
7171
72+
.. image:: /_static/images/tutorials/isp.jpg
73+
74+
The image above is the ``isp`` output frame from the ColorCamera (12MP from IMX378). The blue rectangle represents the cropped 4K
75+
``video`` output, and the yellow rectangle represents a cropped ``preview`` output when the preview size is set to 1:1 aspect ratio
76+
(eg. when using 300x300 MobileNet-SSD NN model).
77+
7278
Usage
7379
#####
7480

docs/source/tutorials/dispaying_detections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ draw bounding boxes to it. For bounding boxes to match the frame, :code:`preview
3131
####################
3232

3333
A problem that we often encounter with models is that their aspect ratio is :code:`1:1`, not eg. :code:`16x9` as our camera resolution.
34-
This means that some of the FOV will be lost. In our :ref:`How to maximize FOV` tutorial we showcased that changing aspect ratio will
34+
This means that some of the FOV will be lost. In our :ref:`Maximizing FOV` tutorial we showcased that changing aspect ratio will
3535
preserve the whole aspect ratio of the camera, but it will "squeeze"/"stretch" the frame, as you can see below.
3636
`Demo code here <https://github.com/luxonis/depthai-experiments/blob/master/gen2-display-detections/3-stretch_img.py>`__.
3737

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,60 @@
1-
How to maximize FOV
2-
===================
1+
Maximizing FOV
2+
==============
33

4-
By default, when you are using :code:`preview` output from :ref:`ColorCamera`, the DepthAI will crop the
5-
frames to get the desired aspect ratio. For example, if you are using Mobilenet-SSD model, you need
6-
:code:`300x300` frames. DepthAI will crop 1080P frames to :code:`1080x1080` and then resize them to :code:`300x300`.
7-
This means you will lose some part of the image.
4+
In this tutorial we will look at how you can use the full FOV of the image sensor.
85

9-
If you would like to maximize the FOV of the image, you can either:
6+
When you are using ``preview`` output from :ref:`ColorCamera`, DepthAI will crop the
7+
frames by default to get the desired aspect ratio. ``preview`` stream derives from ``video`` stream, which is cropped (16:9 aspect ratio,
8+
max 4k resolution) from the ``isp`` stream, which has the full FOV.
109

11-
#. Change the aspect ratio (stretch the image)
12-
#. Apply letterboxing to the image
10+
.. image:: /_static/images/tutorials/isp.jpg
11+
12+
The image above is the ``isp`` output from the :ref:`ColorCamera` (12MP from IMX378). The blue rectangle represents the cropped 4K
13+
``video`` output, and the yellow rectangle represents a cropped ``preview`` output when the preview size is set to 1:1 aspect ratio
14+
(eg. when using 300x300 MobileNet-SSD NN model).
15+
16+
In other words, you **need to use ISP output** from the :ref:`ColorCamera` **to maximize the image FOV**. A challenge
17+
occures when your NN model expects different aspect ratio (eg. 1:1) compared to isp output (eg. 4:3). Let's say we have
18+
a MobileNet-SSD which requires 300x300 frames (1:1 aspect ratio) - we have a few options:
19+
20+
#. :ref:`Stretch the ISP frame <Change aspect ratio>` to to the 1:1 aspect ratio of the NN
21+
#. :ref:`Apply letterboxing <Letterboxing>` to the ISP frame to get 1:1 aspect ratio frame
22+
#. :ref:`Crop the ISP frame <Cropping>` to 1:1 aspect ratio and lose some FOV
1323

1424
Change aspect ratio
1525
*******************
1626

17-
Use :code:`camRgb.setPreviewKeepAspectRatio(False)`. This means the aspect ratio will not be preserved and the image
18-
will be "stretched". This might be problematic for some off-the-shelf NN models, so model fine-tuning it might be required.
19-
`Usage example here <https://github.com/luxonis/depthai-experiments/blob/master/gen2-lossless-zooming/main.py#L19>`__.
27+
**Pros: Preserves full FOV. Cons: Due to stretched frames, NNs accuracy might decrease.**
2028

21-
.. image:: https://user-images.githubusercontent.com/18037362/144095838-d082040a-9716-4f8e-90e5-15bcb23115f9.gif
22-
:target: https://youtu.be/8X0IcnkeIf8
29+
Changing aspect ratio (**stretching**) can be used Use :code:`camRgb.setPreviewKeepAspectRatio(False)`. This means the aspect
30+
ratio will not be preserved and the image will be "stretched". This might be problematic for some off-the-shelf NN models, so some fine-tuning might be required.
31+
`Usage example here <https://github.com/luxonis/depthai-experiments/blob/master/gen2-full-fov-nn/stretching.py>`__.
32+
33+
.. image:: https://user-images.githubusercontent.com/18037362/180607962-e616cdc7-fcad-4bc8-a15f-617b89a2c047.jpg
2334

2435
Letterboxing
2536
************
2637

27-
`Letterboxing <https://en.wikipedia.org/wiki/Letterboxing_%28filming%29>`__ the frames. This method will decrease
28-
the size of the image and apply "black bars" above and below the image, so the aspect ratio is preserved. You can
38+
**Pros: Preserves full FOV. Cons: Smaller "frame" means less features might decrease NN accuracy.**
39+
40+
`Letterboxing <https://en.wikipedia.org/wiki/Letterboxing_%28filming%29>`__ approach will apply "black bars" above and below
41+
the image to the full FOV (isp) frames, so the aspect ratio will be preserved. You can
2942
achieve this by using :ref:`ImageManip` with :code:`manip.setResizeThumbnail(x,y)` (for Mobilenet :code:`x=300,y=300`).
3043
The downside of using this method is that your actual image will be smaller, so some features might not be preserved,
3144
which can mean the NN accuracy could decrease.
32-
`Usage example here <https://github.com/luxonis/depthai-experiments/blob/master/gen2-full-fov-nn/main.py#L28>`__.
45+
`Usage example here <https://github.com/luxonis/depthai-experiments/blob/master/gen2-full-fov-nn/letterboxing.py>`__.
46+
47+
.. image:: https://user-images.githubusercontent.com/18037362/180607958-0db7fb34-1221-42a1-b889-10d1f9793912.jpg
48+
49+
Cropping
50+
********
51+
52+
**Pros: No NN accuracy decrease. Cons: Frame is cropped, so it's not full FOV.**
53+
54+
Cropping the full FOV (isp) frames to match the NN aspect ratio can be used to get the best NN accuracy, but this
55+
decreases FOV.
56+
`Usage example here <https://github.com/luxonis/depthai-experiments/blob/master/gen2-full-fov-nn/cropping.py>`__.
3357

34-
.. image:: /_static/images/tutorials/fov.jpeg
58+
.. image:: https://user-images.githubusercontent.com/18037362/180607873-6a476ea4-55e0-4557-a93e-a7cadcd80725.jpg
3559

60+
.. include:: /includes/footer-short.rst

0 commit comments

Comments
 (0)