# Revision history [back]

you have to avoid single backslashes in ALL kind of filenames, this is not even an opencv specific problem. so load your cascade like this:

 face_cascade.load("C:/OpenCV/sources/data/haarcascades/haarcascade_frontalface_alt2.xml");


next, please do not blindly copy & paste random code lines, e.g. this:

 cap.retrieve(img, CV_CAP_OPENNI_BGR_IMAGE);


will have to be removed (no idea, what you're doing, eh ?)

and really, look at the docs , not at youtube videos ...

you have to avoid single backslashes in ALL kind of filenames, this is not even an opencv specific problem. so load your cascade like this:

 face_cascade.load("C:/OpenCV/sources/data/haarcascades/haarcascade_frontalface_alt2.xml");


or like this:

 face_cascade.load("C:\\OpenCV\\sources\\data\\haarcascades\\haarcascade_frontalface_alt2.xml");


next, please do not blindly copy & paste random code lines, e.g. this:

 cap.retrieve(img, CV_CAP_OPENNI_BGR_IMAGE);


will have to be removed (no idea, what you're doing, eh ?)

and really, look at the docs , not at youtube videos ...

you have to avoid single backslashes in ALL kind of filenames, this is not even an opencv specific problem. so load your cascade like this:

 face_cascade.load("C:/OpenCV/sources/data/haarcascades/haarcascade_frontalface_alt2.xml");


or like this:

 face_cascade.load("C:\\OpenCV\\sources\\data\\haarcascades\\haarcascade_frontalface_alt2.xml");


next, please do not blindly copy & paste random code lines, e.g. this:

 cap.retrieve(img, CV_CAP_OPENNI_BGR_IMAGE);


will have to be removed (no idea, what you're doing, eh ?)removed.

and really, look at the docs , not at youtube videos ...