# Send an updated config with continuous rotate, or after a key press if key >= 0 or (not testFourPt and abs(rotateRate) > 0.0001): cfg = dai.ImageManipConfig() if testFourPt: test = warpList[warpIdx] points, normalized = test[0], test[1] point2fList = [] for p in points: pt = dai.Point2f() pt.x, pt.y = p[0], p[1] point2fList.append(pt) cfg.setWarpTransformFourPoints(point2fList, normalized) else: angleDeg += rotateRate rotatedRect = ((320, 240), (400, 400), angleDeg) rr = dai.RotatedRect() rr.center.x, rr.center.y = rotatedRect[0] rr.size.width, rr.size.height = rotatedRect[1] rr.angle = rotatedRect[2] cfg.setCropRotatedRect(rr, False) if resizeFactor > 0: cfg.setResize(resizeX, resizeY) # cfg.setWarpBorderFillColor(255, 0, 0) # cfg.setWarpBorderReplicatePixels() qManipCfg.send(cfg) for q in [qPreview, qManip]: pkt = q.get() name = q.getName() shape = (3, pkt.getHeight(), pkt.getWidth()) frame = pkt.getCvFrame()
#!/usr/bin/env python3 import cv2 import depthai as dai # Create pipeline pipeline = dai.Pipeline() # Rotate color frames camRgb = pipeline.create(dai.node.ColorCamera) camRgb.setPreviewSize(640, 400) camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P) camRgb.setInterleaved(False) manipRgb = pipeline.create(dai.node.ImageManip) rgbRr = dai.RotatedRect() rgbRr.center.x, rgbRr.center.y = camRgb.getPreviewWidth( ) // 2, camRgb.getPreviewHeight() // 2 rgbRr.size.width, rgbRr.size.height = camRgb.getPreviewHeight( ), camRgb.getPreviewWidth() rgbRr.angle = 90 manipRgb.initialConfig.setCropRotatedRect(rgbRr, False) camRgb.preview.link(manipRgb.inputImage) manipRgbOut = pipeline.create(dai.node.XLinkOut) manipRgbOut.setStreamName("manip_rgb") manipRgb.out.link(manipRgbOut.input) # Rotate mono frames monoLeft = pipeline.create(dai.node.MonoCamera) monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)