Orienting an Object in an image horizontally

asked 2020-01-16 18:07:46 -0500

Reshika gravatar image

I have images of Food Trays oriented in various angles. I would like to make all the trays horizontally oriented. For this I tried finding the longest edge of the tray using hough's transformation and calculated its orientation with respect to the image border and rotated it. It works fine for very few cases. I would like to make it work for all the images I have. Can anyone please help me with this? I have attached some sample images in the link below and also I have included the code which I am currently using. Link for images

edit retag flag offensive close merge delete