-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
258 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
bindings/python/src/pipeline/datatype/RGBDDataBindings.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
#include "DatatypeBindings.hpp" | ||
#include "pipeline/CommonBindings.hpp" | ||
#include <unordered_map> | ||
#include <memory> | ||
|
||
// depthai | ||
#include "depthai/pipeline/datatype/RGBDData.hpp" | ||
|
||
//pybind | ||
#include <pybind11/chrono.h> | ||
#include <pybind11/numpy.h> | ||
|
||
void bind_transformdata(pybind11::module& m, void* pCallstack){ | ||
|
||
using namespace dai; | ||
|
||
py::class_<RGBDData, Py<RGBDData>, Buffer, std::shared_ptr<RGBDData>> rgbdData(m, "RGBDData", DOC(dai, RGBDData)); | ||
|
||
/////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////// | ||
// Call the rest of the type defines, then perform the actual bindings | ||
Callstack* callstack = (Callstack*) pCallstack; | ||
auto cb = callstack->top(); | ||
callstack->pop(); | ||
cb(m, pCallstack); | ||
// Actual bindings | ||
/////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////// | ||
/////////////////////////////////////////////////////////////////////// | ||
|
||
// Metadata / raw | ||
rgbdData | ||
.def(py::init<>()) | ||
.def("__repr__", &RGBDData::str) | ||
.def_readwrite("rgbFrame", &RGBDData::rgbFrame, DOC(dai, RGBDData, rgbFrame)) | ||
.def_readwrite("depthFrame", &RGBDData::depthFrame, DOC(dai, RGBDData, depthFrame)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
|
||
import time | ||
import depthai as dai | ||
import sys | ||
import numpy as np | ||
|
||
try: | ||
import open3d as o3d | ||
except ImportError: | ||
sys.exit("Critical dependency missing: Open3D. Please install it using the command: '{} -m pip install open3d' and then rerun the script.".format(sys.executable)) | ||
|
||
|
||
class O3DNode(dai.node.ThreadedHostNode): | ||
def __init__(self): | ||
dai.node.ThreadedHostNode.__init__(self) | ||
self.inputPCL = self.createInput() | ||
|
||
|
||
def run(self): | ||
def key_callback(vis, action, mods): | ||
global isRunning | ||
if action == 0: | ||
isRunning = False | ||
pc = o3d.geometry.PointCloud() | ||
vis = o3d.visualization.VisualizerWithKeyCallback() | ||
vis.create_window() | ||
vis.register_key_action_callback(81, key_callback) | ||
pcd = o3d.geometry.PointCloud() | ||
coordinateFrame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=1000, origin=[0,0,0]) | ||
vis.add_geometry(coordinateFrame) | ||
first = True | ||
while self.isRunning(): | ||
inPointCloud = self.inputPCL.tryGet() | ||
if inPointCloud is not None: | ||
points, colors = inPointCloud.getPointsRGB() | ||
pcd.points = o3d.utility.Vector3dVector(points.astype(np.float64)) | ||
colors = (colors.reshape(-1, 3) / 255.0).astype(np.float64) | ||
pcd.colors = o3d.utility.Vector3dVector(colors) | ||
if first: | ||
vis.add_geometry(pcd) | ||
first = False | ||
else: | ||
vis.update_geometry(pcd) | ||
vis.poll_events() | ||
vis.update_renderer() | ||
vis.destroy_window() | ||
|
||
# Create pipeline | ||
|
||
with dai.Pipeline() as p: | ||
fps = 30 | ||
# Define sources and outputs | ||
left = p.create(dai.node.Camera) | ||
right = p.create(dai.node.Camera) | ||
color = p.create(dai.node.Camera) | ||
stereo = p.create(dai.node.StereoDepth) | ||
rgbd = p.create(dai.node.RGBD).build() | ||
color.build() | ||
o3dViewer = O3DNode() | ||
left.build(dai.CameraBoardSocket.LEFT) | ||
right.build(dai.CameraBoardSocket.RIGHT) | ||
out = color.requestOutput((1280,720), dai.ImgFrame.Type.RGB888i) | ||
|
||
|
||
out.link(stereo.inputAlignTo) | ||
stereo.setDefaultProfilePreset(dai.node.StereoDepth.PresetMode.DEFAULT) | ||
stereo.setRectifyEdgeFillColor(0) | ||
stereo.enableDistortionCorrection(True) | ||
|
||
# Linking | ||
left.requestOutput((1280, 720)).link(stereo.left) | ||
right.requestOutput((1280, 720)).link(stereo.right) | ||
stereo.depth.link(rgbd.inDepth) | ||
out.link(rgbd.inColor) | ||
|
||
rgbd.pcl.link(o3dViewer.inputPCL) | ||
|
||
p.start() | ||
while p.isRunning(): | ||
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.