OpenCV slow on retina screen vs external screen
I have noticed a really weird behaivor of OpenCV on my Macbook 12 retina (Early 2015 model). I am using OpenCV 3.1.0 and Python 3.5.1 on Mac OSX El Capitan 10.11.2
When I put a window in the external screen (27" 1920x1080) the code runs fast but when I take the same window and move it to the builtin screen(12" 2304 × 1440 on the default settings) the code runs alot slower.
Here is a minimal code that shows the problem:
import cv2
import numpy as np
from time import time, sleep
sum_time = 0
samples = 1000
i = 0
while i < samples:
zeros = np.zeros((640,480,3), dtype=np.uint8)
cv2.imshow("Frame", zeros)
t = time()
cv2.waitKey(1)
sum_time += (time() - t)
i+=1
print("Avg time for took: %f" % (sum_time / samples))
When running on the external screen I get:
Avg time for took: 0.015225
When running the exact same code on the retina screen (i.e. the window is being rendered there):
Avg time for took: 0.033613
I tried it a bunch of times and the results are consistent, any idea what might cause this?
Well, the retina screen has a lot more pixels, and it might take time for the compositing engine to render your image on the screen. It's not just a matter of plotting values on the screen, but there is also some color correction and DPI enhancement involved on the retina screen. I suppose that takes time
Yeha but that much? I mean I can only push 10 fps and in the other screen I can push well over 30 fps... I would assume the GPU would take care of it, maybe the UI facilities in mac aren't accelerated?
It might just be that the imshow function isn't GPU accelerated.
any recommended alternative? :)