Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

your img is most likely invalid.

some things to check:

  1. did the capture open ? is 1 the correct id ? (i doubt so, rather try 0). please check:

    cap.isOpened() #should return True

  2. did you get a valid frame from your capture ? please check if ret==True

    (older webcams might need some "warmup", and you might need to continue, until you receive a valid image)

your img is most likely invalid.

some things to check:

  1. did the capture open ? is 1 the correct id ? (i doubt so, rather try 0). please check:

    cap.isOpened() #should return True

  2. did you get a valid frame from your capture ? please check if ret==True

    (older webcams might need some "warmup", and you might need to continue, until you receive a valid image)

in general, please make it a habit , to always check, if resources got read/loaded, like from imread(), and also you need to check, if the cascade xml files get ead properly with cascade.empty()