Vehicle tracking based on customized template matching