Last active
August 2, 2021 22:24
-
-
Save Erol444/73383c07df936608bb7041790522dc16 to your computer and use it in GitHub Desktop.
DepthAI ImageManip rotate frames
This file contains hidden or 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
import cv2 | |
import depthai as dai | |
# Create pipeline | |
pipeline = dai.Pipeline() | |
# Define sources and outputs | |
monoLeft = pipeline.createMonoCamera() | |
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P) | |
monoLeft.setBoardSocket(dai.CameraBoardSocket.LEFT) | |
manipLeft = pipeline.createImageManip() | |
rr = dai.RotatedRect() | |
rr.center.x, rr.center.y = monoLeft.getResolutionWidth() // 2, monoLeft.getResolutionHeight() // 2 | |
rr.size.width, rr.size.height = monoLeft.getResolutionHeight(), monoLeft.getResolutionWidth() | |
rr.angle = 90 | |
manipLeft.initialConfig.setCropRotatedRect(rr, False) | |
monoLeft.out.link(manipLeft.inputImage) | |
manipLeftOut = pipeline.createXLinkOut() | |
manipLeftOut.setStreamName("manip_left") | |
manipLeft.out.link(manipLeftOut.input) | |
with dai.Device(pipeline) as device: | |
qManip = device.getOutputQueue(name="manip_left", maxSize=8, blocking=False) | |
while True: | |
in_manip = qManip.get() | |
# print(f'Width {in_manip.getWidth()}, Height {in_manip.getHeight()}') | |
cv2.imshow('Left rotated', in_manip.getCvFrame()) | |
if cv2.waitKey(1) == ord('q'): | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment