0

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?

Zetland
  • 569
  • 2
  • 11
  • 25
  • draw each shape filled white on its own single channel black image. then use Mat AND operator to get an image with the overlapping area. – Micka Apr 04 '15 at 10:25
  • @Micka Okay, but how do I then find the area of the overlapping area? – Zetland Apr 04 '15 at 11:26
  • use findContours and use cv::contourArea or just count nonblack pixels in the overlap image. – Micka Apr 04 '15 at 11:48
  • if you only use cv::Rect instead of arbitrary shapes it is very simple btw: cv:: Rect overlap = rect1 && rect2; float area = overlap.width*overlap.height; (in c++) – Micka Apr 04 '15 at 11:50
  • Why do you use MatOfPoints? It is [not even anymore documented](http://docs.opencv.org/search.html?q=matofpoint)... – Antonio Apr 07 '15 at 22:15

0 Answers0