網站首頁 編程語言 正文
imgwarp.cpp:3143: error: (-215:Assertion failed) _src.total() > 0 in function ‘warpPerspective‘
作者:修煉之路 更新時間: 2022-02-13 編程語言錯誤緣由
在使用opencv做透視變換的時候報error: (-215:Assertion failed) _src.total() > 0 in function 'warpPerspective'
,錯誤的詳細信息如下
cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-dglzv4yn/opencv/modules/imgproc/src/imgwarp.cpp:3143: error: (-215:Assertion failed) _src.total() > 0 in function ‘warpPerspective’
透視變化的代碼如下:
def clip_image(img,points):
if isinstance(points,list):
points = np.array(points,dtype=np.float32)
img_crop_width = max(np.linalg.norm(points[0] - points[1]),
np.linalg.norm(points[2] - points[3]))
img_crop_height = max(np.linalg.norm(points[1] - points[2]),
np.linalg.norm(points[0] - points[3]))
pts_std = np.float32([[0,0],[img_crop_width,0],[img_crop_width,img_crop_height],[0,img_crop_height]])
M = cv2.getPerspectiveTransform(points,pts_std)
dst_img = cv2.warpPerspective(img, M, (img_crop_width, img_crop_height), borderMode=cv2.BORDER_REPLICATE,
flags=cv2.INTER_CUBIC)
dst_img_height, dst_img_width = dst_img.shape[0:2]
if dst_img_height * 1.0 / dst_img_width >= 1.5:
dst_img = np.rot90(dst_img)
return dst_img
錯誤原因分析
出現這種錯誤的原因可能有三種:
- 檢查
img
是否為None - 檢查
points
坐標中是否出現負數 - 檢查
points
和pts_std
點的順序是否一致
原文鏈接:https://xiulian.blog.csdn.net/article/details/121666964
相關推薦
- 2022-07-19 簡單認清深拷貝和淺拷貝
- 2023-03-26 WPF使用觸發器需要注意優先級問題解決_C#教程
- 2022-10-21 PID原理與python的簡單實現和調參_python
- 2023-01-31 C#實現文件分割和合并的示例詳解_C#教程
- 2022-12-21 詳解Golang中Channel的原理和使用技巧_Golang
- 2022-09-30 LeetCode189輪轉數組python示例_python
- 2022-08-02 源碼解析python中randint函數的效率缺陷_python
- 2022-07-03 解決編碼問題:UnicodeDecodeError:?'utf-8'?codec?can't?dec
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支