Automated people counting using template matching and head search