简体   繁体   English

Opencv 超分辨率错误:cv2.error: OpenCV(4.7.0) /io/opencv/modules/dnn/src.net_impl.cpp:1188

[英]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.

相关问题 cv2.error: OpenCV(4.5.3) C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pip-req-build-ep71p_ws\\opencv\\modules\\imgproc\\src\\color.cpp:182 - cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-ep71p_ws\opencv\modules\imgproc\src\color.cpp:182 cv2.error: OpenCV(4.5.2) C:\\Users\\ ... \\modules\\imgproc\\src\\resize.cpp:3929: error: (-215:Assertion failed) func != 0 in function 'cv::hal: :调整大小' - cv2.error: OpenCV(4.5.2) C:\Users\ … \modules\imgproc\src\resize.cpp:3929: error: (-215:Assertion failed) func != 0 in function 'cv::hal::resize' cv2.error: OpenCV(4.7.0):-1: 错误: (-5:Bad argument) in function 'imwrite' img data type = 17 is not supported - cv2.error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function 'imwrite' img data type = 17 is not supported cv2.error: OpenCV(4.5.5) D:\a\opencv-python\imgproc\src\color.cpp:182: 错误: (-215:Assertion failed) !_src.empty() in function 'cv:: cvt颜色' - cv2.error: OpenCV(4.5.5) D:\a\opencv-python\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' OpenCV 代码中的错误:cv2.error: OpenCV(4.5.1) - Error in OpenCV code: cv2.error: OpenCV(4.5.1) Laplacian opencv 因 cv2.error 失败:OpenCV(4.1.2) - Laplacian opencv fails with cv2.error: OpenCV(4.1.2) cv2.error: OpenCV(4.5.2).error: (-215:Assertion failed)._src:empty() in function 'cv::cvtColor' - cv2.error: OpenCV(4.5.2) .error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' cv2.error: OpenCV(4.5.2) resize.cpp:4051: error: (-215:Assertion failed).ssize:empty() in function 'cv::resize' - cv2.error: OpenCV(4.5.2) resize.cpp:4051: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize' cv2.error: OpenCV(4.5.2) 👎 错误: (-5:Bad argument) in function 'cvtColor' - cv2.error: OpenCV(4.5.2) 👎 error: (-5:Bad argument) in function 'cvtColor' cv2.error: OpenCV(4.5.4):-1: error: (-5:Bad argument) in function 'warpPerspective' - cv2.error: OpenCV(4.5.4) :-1: error: (-5:Bad argument) in function 'warpPerspective'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM