-1

I was trying to check on what data was actually being read in via cv2.imread() but whenever I do so I get a full grey screen. I should be getting a rainbow image instead.

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)
abhinav6
  • 1
  • 2

3 Answers3

2

Replace time.sleep(3) with cv2.waitKey(3000).

duckboycool
  • 2,425
  • 2
  • 8
  • 23
1

add cv2.waitKey(0) after cv2.imshow()

Nicolas Gervais
  • 33,817
  • 13
  • 115
  • 143
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()

Alan Jones
  • 452
  • 1
  • 8
  • 19
  • Although this code might solve the problem, a good answer should also explain **what** the code does and **how** it helps. – BDL Apr 22 '20 at 11:22