display OpenCV image at full “Retina” resolution on macOS
It was suggested I ask a new question, even though this same issue was asked in June 2016 and never answered.
When imshow
is called on an OpenCV mat
on an Apple macOS machine, it is displayed at half the “Retina” screen resolution. That is, it is twice the size it should be in both dimensions, essentially “zoomed in” or scaled up.
There may be a reason this is the default behavior. But I want to be able to display images at the same high resolution as the rest of the screen and at their “natural” size. Is there any way to do that?
I'm using OpenCV 4.1.2 on macOS Catalina 10.15.2 with Xcode/clang/c++
Can you show your code? imshow code is here. There is no dpi in opencv
The code is pretty unremarkable, and similar to bob_oi’s example in his 2016 question. the variable
size
is normally set to 511:What is the size value? Have you got opengl in your opencv configuration?
As I mentioned above,
size
is normally 511. The resolution of my Retina LCD screen is 2880x1800. When I display my 511x511 images usingimshow
and tile them horizontally, I can fit two of them (plus most of a third one) across the screen. This corresponds to my original report that they are about 1024x1024, roughly twice their “natural” size. I expected to fit at least 5 of these images across the screen.As to OpenGL, I do not think so, but am not sure. I installed OpenCV using the HomeBrew package management system, similar to
appget
on Linux. This page describes brew’s OpenCV package: https://formulae.brew.sh/formula/opencv (Probably not relevant but an old version of OpenGL is definitely installed on this laptop and I use it in other projects. OpenGL is deprecated by Apple.)Perhaps I can ask my friends who more about Objective-C++ and the macOS window system if they know how to access Retina resolution.
(Interesting coincidence the macOS source for
cvMoveWindow
just below the code reference give by LBerger above, was recently patched in response to another bug I reported.)