How do I differentiate between these images using opencv and PCA?

How did you compute the gradients for the PCA?
The kernel for the gradients and the PCA analysis window should be at the scale of the object. If you use a sobel filter, it will give you the local orientations (which change at every bend). To get a global orientation, use a Laplacian filter or gaussian derivate and a larger analysis window.

Showing your code would help to understand what you are doing exactly.