Using array instead of Mat to reduce matching time