Event detection in complex environments: An effective and efficient machine-learning-based framework