requestOutput(..., enableUndistortion=True)(或 requestFullResolutionOutput)为每个输出启用。相机输出请求还接受一个可选的 alphaScaling 值,当您想要控制裁剪和保留完整视场之间的平衡时。注意事项:- 去畸变不会改变存储的相机内参。
- 可选的
alphaScaling控制裁剪与 FOV 的权衡。较低的值会更积极地裁剪,而较高的值会保留更多原始视场。 - 去畸变会改变有效 FOV;根据您请求的输出尺寸、调整大小模式和
alphaScaling值,去畸变后您可能会看到更多或更少的原始图像。 - 在 RVC2 上,
alphaScaling仅在 FOV 超过 90 度时有效,而在 RVC4 上,它适用于任何 FOV。
演示
流水线
源代码
Python
PythonGitHub
1#!/usr/bin/env python3
2
3import cv2
4import depthai as dai
5
6# Create pipeline
7with dai.Pipeline() as pipeline:
8 # Define source and output
9 cam = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
10 croppedQueue = cam.requestOutput((300,300), resizeMode=dai.ImgResizeMode.CROP, enableUndistortion=True).createOutputQueue()
11 stretchedQueue = cam.requestOutput((300,300), resizeMode=dai.ImgResizeMode.STRETCH, enableUndistortion=True).createOutputQueue()
12 letterBoxedQueue = cam.requestOutput((300,300), resizeMode=dai.ImgResizeMode.LETTERBOX, enableUndistortion=True).createOutputQueue()
13
14 # Connect to device and start pipeline
15 pipeline.start()
16 while pipeline.isRunning():
17 croppedIn = croppedQueue.get()
18 assert isinstance(croppedIn, dai.ImgFrame)
19 cv2.imshow("cropped undistorted", croppedIn.getCvFrame())
20
21 stretchedIn = stretchedQueue.get()
22 assert isinstance(stretchedIn, dai.ImgFrame)
23 cv2.imshow("stretched undistorted", stretchedIn.getCvFrame())
24
25 letterBoxedIn = letterBoxedQueue.get()
26 assert isinstance(letterBoxedIn, dai.ImgFrame)
27 cv2.imshow("letterboxed undistorted", letterBoxedIn.getCvFrame())
28
29 if cv2.waitKey(1) == ord("q"):
30 break需要帮助?
请访问讨论论坛以获取技术支持或您可能有的任何其他问题。