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

1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

인천여자상업고등학교 목차 학교 연혁 설치 학과 학교 동문 참고 자료 각주 외부 링크 둘러보기 메뉴북위 37° 28′ 05″ 동경 126° 37′ 41″ / 북위 37.4680025° 동경 126.6279602°  / 37.4680025; 126.6279602인천여자상업고등학교“인천광역시립학교 설치조례 별표1”인천여자상업고등학교 홈페이지eheh문서를 완성해