-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
  • 1

3 Answers3

1

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

duckboycool
  • 1,901
  • 2
  • 8
  • 17
0

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

Nicolas Gervais
  • 28,901
  • 11
  • 96
  • 121
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
  • 309
  • 1
  • 6
  • 13
  • 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