Machine Learning based Video Processing for Real-time Near-Miss Detection