The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

d/dai: Autodetect OAK-D vs OAK-D Lite

Co-authored-by: Jakob Bornecrantz <jakob@collabora.com>

authored by

Moses Turner
Jakob Bornecrantz
and committed by
Moses Turner
a5024060 1abf73df

+46 -5
+45 -5
src/xrt/drivers/depthai/depthai_driver.cpp
··· 136 136 dai::CameraImageOrientation image_orientation; 137 137 uint32_t fps; 138 138 bool interleaved; 139 + bool oak_d_lite; 139 140 }; 140 141 141 142 ··· 248 249 } 249 250 250 251 static void 251 - depthai_print_connected_cameras(struct depthai_fs *depthai) 252 + depthai_guess_camera_type(struct depthai_fs *depthai) 252 253 { 254 + // We could be a lot more pedantic here, but let's just not. 255 + // For now, ov7251 == oak-d lite, and ov9282 == oak-d/oak-d S2/oak-d pro 253 256 std::ostringstream oss = {}; 254 - for (const auto &cam : depthai->device->getConnectedCameras()) { 255 - oss << "'" << static_cast<int>(cam) << "' "; 257 + std::vector<dai::CameraBoardSocket> sockets = depthai->device->getConnectedCameras(); 258 + std::unordered_map<dai::CameraBoardSocket, std::string> sensornames = depthai->device->getCameraSensorNames(); 259 + 260 + bool ov9282 = false; 261 + 262 + bool ov7251 = false; 263 + 264 + 265 + 266 + for (size_t i = 0; i < sockets.size(); i++) { 267 + dai::CameraBoardSocket sock = sockets[i]; 268 + std::string sensorname = sensornames.at(sock); 269 + if (sensorname == "OV9282" || sensorname == "OV9*82") { 270 + ov9282 = true; 271 + } else if (sensorname == "OV7251") { 272 + ov7251 = true; 273 + } 274 + oss << "'" << static_cast<int>(sock) << "': " << sensorname << ", "; 256 275 } 276 + 277 + 257 278 std::string str = oss.str(); 258 279 259 280 DEPTHAI_DEBUG(depthai, "DepthAI: Connected cameras: %s", str.c_str()); 281 + 282 + if (ov9282 && !ov7251) { 283 + // OAK-D 284 + DEPTHAI_DEBUG(depthai, "DepthAI: Found an OAK-D!"); 285 + depthai->oak_d_lite = false; 286 + } else if (ov7251 && !ov9282) { 287 + // OAK-D Lite 288 + DEPTHAI_DEBUG(depthai, "DepthAI: Found and OAK-D Lite!"); 289 + depthai->oak_d_lite = true; 290 + } else { 291 + DEPTHAI_WARN(depthai, 292 + "DepthAI: Not sure what kind of device this is - going to pretend this is an OAK-D."); 293 + depthai->oak_d_lite = false; 294 + } 260 295 } 261 296 262 297 static void ··· 473 508 static void 474 509 depthai_setup_stereo_grayscale_pipeline(struct depthai_fs *depthai) 475 510 { 511 + 512 + // Get the camera calibration 513 + struct t_stereo_camera_calibration *calib = NULL; 514 + depthai_get_gray_cameras_calibration(depthai, &calib); 515 + 476 516 // Hardcoded to OV_9282 L/R 477 - if (true) { 517 + if (!depthai->oak_d_lite) { 478 518 // OV_9282 L/R 479 519 depthai->width = 1280; 480 520 depthai->height = 800; ··· 737 777 depthai->device = d; 738 778 739 779 // Some debug printing. 740 - depthai_print_connected_cameras(depthai); 780 + depthai_guess_camera_type(depthai); 741 781 depthai_print_calib(depthai); 742 782 743 783 // Make sure that the thread helper is initialised.
+1
src/xrt/drivers/depthai/depthai_interface.h
··· 39 39 40 40 /*! 41 41 * Create a DepthAI frameserver using two gray cameras. 42 + * Either OAK-D or OAK-D Lite. Custom FFC setups may or may not work. 42 43 * 43 44 * @ingroup drv_depthai 44 45 */