title: Displaying an image with opencv and asyncio Python 3.6
body: <p>I was running a trial to see whether I can display an image and wait for a keypress with opencv3 as one process within an asynchronous program. It struck me that this was central to what I am wanting to do and I had better check it out first. So here's the code:</p>
  
  <pre><code>import asyncio
  import cv2
  import functools
  
  
  def load_img(image):
      print(image)
      im = cv2.imread(image, cv2.IMREAD_GRAYSCALE)
      _, inv = cv2.threshold(im, 150, 255, cv2.THRESH_BINARY_INV)
      cv2.GaussianBlur(inv, (3, 3), 0)
      cv2.imshow('Async test', inv)
      cv2.waitKey(0)
      cv2.destroyAllWindows()
      return
  
  
  async def test():
      tiff_img = 'Im1.tiff'
      await loop.run_in_executor(None, functools.partial(load_img, 
                                                         image=tiff_img))
  
      return
  
  
  async def numbers():
      for number in range(200):
          await asyncio.sleep(0.5)
          print(number)
      return
  
  if __name__ == '__main__':
  
      loop = asyncio.get_event_loop()
      single = asyncio.gather(test(), numbers())
      loop.run_until_complete(single)
  </code></pre>
  
  <p>Output is:</p>
  
  <pre><code>Im1.tiff
  2018-01-26 15:22:11.091 python3.6[2784:215235] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
  0
  1
  2
  3
  4
  </code></pre>
  
  <p>Looking at the warning it is perhaps self explanatory.</p>
  
  <p>Question is whether there is a way to achieve my aim or not ??</p>