error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
时间: 2023-09-29 11:04:11 浏览: 306
根据引用中提到的信息,"error: (-215:Assertion failed) !_img.empty() in function 'imwrite'"是由于在视频分帧保存为图片时出现的问题。这个错误通常发生在没有正确检查帧是否为空的情况下尝试写入图片时。解决这个问题的方法是在写入图片之前添加一个判断条件,确保帧不为空。具体来说,你可以在写入图片之前添加以下代码:
```
if not _img.empty():
cv2.imwrite('path_to_save_image.jpg', _img)
```
这样做可以避免出现"error: (-215:Assertion failed) !_img.empty() in function 'imwrite'"的错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [error: (-215:Assertion failed)的两种解决方案](https://blog.csdn.net/yin20020606/article/details/127235580)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [tensor_proto.raw_data().empty() || !tensor_proto.float_data().empty() || !tensor_proto.double_data()](https://download.csdn.net/download/weixin_38571878/14035634)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [解决python-opencv:(-215:Assertion failed) _img.empty() in function ‘cv::imwrite‘在将视频分成帧图片...](https://blog.csdn.net/qq_54731673/article/details/126891909)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文