[英]Opencv super resolution error: cv2.error: OpenCV(4.7.0) /io/opencv/modules/dnn/src/net_impl.cpp:1188
I would like to upscale Sentinel2 swir images from 20m to 10m to use it with r, g, b and nir bands.我想将 Sentinel2 旋涡图像从 20m 升级到 10m,以将其与 r、g、b 和 nir 波段一起使用。 To do this, I'm trying opencv super resolution module with this python code:
为此,我正在使用 python 代码尝试 opencv 超分辨率模块:
import cv2
img = cv2.imread("img.jp2")
sr = cv2.dnn_superres.DnnSuperResImpl_create()
sr.readModel("EDSR_x2.pb")
sr.setModel("edsr", 2)
result = sr.upsample(img)
cv2.imwrite("result.jp2", result)
With opencv and opencv-contrib 4.7.0.68, this EDSR_x2.pb file and this image使用 opencv 和 opencv-contrib 4.7.0.68,这个EDSR_x2.pb文件和这个图像
Unfortunately, this line generate an error: result = sr.upsample(img)
不幸的是,这一行产生了一个错误:
result = sr.upsample(img)
Error:错误:
cv2.error: OpenCV(4.7.0) /io/opencv/modules/dnn/src/net_impl.cpp:1188: error: (-2:Unspecified error) in function 'void cv::dnn::dnn4_v20221220::Net::Impl::getLayerShapesRecursively(int, cv::dnn::dnn4_v20221220::Net::Impl::LayersShapesMap&)'
> (expected: 'total(os[i]) > 0'), where
> 'total(os[i])' is -874068992
> must be greater than
> '0' is 0
I tried to downgrade opencv and opencv-contrib to 4.6.0.66 and 4.5.5.64, same result.我尝试将 opencv 和 opencv-contrib 降级到 4.6.0.66 和 4.5.5.64,结果相同。
Does anyone know why it doesn't work or has the same issue?有谁知道为什么它不起作用或有同样的问题?
You can try to start with a minimal working example:您可以尝试从一个最小的工作示例开始:
import cv2
img = cv2.imread("img.png")
sr = cv2.dnn_superres.DnnSuperResImpl_create()
sr.readModel("models/EDSR_x2.pb")
sr.setModel("edsr", 2)
result = sr.upsample(img)
cv2.imwrite("out.png", result)
EDSR-file: https://github.com/Saafke/EDSR_Tensorflow/tree/master/models EDSR 文件: https://github.com/Saafke/EDSR_Tensorflow/tree/master/models
OpenCV: opencv-contrib-python-4.7.0.68 OpenCV:opencv-contrib-python-4.7.0.68
Input:输入:
Output: Output:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.