最近我安装了 OpenCV 和 OpenPose 来跟踪在 Windows 10 上的 Blender 2.81 中创建、装配和动画的 3d 角色的头部。当我使用 OpenCV 时,我使用这个插件:
https://github.com/jkirsons/FacialMotionCapture
当我使用 Open Pose 时,我已经安装了这个插件:
https://gitlab.com/sat-metalab/blender-addon-openpose
有什么问题 ?问题是为 OpenCV 编写的插件运行良好,但为 Openpose 编写的插件却不行。我没有 python 经验,但我查看了插件代码以试图了解原因。
请检查下面 OpenCV / 面部动作捕捉插件中的相关 python 代码:
# Show camera image in a window
cv2.imshow("Output", image)
# Show camera image in a window
cv2.imshow("Output", image)
cv2.waitKey(1)
return {'PASS_THROUGH'}
def init_camera(self):
if self._cap == None:
self._cap = cv2.VideoCapture(0)
self._cap.set(cv2.CAP_PROP_FRAME_WIDTH, self.width)
self._cap.set(cv2.CAP_PROP_FRAME_HEIGHT, self.height)
self._cap.set(cv2.CAP_PROP_BUFFERSIZE, 1)
time.sleep(1.0)
现在检查下面 OpenPose 插件中的相关 python 代码:
class Camera:
"""
Utility class embedding a camera, its parameters and buffers
"""
def __init__(self,
path: str) -> None:
self._path = path
self._camera = cv2.VideoCapture()
self._camera.open(path)
self._shape: Tuple[int, int, int] = (0, 0, 0)
self._bbox = [180, 120, 270, 270]
self._bbox_new = self._bbox
class OpenPoseWrapper:
def __init__(self) -> None:
self._cameras: List[Camera] = []
self._image_buffer: Optional[bpy.types.Image] = None
self._camera_paths: List[str] = ['/dev/video0', '/dev/video1']
self._is_stereo = False
self._is_stereo_calibrated = False
我想知道的是为什么 OpenCV 能够抓取我使用的视频文件,而不是 OpenPose 插件无法做到这一点。我怀疑 OpenPose 插件的代码是为 Linux 编写的,但我使用的是 Windows 10。出于这个原因,我应该更改这一行:
self._camera_paths: List[str] = ['/dev/video0', '/dev/video1']
事实上,在 Windows 10 中没有这样的设备。那么,如果我希望 Windows 10 能够检测为 OpenCV 编写的代码能够检测到的视频文件,我应该如何更改代码?