I am currently working on a project to detect whether vehicles are using the railway track of a level crossing. Right now, I'm doing this by demarcating the railway track as a MatOfPoint and identifying each vehicle as a Rect. My next step from here is to work out the area of overlap between the MatOfPoint (railway line) and the Rect (vehicles). Thus, if 50% of a Rect shares its area with the MatOfPoint, it's very likely that a vehicle is using the level crossing.
How can I find the area of this intersection? Does OpenCV have any functions which allow this?