Ask Your Question

Revision history [back]

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?