An Adaptive Vehicle Detection Algorithm Based on Magnetic Sensors in Intelligent Transportation Systems