问题描述
代码如下:
import cv2
from cv2 import dnn_superres
# Create an SR object
sr = dnn_superres.DnnSuperResImpl_create()
# Read image
image = cv2.imread('IMG.png') #it is in the same path of this code
# Read the desired model
path = "ESPCN_x3.pb" #downloaded from a github
sr.readModel('D:\Folder\Folder Python\ESPCN_x3.pb')
# Set the desired model and scale to get correct pre- and post-processing
sr.setModel("espcn",3)
# Upscale the image
result = sr.upsample(image)
# Save the image
cv2.imwrite("./upscaled.png",sr.upsample(image))
我得到的错误如下:
Traceback (most recent call last):
File "D:\Folder\Folder Python\superres.py",line 21,in <module>
cv2.imwrite("./upscaled.png",sr.upsample(image))
cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-5rb_9df3\opencv\modules\core\src\matrix_wrap.cpp:1243: error: (-215:Assertion Failed) !(m.empty() && fixedType() && fixedSize()) && "Can't reallocate empty Mat with locked layout (probably due to misused 'const' modifier)" in function 'cv::_OutputArray::create'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)