cv2.imshow()无法正确显示图像

时间:2020-04-22 00:10:50

标签: python image opencv

我试图检查实际上是通过cv2.imread()读取了哪些数据,但是每当执行此操作时,我都会得到全灰屏。我应该得到一张彩虹图像。

def detect_pixels():
    txt_parts = {}
    path = r'C:\Users\Singh\Documents\jpgtotxt\rainbow.jpg'
    BRG = cv2.imread(path)
    cv2.imshow('BRG', BRG)
    time.sleep(3)

3 个答案:

答案 0 :(得分:0)

std::chrono之后添加cv2.waitKey(0)

答案 1 :(得分:0)

cv2.imshow()替换为time.sleep(3)

答案 2 :(得分:0)

def detect_pixels():
    txt_parts = {}
    path = r'C:\Users\Singh\Documents\jpgtotxt\rainbow.jpg'
    BRG = cv2.imread(path)
    cv2.imshow('BRG', BRG)
    cv2.waitKey(0)
    cv2.destroyAllWindows()