C# Determine when the line has been crossed

hello everyone
At the moment I am using Opencv and Absdiff to determine when the line has been crossed. The line can be any color or even laser red. Is my idea good or am I on the wrong way.
The screenshot is only for viewing the camera direction.

Many Thanks for suggestions.

would you know, what a state machine is ?

sorry no can you explain it to me in short