在Opencv中作为Canny输入数据的文件类型是什么?

问题描述

我有一个图像的h5文件。我将其设置为“ h5py.File”,其dtype为“ Array of float32”。
现在我想应用到一个模块,CV2中的边缘检测cv2.Canny()。 但是,出现以下错误

829:错误:(-215:声明失败)_src.depth()==函数'Canny'中的CV_8U

我猜数据dtype不匹配。在Canny的示例中,使用jpg文件进行读取。

我不知道Canny读取哪种数据类型。在示例中,他们使用cv.imread()读取jpg。然后应用Canny()。

我该怎么办?我不想从h5file压缩数据。因为我不想丢失任何数据。

我当前的代码如下,

import cv2
import numpy as np
import h5py
from scipy import ndimage

A = h5py.File('h5file.h5,' 'r')
A_ = A['dataset']
A__ = A_['real']+A_['imag']
A__abs = np.abs(A__)

B = ndimage.rotate(A__abs,45)
C = np.zeros((500,500))
C = cv2.normalize(B,C,1,cv2.norM_MINMAX) # C is the Array of float32

edges = cv2.Canny(C,0.5,0.6)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)