Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RSDK-8402] Migrate from OakCamera to DepthAI #51

Merged
merged 28 commits into from
Aug 5, 2024
Merged

[RSDK-8402] Migrate from OakCamera to DepthAI #51

merged 28 commits into from
Aug 5, 2024

Conversation

hexbabe
Copy link
Collaborator

@hexbabe hexbabe commented Jul 31, 2024

RSDK-8402

PR comment in luxonis/depthai
We were notified by Luxonis folk that they are sunsetting the OakCamera SDK. We should refactor our integration to use DepthAI

This PR switches out OakCamera functionality with the equivalent new idioms presented in their new shiny documentation https://docs.luxonis.com/

I did more thorough manual testing since this is kind of a huge change.

Testing

OAK-D tests on Mac

Integration tests

Passing ✅

OAK-D config with "color" sensor (get_image stream on app)

{
  "sensors": [
    "color"
  ]
}

image

Reconfigure from above -> OAK-D config with "color" sensor and dimensions (get_image stream on app)

{
  "sensors": [
    "color"
  ],
  "width_px": 640,
  "height_px": 480
}

image

Reconfigure from above -> OAK-D config add FPS (get_image stream on app)

{
  "sensors": [
    "color"
  ],
  "width_px": 640,
  "height_px": 480,
  "frame_rate": 10
}

Same as above but with choppy stream ✅

Reconfigure from above -> OAK-D config with color main sensor and depth secondary sensor (get_image stream on app)

{
  "sensors": [
    "color",
    "depth"
  ],
  "width_px": 640,
  "height_px": 480,
  "frame_rate": 10
}

Same as above ✅
I also switched the order and tested color as the main sensor with get_image and it looks good too ✅

Reconfigure from above -> OAK-D config with depth main sensor and color secondary sensor (get_image stream on app)

{
  "sensors": [
    "depth",
    "color"
  ],
  "width_px": 640,
  "height_px": 480,
  "frame_rate": 10
}

image

OAK-D config with depth main sensor and color secondary sensor (get_images from my Python client)

{
  "sensors": [
    "depth",
    "color"
  ],
  "width_px": 640,
  "height_px": 480,
  "frame_rate": 10
}

Honestly in a future PR I should source control the Python test client. But the results look good!

OAK-D config with depth main sensor and color secondary sensor (get_point_cloud from app)

{
  "sensors": [
    "depth",
    "color"
  ],
  "width_px": 640,
  "height_px": 480,
  "frame_rate": 10
}
Screenshot 2024-08-01 at 10 56 08 AM

OAK-FFC-3P on my RPI4

Single sensor on cam_c (get_image on app)

{
  "camera_sensors": [
    {
      "height_px": 720,
      "socket": "cam_c",
      "type": "color",
      "width_px": 1280
    }
  ]
}

image Hey Johnn ✅

Reconfigure from above -> two sensors with main on cam_b (get_image on app)

{
  "camera_sensors": [
        {
      "height_px": 720,
      "socket": "cam_b",
      "type": "color",
      "width_px": 1280
    },
    {
      "height_px": 720,
      "socket": "cam_c",
      "type": "color",
      "width_px": 1280
    }
  ]
}

image

Two sensors with main on cam_b (get_images with python test client)

{
  "camera_sensors": [
        {
      "height_px": 720,
      "socket": "cam_b",
      "type": "color",
      "width_px": 1280
    },
    {
      "height_px": 720,
      "socket": "cam_c",
      "type": "color",
      "width_px": 1280
    }
  ]
}

Two similar images were .show()-ed successfully by pillow ✅

Two sensors with main on cam_b with all attributes configured (get_image on app)

{
  "camera_sensors": [
    {
      "height_px": 720,
      "socket": "cam_b",
      "type": "color",
      "frame_rate": 5,
      "color_order": "bgr",
      "interleaved": true,
      "width_px": 1280
    },
    {
      "type": "color",
      "width_px": 1280,
      "height_px": 720,
      "socket": "cam_c"
    }
  ]
}

image
Color wonkiness of BGR is good. Frame rate looks around 5. Interleaved is not visually discernable, but no errors and we do set it! ✅

.gitignore Show resolved Hide resolved
.gitignore Show resolved Hide resolved
integration-tests/tests/oak_d_test.go Show resolved Hide resolved
src/components/worker/worker.py Show resolved Hide resolved
Copy link
Collaborator

@seanavery seanavery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice work!

Just left a couple of questions to better understand things.

BGR color wonkiness ok? Or should we handle that better?

"oak.start() called before oak was assigned. Must configure worker first."
async def start(self):
self.device = None
while not self.device and self.should_exec:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] will this infinite loop if device fails to initialize?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it will, but since it's an async function that async sleeps, it should yield to other tasks on the event loop

self.pipeline = dai.Pipeline()
try:
stage = "color"
color_node = configure_color()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] Will there be any issues wrt early exit of the try block here if one of the nodes fails to initialize?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think we actually set configured to True after, which is wrong. I'm gonna change it to re-raise a helpful exception instead in the except block

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


if self.cfg.sensors.stereo_pair:
self.depth_queue = self.device.getOutputQueue(
self.depth_stream_name, 30, blocking=False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] Is it ok to have hardcoded queue size here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (unhardcoded it and cleaned up some defaults at the top of the file)

@hexbabe
Copy link
Collaborator Author

hexbabe commented Aug 5, 2024

BGR color wonkiness ok? Or should we handle that better?

BGR looking weird through App is expected. On the scope, Pete raised the point that on Tennibot's demo repo, they request BGR color order explicitly. The attribute is default rgb unless bgr is explicitly supplied though

@hexbabe hexbabe merged commit 8b43ac8 into main Aug 5, 2024
2 checks passed
@hexbabe hexbabe deleted the RSDK-8402 branch August 5, 2024 18:54
@hexbabe hexbabe changed the title [RSDK-8402] Migrate from OakCamera to DepthAI v3 [RSDK-8402] Migrate from OakCamera to DepthAI Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants