TypeError: descriptor 'open' for 'cv2.VideoCapture' objects doesn't apply to a 'str' object
时间: 2023-12-23 17:05:07 浏览: 244
这个错误是因为在使用cv2.VideoCapture函数时,传入的参数类型不正确。根据引用\[1\]和引用\[2\]的信息,可以看出,当视频文件路径包含中文字符时,会导致这个错误。解决方法是将路径转换为utf-8编码,即使用`cv2.VideoCapture(absolute_path.encode('utf-8'))`来代替`cv2.VideoCapture(absolute_path)`。这样可以确保路径的正确性。另外,根据引用\[3\]的信息,还有可能是缺少处理视频文件所需的dll文件,可以尝试将opencv文件夹中的`opencv_ffmpeg.dll`文件复制到Python文件夹目录中。这样应该能够解决这个错误。
#### 引用[.reference_title]
- *1* *2* [opencv-python中,cv2.VideoCapture(path)报错TypeError: an integer is required](https://blog.csdn.net/weixin_43249191/article/details/82805881)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [cv2.videocapture()失败,无法读取视频的解决办法](https://blog.csdn.net/weixin_43522974/article/details/90105555)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文