網站首頁 編程語言 正文
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
相關推薦
- 2023-01-12 使用scipy.optimize的fsolve,root函數求解非線性方程問題_python
- 2023-01-03 Kotlin中Lambda表達式與高階函數使用分析講解_Android
- 2022-10-13 react-router?v6實現動態路由實例_React
- 2022-10-18 Qt實現計算器功能_C 語言
- 2022-04-23 uni-app項目之商品列表的下拉刷新與上拉加載更多
- 2021-12-02 利用Matlab仿真實現圖像煙霧識別(k-means聚類圖像分割+LBP+PCA+SVM)_C 語言
- 2022-12-07 C++?Boost?Bimap示例詳細講解_C 語言
- 2022-09-15 Python利用shutil實現拷貝文件功能_python
- 最近更新
-
- 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同步修改后的遠程分支