luxonis / depthai-python

DepthAI Python Library
MIT License
358 stars 193 forks source link

documentation glitches in Hello world tutorial #447

Open piponazo opened 2 years ago

piponazo commented 2 years ago

Hi, I just started my journey playing with the OAK-D camera and I found some "glitches" in the hello world tutorial. I thought about proposing a Pull Request with corrections, but I do not know enough about the project yet to make proper corrections. Therefore, I just wanted to mention it here so that somebody else hopefully can take the feedback and improve the documentation page:

  1. In the dependencies section, the python version is specified for Ubuntu or Raspbian, but not for other platforms (Windows, OSX, etc).
  2. Starting from section Define a pipeline there are references to dai. But that object or alias is not defined before. I actually noticed that in the code repository with the examples, dai is not used anymore.
MihailV1989 commented 2 years ago

Hi, I'm joining in and asking as well for clarification of the tutorial.

About 2.: dai is probably short for depthai, so I just wrote in my code: import depthai as dai and of course replaced 'depthai' with dai in two lines where it's still called that way.

But there are more:

  1. the following code line is probably just an example: detection_nn.setBlobPath("/path/to/mobilenet-ssd.blob")

But there is no info how to get the blob. I took a look at full code at github (https://github.com/luxonis/depthai-tutorials/blob/master/1-hello-world/hello_world.py) and there you have instead: detection_nn.setBlobPath(str(blobconverter.from_zoo(name='mobilenet-ssd', shaves=6)))

  1. But as I further inspected the whole .py at github, I've noticed that there the pipeline methods are called differently at several lines, e.g.: detection_nn = pipeline.createMobileNetDetectionNetwork() instead of this in the tutorial: detection_nn = pipeline.create(dai.node.NeuralNetwork)

Then I checked the tutorial history on github and saw that after there was a commit " update tutorials to latest API (#294) " on 21 June, there was a an another commit "Merge branch 'develop' into gen2_scripting" on 24 June that changed the way the pipeline methods were called, as already mentioned above.

Is the older version of the tutorial from 21 June really using an older API? Because I constantly get errors with the current version of the tutorial:

Traceback (most recent call last):
  File "c:\Users\mpv98\AIKIT\depthai-tutorials-practice\1-hello-world\hello_world.py", line 27, in <module>
    detection_nn.setConfidenceThreshold(0.5)
AttributeError: 'depthai.node.NeuralNetwork' object has no attribute 'setConfidenceThreshold'

Then I have commented out the line and got the next error:

Traceback (most recent call last):
  File "c:\Users\mpv98\AIKIT\depthai-tutorials-practice\1-hello-world\hello_world.py", line 62, in <module>
    detections = in_nn.detections
AttributeError: 'depthai.NNData' object has no attribute 'detections'
Luxonis-Brandon commented 2 years ago

Thanks for the report and sorry for the trouble here. Asking the team on this (who are in Europe, so will be online in ~9 hours or so).

Erol444 commented 2 years ago

Sorry about these inaccuracies, I am currently fixing them. @piponazo 1) Python required version is >=3.6. 2) it should be import depthai as dai @MihailV1989 3) We are using blobconverter to download converted model, and it returns Path to the model. 4) It's a bit of a quirk in our API - both styles are supported, so it's up to you which to use. WRT AttributeError: 'depthai.node.NeuralNetwork' object has no attribute 'setConfidenceThreshold' - Only MobileNetDetectionNetwork and YoloDetectionNetwork (and Spatial versions of these 2 nodes) have option to set confidence threshold - as model results are parsed on the device itself. So we have changed from NeuralNetwork node to MobileNetDetectionNetwork, and output of NeuralNetwork node is NNData (which doesn't have detections attribute, while for MobileNetDetectionNetwork it's ImgDetections, which does have detections attribute. Sorry again for all this confusion, fixing docs/tutorial now.

Erol444 commented 2 years ago

PR here: https://github.com/luxonis/depthai-python/pull/449

MihailV1989 commented 2 years ago

PR here: #449

So far so good. But then you forgot to change detection_nn = pipeline.create(depthai.node.NeuralNetwork) to detection_nn = pipeline.create(depthai.node.MobileNetDetectionNetwork) didn't you?

Erol444 commented 2 years ago

@MihailV1989 you are right, thanks for noticing!