【问题标题】:Why is ndarray displayed as a black image?为什么ndarray显示为黑色图像?
【发布时间】:2015-05-13 06:19:00
【问题描述】:

我尝试将 ndarray 转换为图像:

import numpy as np
import cv2

def main():
    #...
    data_array = []
    data_array.append((255, 255, 255))
    data_array.append((255, 255, 255))
    # http://pastebin.com/iUs6ebBU

    new_image = np.array(data_array).reshape((height, width, 3))

    r,g,b = cv2.split(new_image)
    img_bgr = cv2.merge([b,g,r])

    cv2.imshow('image',img_bgr)
    cv2.waitKey(0)

但我只看到黑色图像,而不是我的。有什么问题?

【问题讨论】:

    标签: python image python-2.7 opencv numpy


    【解决方案1】:

    我找到了解决办法:np.uint32 data type is not supported by OpenCV.

    我将int32 转换为uint8,现在它可以工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-09
      • 2012-07-26
      • 1970-01-01
      • 2015-10-15
      • 1970-01-01
      • 1970-01-01
      • 2013-11-25
      相关资源
      最近更新 更多