How can I tell the angle from a horizontal line?

I have a solar cell, and there are white lines on it, which say which direction their facing (I know that is not quite accurate, but for the sake of this question let’s just say that). How would I be able to tell if the lines are facing west-east or north-south? And how would I calculate what angle they have from going for example west-to-east?

Maybe some example images would help, but I imagine you have a camera installed above the panel.
You can detect the lines with the HoughLines function (tutorial), which give you directly the angle (theta) of the detected lines (note: 0° is horizontal). The average of the angles will give you the orientation of the panel.

once you found the line, the angle is just a maths problem:

0 ----------- B

 dx = Ax - Bx
 dy = Ay - By 
 angle = atan2(dy,dx)

post a picture of your situation please.

I’ll assume you mean what I think you mean.

use a 2D fourier transform and look for peaks in the spectrum. the location of the peak indicates the angle of the pattern/lines. that method works for orienting/rotating scanned pages of text as well.

look here: Fred's ImageMagick Scripts: TEXTDESKEW

(Don’t worry, it’s more zoomed in on the sample pictures)

Yeah, I think I would just have to implement that script to the program. I assume you can get the angle of the picture.

Unfortunately, this isn’t enough for the project’s completion.

why not?

that’ll give you an estimate of in-plane rotation.

if you need something else, you haven’t said that.

The lines in your image are very clean. You should be able to get good results with Sobel, followed by phase(…)

Operations on Arrays — OpenCV documentation

Similar question here:
opencv - Sobel operator for gradient angle - Stack Overflow

Hough may work (mentioned above), but I’ve had good results with the Sobel/phase method.