# i am doing a project to predict age and gender using tensorflow and opencv. and how to add path for xml file.

after running the code, webcam of PC will on but not capture any image. code is https://github.com/ashubansal005/Gend...

edit retag close merge delete

You don't even test that videcapture. read() succeeds... that's what ret is for. Likely your videocaoture is not even opened, but your code diesn't fail in that case, it just waits for a miracle.

( 2020-07-03 01:09:50 -0500 )edit

( 2020-07-03 01:22:44 -0500 )edit

If your xml in currently directory. But you have this on your folder *GenderReco_AgeEsti\pretrained_models*. But you don't have Drive E:. You actually have on Drive C: You should change this:

CASE_PATH = "\\E:\\GenderReco_AgeEsti\\pretrained_models\\haarcascade_frontalface_alt.xml"
WRN_WEIGHTS_PATH = "\\E:\\GenderReco_AgeEsti\\pretrained_models\\pretrained_models\\weights.18-4.06.hdf5"


To:

CASE_PATH = "haarcascade_frontalface_alt.xml"
WRN_WEIGHTS_PATH = "weights.18-4.06.hdf5"

( 2020-07-03 07:57:32 -0500 )edit

i have tried but have the same error

( 2020-07-03 08:42:55 -0500 )edit

Are you certainly on Drive C: instead of Drive E:? Is xml is in currently folder?

( 2020-07-03 08:46:00 -0500 )edit

Sort by » oldest newest most voted

please remove \\ at the start here

error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale.

more

i removed // but it shows this error- class 'cv2.CascadeClassifier'> returned a result with an error set

( 2020-07-03 08:41:34 -0500 )edit

Berak - as always - gave the solution. Your absolute path starts with \\ Pleas post the path you are using now. They way i usually do it in windows is to copy the path from the file explorer and then escape the \ character (\ becomes \\). Just make sure the initial path is valid.

If you still struggle , try to read in the file from a program and print its content to make very sure the path is valid. If you see the file content - its something else but the path.

( 2020-07-04 09:46:45 -0500 )edit

I dont want to be blasphemic - But if you are using tensorflow - why are you working with cascades for face detection ? They are inferior to a face detection model in terms of accuracy.

more

Official site

GitHub

Wiki

Documentation

## Stats

Seen: 214 times

Last updated: Jul 03