Find intersection point

Hi everyone!

I created lines using the Imgproc.line and this lines connects four differents colors. For do that, I used two differents forEach (like in the print). I created a method (lineIntersection) to find the intersections points between this lines, but how I used two differents forEach, I’m having some difficult to use the values of this points in my method. Anyone have an ideia of how can I do that?

please, NO IMAGES OF CODE here, thank you