Face Detection with CVTools v0.2

maytsang's picture

I am new to Quartz Composer and creating a face detection system for my Uni work. I was wondering anyone could help me. I am trying to create a system where once the face is detected, either a green or red light turns on. This is going to be randomized. Currently I have set it up so that the green light is on when the face is detected, but I've had no luck with randomizing it so the red light occasionally turns on instead. Also is it possible to display an error message when no faces are tracked? I would greatly appreciate it if anyone can help me. Please find attached the .qtz file. Thanks in advance!

PreviewAttachmentSize
making things move.qtz242.84 KB

gtoledo3's picture
Re: Face Detection with CVTools v0.2

"... is it possible to display an error message when no faces are tracked? "

-There is a Structure Count object. When there is no face, it will output a value of 0. By using that to control a String Multiplexer, you can route messages to a Billboard that indicate the count. Here, I have written "ERROR!" in Source# 0, and simply left Source# 1 empty.

(You can actually connect the plain Structure Count output and anything over 1 will register on a boolean input port as "true/1", but since I used a range patch for the color part that caps stuff at 1, I'm just using the output from the Range.)

"but I've had no luck with randomizing it so the red light occasionally turns on instead."

-Here your composition gets to where I'm not sure exactly what you want to do, so I'm just going to take a stab at it.

This randomizes whether green/red when face is detected, with just one sphere in a lighting environment (there were a few, I'm guessing because you were trying to figure out where it made sense to place them in the composition).

I added notes to each part of the process, so hopefully that will clarify what is going on. Good luck!

PreviewAttachmentSize
making things move_annotated_gt.qtz245.22 KB

maytsang's picture
Re: Face Detection with CVTools v0.2

Many thanks for your help! Just wondering how can I turn the face tracking back on? Can I make it so that when a persons face is out of sight, the error message comes up automatically and disappears again once their face is tracked?

gtoledo3's picture
Re: Face Detection with CVTools v0.2

When you opened it, did you make sure that you opened it in a location where the haar.xml (the face tracker file) is also relative? Save both files on your desktop (or in the same folder), close file, reopen, run.

Right now the CVTools Haar patch is loading a Haar file that was in your CVTools examples. By the file you downloaded from my being in Downloads (I'm guessing), when you open the file, you would probably just see error, since there is no Haar file at a relative file path for the qtz to load. Alternatively, find the haar.xml file, and drag it into the file path of the Haar importer object, and restart the composition.

If you do that, it should work fine, and do exactly what you're asking.

maytsang's picture
Re: Face Detection with CVTools v0.2

Oh yeah, I forgot about that! Thanks so much! You're fantastic!

gtoledo3's picture
Re: Face Detection with CVTools v0.2

You're welcome. I hope you enjoy the boards. It would be cool to see how your project ends up.