Skip to content

Commit

Permalink
Merge branch 'v3_develop' into v3_rgbd_node
Browse files Browse the repository at this point in the history
  • Loading branch information
Serafadam committed Jan 29, 2025
2 parents be89d47 + e99a9b9 commit b9019e6
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bindings/python/external/pybind11_opencv_numpy
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceRVC4Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set(DEPTHAI_DEVICE_RVC4_MATURITY "snapshot")

# "version if applicable"
# set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+93f7b75a885aa32f44c5e9f53b74470c49d2b1af")
set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+c9ed16c24584e7463170375f849bd0c24f2596d2")
set(DEPTHAI_DEVICE_RVC4_VERSION "0.0.1+78ff040f04e86bc77b1618c87a931d645f7aa109")
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceSideConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")

# "full commit hash of device side binary"
set(DEPTHAI_DEVICE_SIDE_COMMIT "976351fda3b70483e37882f989686bf0aa8c604d")
set(DEPTHAI_DEVICE_SIDE_COMMIT "a9d354351694c5dd96def768c0b0155354cab38c")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
2 changes: 1 addition & 1 deletion examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ dai_add_example(camera_multiple_outputs Camera/camera_multiple_outputs.cpp OFF O
dai_add_example(image_manip_host HostNodes/image_manip_host.cpp OFF OFF)
dai_add_example(image_manip_color_conversion_host HostNodes/image_manip_color_conversion.cpp OFF OFF)
dai_add_example(image_manip_v2_resize ImageManip/image_manip_v2_resize.cpp OFF OFF)
dai_add_example(image_manip_v2_mod ImageManip/image_manip_v2_mod.cpp OFF OFF)
dai_add_example(image_manip_v2_multi_ops ImageManip/image_manip_v2_multi_ops.cpp OFF OFF)
dai_add_example(image_manip_color_conversion ImageManip/image_manip_color_conversion.cpp OFF OFF)

# Record
Expand Down
4 changes: 2 additions & 2 deletions examples/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ add_python_example(threaded_host_nodes HostNodes/threaded_host_nodes.py)
dai_set_example_test_labels(threaded_host_nodes ondevice rvc2_all rvc4 ci)

## ImageManip
add_python_example(image_manip_mod ImageManip/image_manip_v2_mod.py)
dai_set_example_test_labels(image_manip_mod ondevice rvc2_all rvc4 ci)
add_python_example(image_manip_v2_multi_ops ImageManip/image_manip_v2_multi_ops.py)
dai_set_example_test_labels(image_manip_v2_multi_ops ondevice rvc2_all rvc4 ci)

add_python_example(image_manip_resize ImageManip/image_manip_v2_resize.py)
dai_set_example_test_labels(image_manip_resize ondevice rvc2_all rvc4 ci)
Expand Down
62 changes: 62 additions & 0 deletions examples/python/ImageManip/image_manip_v2_all_ops.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import depthai as dai
import cv2

pipeline = dai.Pipeline()

manip_input = pipeline.create(dai.node.ImageManipV2)
manip_input.initialConfig.setFrameType(dai.ImgFrame.Type.BGR888p)
inputQueue = manip_input.inputImage.createInputQueue()

manip_ops = [
# Resize operations. If aspect ratio isn't the same, the image will be stretched/cropped/letterboxed (depending on resize mode)
# Docs here: https://docs.luxonis.com/software/depthai/resolution-techniques/
('resize_stretch', lambda conf: conf.setOutputSize(256, 200, dai.ImageManipConfigV2.ResizeMode.STRETCH)),
('resize_letterbox', lambda conf: conf.setOutputSize(256, 200, dai.ImageManipConfigV2.ResizeMode.LETTERBOX)),
('resize_center_crop', lambda conf: conf.setOutputSize(256, 200, dai.ImageManipConfigV2.ResizeMode.CENTER_CROP)),
# Crop the image topLeft (10,40) to bottomRight (310,110)
('crop', lambda conf: conf.addCrop(x=50, y=50, w=150, h=200)),
# Flip the frame vertically/horizontally
('flip_vertical', lambda conf: conf.addFlipVertical()),
('flip_horizontal', lambda conf: conf.addFlipHorizontal()),
# Scale the image by 0.7x in x and 0.5x in y
('scale', lambda conf: conf.addScale(0.7, 0.5)),
# Rotate. If center isn't specified, it will rotate around center (0.5, 0.5)
('rotate_90_deg', lambda conf: conf.addRotateDeg(90)),
('rotate_90_deg_center', lambda conf: conf.addRotateDeg(90, center=dai.Point2f(0.2, 0.3)).setOutputCenter(False)),
('transform_affine', lambda conf: conf.addTransformAffine( # Shearing
[1, 0.5,
0.2, 1])),
('transform_perspective', lambda conf: conf.addTransformPerspective(
[1.0, 0.2, 0.0, # First row
0.1, 1.0, 0.0, # Second row
0.001, 0.002, 1.0])), # Third row
('frame_type', lambda conf: conf.setFrameType(dai.ImgFrame.Type.RAW8)), # to Grayscale
]

# Dynamically create ImageManipV2 nodes, apply configurations, and set up queues
queues = {}
for name, config in manip_ops:
print(name, config)
manip = pipeline.create(dai.node.ImageManipV2)
config(manip.initialConfig)
manip_input.out.link(manip.inputImage)
queues[name] = manip.out.createOutputQueue(maxSize=4, blocking=False)


imgFrame = dai.ImgFrame()

input_frame = cv2.imread('../models/lenna.png') # 512x512
# Send 256x256 image to the device
imgFrame.setCvFrame(cv2.pyrDown(input_frame), dai.ImgFrame.Type.BGR888i)
inputQueue.send(imgFrame)

cv2.imshow('input_image', input_frame)


pipeline.start()

for name, queue in queues.items():
inFrame = queue.get()
cv2.imshow(name, inFrame.getCvFrame())

key = cv2.waitKey(0)
20 changes: 11 additions & 9 deletions examples/python/ImageManip/image_manip_v2_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
camRgb = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_A)
manip = pipeline.create(dai.node.ImageManipV2)


manip.initialConfig.setOutputSize(300, 300, dai.ImageManipConfigV2.ResizeMode.STRETCH)

camRgb.requestOutput((1920, 1080)).link(manip.inputImage)
camOut = camRgb.requestOutput((1920, 1080))
camOut.link(manip.inputImage)

out = manip.out.createOutputQueue()
manipQ = manip.out.createOutputQueue()
camQ = camOut.createOutputQueue()

pipeline.start()

while True:
inFrame = out.get()
if inFrame is not None:
cv2.imshow("Show frame", inFrame.getCvFrame())
key = cv2.waitKey(1)
if key == ord('q'):
break
if manipQ.has():
cv2.imshow("Manip frame", manipQ.get().getCvFrame())
if camQ.has():
cv2.imshow("Camera frame", camQ.get().getCvFrame())
key = cv2.waitKey(1)
if key == ord('q'):
break
8 changes: 6 additions & 2 deletions include/depthai/utility/ImageManipV2Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,12 @@ bool ColorChange<ImageManipBuffer, ImageManipData>::colorConvertToNV12(
done = true;
break;
}
case ImgFrame::Type::RAW8:
case ImgFrame::Type::GRAY8:
std::copy(src, src + inputSize, outputFrame.data());
memset(outputFrame.data() + dstSpecs.p2Offset, 128, dstSpecs.p2Stride * dstSpecs.height / 2);
done = true;
break;
case ImgFrame::Type::YUV422i:
case ImgFrame::Type::YUV444p:
case ImgFrame::Type::YUV422p:
Expand All @@ -1567,7 +1573,6 @@ bool ColorChange<ImageManipBuffer, ImageManipData>::colorConvertToNV12(
case ImgFrame::Type::RAW14:
case ImgFrame::Type::RAW12:
case ImgFrame::Type::RAW10:
case ImgFrame::Type::RAW8:
case ImgFrame::Type::PACK10:
case ImgFrame::Type::PACK12:
case ImgFrame::Type::YUV444i:
Expand All @@ -1578,7 +1583,6 @@ bool ColorChange<ImageManipBuffer, ImageManipData>::colorConvertToNV12(
case ImgFrame::Type::BGRF16F16F16p:
case ImgFrame::Type::RGBF16F16F16i:
case ImgFrame::Type::BGRF16F16F16i:
case ImgFrame::Type::GRAY8:
case ImgFrame::Type::GRAYF16:
case ImgFrame::Type::RAW32:
case ImgFrame::Type::NONE:
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ dai_set_test_labels(neural_network_node_test ondevice rvc2_all rvc4 ci)

# ImgTransformations tests
dai_add_test(img_transformation_test src/ondevice_tests/img_transformation_test.cpp CXX_STANDARD 17)
dai_set_test_labels(message_group_frame_test ondevice rvc4 ci)
dai_set_test_labels(img_transformation_test ondevice rvc2_all rvc4 ci)

# Regression tests for encountered bugs
dai_add_test(regression_camera_concurrency_test src/ondevice_tests/regression/camera_concurrency.cpp)
Expand Down

0 comments on commit b9019e6

Please sign in to comment.