[英]Python OpenCV Error: (-215:Assertion failed) _step >= minstep in function 'cv::Mat::Mat'
I'm trying to get python-opencv running, but I always get this error:我试图让 python-opencv 运行,但我总是收到这个错误:
image = cv.cvtColor(image, cv.COLOR_RGB2BGR)
cv2.error: OpenCV(4.5.4-dev) D:\a\opencv-python\opencv-python\opencv\modules\core\src\matrix.cpp:466: error: (-215:Assertion failed) _step >= minstep in function 'cv::Mat::Mat'
This path part is really strange "D:\\a\\opencv-" I never even had a D: drive.这个路径部分真的很奇怪 "D:\\a\\opencv-" 我什至从未有过 D: 驱动器。
This is my code (Windows 10, python 3.8, pycharm, pipenv)这是我的代码(Windows 10、python 3.8、pycharm、pipenv)
import cv2 as cv
import numpy as np
import pyautogui as pg
def make_screenshot(x=0, y=0, x_length=1920, y_length=1080, debug=False):
image = pg.screenshot(region=(x, y, x_length, y_length))
image = np.array(image)
image = cv.cvtColor(image, cv.COLOR_RGB2BGR)
if debug:
cv.imshow('test', image)
cv.waitKey()
return image
print(make_screenshot(0, 0, 1, 1, False))
Checked already without success:已经检查没有成功:
error: (-215:Assertion failed) _step >= minstep in function 'cv::Mat::Mat' 错误:(-215:断言失败)_step >= minstep in function 'cv::Mat::Mat'
error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize' OpenCV 错误: (-215:Assertion failed) !ssize.empty() in function 'cv::resize' OpenCV
cv2.error:(-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' 函数 'cv::cvtColor' 中的 cv2.error:(-215:Assertion failed) !_src.empty()
Do you need to convert it to an array?您需要将其转换为数组吗?
Maybe use the .imread() function as well.也许也使用 .imread() 函数。
image = cv2.imread(image)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.