Why is dlib's load_rgb_image() method rotating some of my images?Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnailWhy the output image will be rotated?What is the difference between Python's list methods append and extend?Python join: why is it string.join(list) instead of list.join(string)?Lazy load of images in ListViewUnderstanding Python super() with __init__() methodsStatic methods in Python?How do I auto-resize an image to fit a 'div' container?Does Python have a string 'contains' substring method?How to vertically align an image inside a divWhy is reading lines from stdin much slower in C++ than Python?Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition

What is this sticking out of my wall?

Number of aircraft to operate in an airline company

How to create a list of dictionaries from a dictionary with lists of different lengths

Are programming languages necessary/useful for operations research practitioner?

What happens to gadgets of players that leave a match

2.5 year old daughter refuses to take medicine

How accurate is the new appraisal system?

Leaving wiggling room for your characters while avoiding contradictions

Which ping implementation is cygwin using?

How do I restrict an interpolated function to only take values > 0?

On the origin of "casa"

Online Education for OR and Developing Decision Support Systems

Is English tonal for some words, like "permit"?

Two different colors in an Illustrator stroke / line

What does the phrase "pinch apart" mean here?

How would two worlds first establish an exchange rate between their currencies

Is there a star over my head?

Why is the the worst case for this function O(n^2)

What causes this bloom with an old telephoto lens?

How does Vivi differ from other Black Mages?

Have there been any countries that voted themselves out of existence?

Why would "an mule" be used instead of "a mule"?

Do any aircraft carry boats?

Is there any detail about ambulances in Star Wars?



Why is dlib's load_rgb_image() method rotating some of my images?


Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnailWhy the output image will be rotated?What is the difference between Python's list methods append and extend?Python join: why is it string.join(list) instead of list.join(string)?Lazy load of images in ListViewUnderstanding Python super() with __init__() methodsStatic methods in Python?How do I auto-resize an image to fit a 'div' container?Does Python have a string 'contains' substring method?How to vertically align an image inside a divWhy is reading lines from stdin much slower in C++ than Python?Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm working on image processing with some images I collected myself. Dlib's dlib.load_rgb_image('image_path') method swaps the rows and columns on some images while OpenCV's cv2.imread('image_path') method does not.



I don't want to go in and rotate some of these offending images myself manually because I'm creating an app.



Check out the results below



img = dlib.load_rgb_image("myimg.jpg")
print(img.shape)

--------------------
OUTPUT: (1944, 2592, 3)
(the resultant image is rotated 90 degrees clockwise)


while OpenCV's method returns the correct shape:



img = cv2.imread("myimg.jpg")
print(img.shape)

--------------------
OUTPUT: (2592, 1944, 3)


Does anyone have any idea why this is happening?



I am also attaching the image details of one of the offending photos:



image.png










share|improve this question


























  • it is on the dlib document that dlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height

    – Ha Bom
    Mar 28 at 8:26











  • Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.

    – Rafay Khan
    Mar 28 at 8:38






  • 1





    I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github

    – Ha Bom
    Mar 28 at 8:43






  • 1





    Some images have Orientation set in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check with exiftool or ImageMagick.

    – Mark Setchell
    Mar 28 at 8:52







  • 1





    stackoverflow.com/a/48146220/2836621

    – Mark Setchell
    Mar 28 at 8:59

















0















I'm working on image processing with some images I collected myself. Dlib's dlib.load_rgb_image('image_path') method swaps the rows and columns on some images while OpenCV's cv2.imread('image_path') method does not.



I don't want to go in and rotate some of these offending images myself manually because I'm creating an app.



Check out the results below



img = dlib.load_rgb_image("myimg.jpg")
print(img.shape)

--------------------
OUTPUT: (1944, 2592, 3)
(the resultant image is rotated 90 degrees clockwise)


while OpenCV's method returns the correct shape:



img = cv2.imread("myimg.jpg")
print(img.shape)

--------------------
OUTPUT: (2592, 1944, 3)


Does anyone have any idea why this is happening?



I am also attaching the image details of one of the offending photos:



image.png










share|improve this question


























  • it is on the dlib document that dlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height

    – Ha Bom
    Mar 28 at 8:26











  • Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.

    – Rafay Khan
    Mar 28 at 8:38






  • 1





    I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github

    – Ha Bom
    Mar 28 at 8:43






  • 1





    Some images have Orientation set in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check with exiftool or ImageMagick.

    – Mark Setchell
    Mar 28 at 8:52







  • 1





    stackoverflow.com/a/48146220/2836621

    – Mark Setchell
    Mar 28 at 8:59













0












0








0


0






I'm working on image processing with some images I collected myself. Dlib's dlib.load_rgb_image('image_path') method swaps the rows and columns on some images while OpenCV's cv2.imread('image_path') method does not.



I don't want to go in and rotate some of these offending images myself manually because I'm creating an app.



Check out the results below



img = dlib.load_rgb_image("myimg.jpg")
print(img.shape)

--------------------
OUTPUT: (1944, 2592, 3)
(the resultant image is rotated 90 degrees clockwise)


while OpenCV's method returns the correct shape:



img = cv2.imread("myimg.jpg")
print(img.shape)

--------------------
OUTPUT: (2592, 1944, 3)


Does anyone have any idea why this is happening?



I am also attaching the image details of one of the offending photos:



image.png










share|improve this question
















I'm working on image processing with some images I collected myself. Dlib's dlib.load_rgb_image('image_path') method swaps the rows and columns on some images while OpenCV's cv2.imread('image_path') method does not.



I don't want to go in and rotate some of these offending images myself manually because I'm creating an app.



Check out the results below



img = dlib.load_rgb_image("myimg.jpg")
print(img.shape)

--------------------
OUTPUT: (1944, 2592, 3)
(the resultant image is rotated 90 degrees clockwise)


while OpenCV's method returns the correct shape:



img = cv2.imread("myimg.jpg")
print(img.shape)

--------------------
OUTPUT: (2592, 1944, 3)


Does anyone have any idea why this is happening?



I am also attaching the image details of one of the offending photos:



image.png







python image opencv dlib






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 16:54









Kevin Workman

35.4k7 gold badges44 silver badges78 bronze badges




35.4k7 gold badges44 silver badges78 bronze badges










asked Mar 28 at 8:00









Rafay KhanRafay Khan

1401 silver badge11 bronze badges




1401 silver badge11 bronze badges















  • it is on the dlib document that dlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height

    – Ha Bom
    Mar 28 at 8:26











  • Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.

    – Rafay Khan
    Mar 28 at 8:38






  • 1





    I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github

    – Ha Bom
    Mar 28 at 8:43






  • 1





    Some images have Orientation set in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check with exiftool or ImageMagick.

    – Mark Setchell
    Mar 28 at 8:52







  • 1





    stackoverflow.com/a/48146220/2836621

    – Mark Setchell
    Mar 28 at 8:59

















  • it is on the dlib document that dlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height

    – Ha Bom
    Mar 28 at 8:26











  • Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.

    – Rafay Khan
    Mar 28 at 8:38






  • 1





    I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github

    – Ha Bom
    Mar 28 at 8:43






  • 1





    Some images have Orientation set in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check with exiftool or ImageMagick.

    – Mark Setchell
    Mar 28 at 8:52







  • 1





    stackoverflow.com/a/48146220/2836621

    – Mark Setchell
    Mar 28 at 8:59
















it is on the dlib document that dlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height

– Ha Bom
Mar 28 at 8:26





it is on the dlib document that dlib.load_rgb_image(filename: unicode) → numpy.ndarray[(rows,cols,3),uint8]. It's just different in the order of width and height

– Ha Bom
Mar 28 at 8:26













Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.

– Rafay Khan
Mar 28 at 8:38





Yeah, I did check out the docs. This doesn't make sense the in a numpy array of an image the rows=height_of_image, and cols=width_of_image.

– Rafay Khan
Mar 28 at 8:38




1




1





I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github

– Ha Bom
Mar 28 at 8:43





I see. I think if it happened only in some images, it could be an issue. You better inform this problem in the dlib github

– Ha Bom
Mar 28 at 8:43




1




1





Some images have Orientation set in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check with exiftool or ImageMagick.

– Mark Setchell
Mar 28 at 8:52






Some images have Orientation set in their EXIF data - particularly camera phone ones. OpenCV ignores it. You can check with exiftool or ImageMagick.

– Mark Setchell
Mar 28 at 8:52





1




1





stackoverflow.com/a/48146220/2836621

– Mark Setchell
Mar 28 at 8:59





stackoverflow.com/a/48146220/2836621

– Mark Setchell
Mar 28 at 8:59












1 Answer
1






active

oldest

votes


















1
















Thanks to @Mark Setchell, for pointing me in the right direction.



The EXIF data is the key, here.



dlib.load_rgb_image() does not take into account the EXIF orientation metadata, so some images are read incorrectly. To remedy this EXIF orientation tag of an image needs to be checked to perform the correct rotation on it.



Here are a few good answers:
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnail



Apparently, since OpenCV 3.1 imread handles EXIF orientation perfectly.






share|improve this answer



























  • Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.

    – Mark Setchell
    Mar 28 at 17:03











  • Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL

    – Rafay Khan
    Mar 29 at 5:27










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392646%2fwhy-is-dlibs-load-rgb-image-method-rotating-some-of-my-images%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1
















Thanks to @Mark Setchell, for pointing me in the right direction.



The EXIF data is the key, here.



dlib.load_rgb_image() does not take into account the EXIF orientation metadata, so some images are read incorrectly. To remedy this EXIF orientation tag of an image needs to be checked to perform the correct rotation on it.



Here are a few good answers:
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnail



Apparently, since OpenCV 3.1 imread handles EXIF orientation perfectly.






share|improve this answer



























  • Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.

    – Mark Setchell
    Mar 28 at 17:03











  • Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL

    – Rafay Khan
    Mar 29 at 5:27















1
















Thanks to @Mark Setchell, for pointing me in the right direction.



The EXIF data is the key, here.



dlib.load_rgb_image() does not take into account the EXIF orientation metadata, so some images are read incorrectly. To remedy this EXIF orientation tag of an image needs to be checked to perform the correct rotation on it.



Here are a few good answers:
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnail



Apparently, since OpenCV 3.1 imread handles EXIF orientation perfectly.






share|improve this answer



























  • Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.

    – Mark Setchell
    Mar 28 at 17:03











  • Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL

    – Rafay Khan
    Mar 29 at 5:27













1














1










1









Thanks to @Mark Setchell, for pointing me in the right direction.



The EXIF data is the key, here.



dlib.load_rgb_image() does not take into account the EXIF orientation metadata, so some images are read incorrectly. To remedy this EXIF orientation tag of an image needs to be checked to perform the correct rotation on it.



Here are a few good answers:
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnail



Apparently, since OpenCV 3.1 imread handles EXIF orientation perfectly.






share|improve this answer















Thanks to @Mark Setchell, for pointing me in the right direction.



The EXIF data is the key, here.



dlib.load_rgb_image() does not take into account the EXIF orientation metadata, so some images are read incorrectly. To remedy this EXIF orientation tag of an image needs to be checked to perform the correct rotation on it.



Here are a few good answers:
Rotating an image with orientation specified in EXIF using Python without PIL including the thumbnail



Apparently, since OpenCV 3.1 imread handles EXIF orientation perfectly.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 29 at 5:28

























answered Mar 28 at 9:20









Rafay KhanRafay Khan

1401 silver badge11 bronze badges




1401 silver badge11 bronze badges















  • Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.

    – Mark Setchell
    Mar 28 at 17:03











  • Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL

    – Rafay Khan
    Mar 29 at 5:27

















  • Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.

    – Mark Setchell
    Mar 28 at 17:03











  • Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL

    – Rafay Khan
    Mar 29 at 5:27
















Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.

– Mark Setchell
Mar 28 at 17:03





Thank you for working it out and sharing back with the Stack Overflow community. You can accept your own answer and bag the points, by the way.

– Mark Setchell
Mar 28 at 17:03













Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL

– Rafay Khan
Mar 29 at 5:27





Thanks, will do that. Apparently, can't accept my own answer for at least two days. LOL

– Rafay Khan
Mar 29 at 5:27








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid …


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392646%2fwhy-is-dlibs-load-rgb-image-method-rotating-some-of-my-images%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?