I want to detect whether object is perpendicular to optical axis.

Sample input will be an image that has and object (cylinder shape similar to a bottle) in it and a mostly plain background.
Output will be a boolean determining whether that object is perpendicular to camera axis. This does not require to have much accuracy.
For example following image is not perpendicular to camera axis

Following image is not perpendicular too because camera angle is little bit from above

Next image is perpendicular and in the correct position

Is there any algorithm in OpenCV to do this?