This is a Processing piece of code that I used to detect tirangle location and direction from a webcam stream.
the code