title: OpenCV: Segmentation fault (core dumped)
body: <p>This is the very basic program:</p>
  
  <pre><code>import numpy
  import cv2
  
  img = cv2.imread('watch.jpg', cv2.IMREAD_GRAYSCALE)
  
  cv2.imshow('image', img)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>When I write <code>python3 opencv.py</code>, the following error occurs:</p>
  
  <pre><code>QObject::moveToThread: Current thread (0x2e43c30) is not the object's thread (0x2ee1060).
  
  Cannot move to target thread (0x2e43c30)
  
  Segmentation fault (core dumped)
  </code></pre>
  
  <p>The error arises due to the line containing <code>imshow()</code>. 
  Plotting using <code>matplotlib</code> works just fine.
  Using python2 gives the same error as well.</p>
  
  <p>I have installed/reinstalled opencv using:</p>
  
  <pre><code>sudo pip3 install opencv-python
  
  sudo apt install python-opencv
  </code></pre>
  
  <p>Tried installing contrib package while searching for solution</p>
  
  <pre><code>sudo pip3 install opencv-contrib-python
  </code></pre>
  
  <p>Tried two different virtual environments namely <code>conda</code> and <code>venv</code> (clearly it won't have solved the problem)</p>
  
  <p>This is the result of debugging using <code>gdb python3</code> > <code>run opencv.py</code></p>
  
  <pre><code>Starting program: /home/subtleseeker/virtualenvironment/pp/bin/python3 openCV.py
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
  [New Thread 0x7ffff3bac700 (LWP 13322)]
  [New Thread 0x7ffff33ab700 (LWP 13323)]
  [New Thread 0x7fffeebaa700 (LWP 13324)]
  QObject::moveToThread: Current thread (0xee9360) is not the object's thread (0xf867a0).
  Cannot move to target thread (0xee9360)
  
  
  Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
  0x00007fffe24d41ce in xcb_send_request_with_fds64 ()
     from /usr/lib/x86_64-linux-gnu/libxcb.so.1
  </code></pre>
  
  <p>I am using Kubuntu 17.04. I am really out of options, of what else to try. Any help is greatly appreciated.</p>