You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/components/nodes/stereo_depth.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ as:
62
62
(this confidence score is kind-of inverted, if say comparing with NN)
63
63
64
64
For the final disparity map, a filtering is applied based on the confidence threshold value: the pixels that have their confidence score larger than
65
-
the threshold get invalidated, i.e. their disparity value is set to zero. You can set the confidence threshold with :code:`stereo.setConfidenceThreshold()`.
65
+
the threshold get invalidated, i.e. their disparity value is set to zero. You can set the confidence threshold with :code:`stereo.initialConfig.setConfidenceThreshold()`.
Try running the script and ensure it executes without error:
78
79
@@ -111,13 +112,16 @@ Now, first node we will add is a :class:`ColorCamera`. We will use the :code:`pr
111
112
cam_rgb.setPreviewSize(300, 300)
112
113
cam_rgb.setInterleaved(False)
113
114
114
-
Up next, let's define a :class:`NeuralNetwork` node with `mobilenet-ssd network <https://docs.openvinotoolkit.org/latest/omz_models_public_mobilenet_ssd_moblenet_ssd.html>`__.
115
-
The blob file for this example can be found `here <https://github.com/luxonis/depthai-tutorials/raw/e37989e07a36a57ffef624b7aa8cf20ab493fa07/1-hello-world/mobilenet-ssd/mobilenet-ssd.blob>`__
115
+
Up next, let's define a :class:`MobileNetDetectionNetwork` node with `mobilenet-ssd network <https://docs.openvinotoolkit.org/latest/omz_models_public_mobilenet_ssd_moblenet_ssd.html>`__.
116
+
The blob file for this example will be compiled automatically using `blobconverter tool <https://pypi.org/project/blobconverter/>`__, we'll be provided with a ready-to-use blob path.
117
+
With this node, the output from nn will be parsed on device side and we'll receive a ready to use detection objects. For this to work properly, we need also to set the confidence threshold
Second, the neural network results will also need transformations. These are also returned as a 1D array, but this time
231
-
the array has a fixed size (constant, no matter how many results the neural network has actually produced).
232
-
Actual results in array are followed with :code:`-1` and then filled to meet the fixed size with :code:`0`.
233
-
One results has 7 fields, each being respectively :code:`image_id, label, confidence, x_min, y_min, x_max, y_max`.
234
-
We will want only the last four values (being the bounding box), but we'll also filter out the ones which :code:`confidence`
235
-
is below a certain threshold - it can be anywhere between <0..1>, and for this example we will use :code:`0.8` threshold
233
+
Second, we will receive the neural network results. Default MobileNetSSD result has 7 fields, each being respectively :code:`image_id, label, confidence, x_min, y_min, x_max, y_max`,
234
+
and by accessing the :code:`detections` array, we receive the detection objects that allow us to access these fields
236
235
237
236
.. code-block:: python
238
237
239
238
if in_nn isnotNone:
240
-
bboxes = np.array(in_nn.getFirstLayerFp16())
241
-
bboxes = bboxes[:np.where(bboxes ==-1)[0][0]]
242
-
bboxes = bboxes.reshape((bboxes.size //7, 7))
243
-
bboxes = bboxes[bboxes[:, 2] >0.8][:, 3:7]
244
-
245
-
To better understand this flow, let's take an example. Let's assume the :code:`np.array(in_nn.getFirstLayerFp16())` returns the following array
Last one - :code:`bboxes = bboxes[bboxes[:, 2] > 0.8][:, 3:7]` - will filter the results based on the confidence column (3rd one, with index :code:`2`)
267
-
to be above a defined threshold (:code:`0.8`) - and from these results, it will only take the last 4 columns being the bounding boxes.
268
-
Since both our results have a very high confidence (:code:`0.99023438` and :code:`0.98828125` respectively), they won't be filtered, and the final
269
-
array will look like this
270
-
271
-
.. code-block:: python
272
-
273
-
[
274
-
[0.45556641, 0.343994140.88037109, 0.9921875],
275
-
[0.03076172, 0.23388672, 0.60205078, 1.0078125]
276
-
]
239
+
detections = in_nn.detections
277
240
278
241
Display the results
279
242
###################
@@ -283,12 +246,12 @@ Up to this point, we have all our results consumed from the DepthaI device, and
0 commit comments