我们如何将 Mat 从 opencv 传递到 tensorflow tf.image.ssim

我有一些带有 Opencv Python 的视频帧,并且能够将其转换为灰度。


现在我想做这样的事情来计算 ssim_multiscale


    i1 = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)

    i2 = cv2.cvtColor(frame2,cv2.COLOR_BGR2GRAY)

    i1 = np.array(i1, dtype=np.float64)

    i2 = np.array(i2,dtype=np.float64)

    print(tf.image.ssim_multiscale(i1,i2,255))

但我收到了这个错误


shape1 = img1.get_shape().with_rank_at_least(3)。AttributeError: 'numpy.ndarray' 对象没有属性 'get_shape'


我检查了 np.array 的文档,它有 get_shape 属性。我应该如何将 Mat 传递给 ssim_multiscale 参数?


tf.image.ssim_multiscale(

    img1,

    img2,

    max_val,

    power_factors=_MSSSIM_WEIGHTS

)


米脂
浏览 157回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python