[PYTHON] Notes on imshow () in OpenCV

Something is displayed in a glance at imshow of OpenCV

I decided to touch openCV in class, so first install. By the way, mac, Python 3.7.4

pip install opencv-python

Then, create test.py that just displays the image.

test.py



import cv2
img = cv2.imread('mona.jpg')
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

Although the image was displayed when executed,

objc[62826]: Class RunLoopModeTracker is implemented in both /Users/username/.pyenv/versions/anaconda3-2019.10/lib/python3.7/site-packages/cv2/.dylibs/QtCore (0x1139e97f0) and /Users/username/.pyenv/versions/anaconda3-2019.10/lib/libQt5Core.5.9.7.dylib (0x128195a80). One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7fc0f7435300) is not the object's thread (0x7fc0f9f02cc0).
Cannot move to target thread (0x7fc0f7435300)

You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
QObject::moveToThread: Current thread (0x7fc0f7435300) is not the object's thread (0x7fc0f9f02cc0).
Cannot move to target thread (0x7fc0f7435300)

(Omitted)

Documents similar to "You might be-" follow in a row in the abbreviation. Even though the image is displayed, I'm worried about it.

After a little research, I found a similar case at here.

"If multiple packages have GUI functions, you can install the ver without GUI functions from Mazui." It seems that opencv-python-headless, which has no GUI function, should be installed.

pip install opencv-python-headless

Hundreds of mysterious lines disappeared safely. Rest assured. By the way, if you enter the keyboard with the image selected, it will end.

However, the site that seems to be official says that you have to install only one appropriate one, so uninstall opencv-python.

pip uninstall opencv-python

Then, it seems that the necessary headless was also uninstalled, so install it again.

pip install opencv-python-headless

That's it.

Recommended Posts

Notes on imshow () in OpenCV
Notes for using OpenCV on Windows10 Python 3.8.3.
Notes on nfc.ContactlessFrontend () for nfcpy in python
Notes on creating static files in Django
Notes on Flask
Notes on using code formatter in Python
Notes on using dict in python [Competition Pro]
ABC125_C --GCD on Blackboard [Notes solved in Python]
Notes on neural networks
Notes on installing PycURL
Notes on using Alembic
Notes on SciPy.linalg functions
Notes on transactions in the Java client library in the datastore
Notes on tf.function and Tracing
Web scraping notes in python3
Notes on installing dlib on mac
Notes on python's sqlite3 module
Notes on * args and ** kargs
Notes on defining PySide slots (2)
Try using OpenCV on Windows
[Django] Notes on using django-debug-toolbar
Notes on pyenv and Atom
Notes on defining PySide slots
[Python] Notes on data analysis
Notes on optimization using Pytorch
Notes on installing Python on Mac
Make Opencv available in Python
Notes on installing pipenv on Mac
Notes on how to use marshmallow in the schema library
Get Evernote notes in Python
Notes on installing Anaconda 3 on Windows
Notes on installing Python on CentOS
Install OpenCV4 on Raspberry Pi 3
Notes on reading and writing float32 TIFF images in python
How to install OpenCV on Cloud9 and run it in Python
Notes on installing Caffe in CPU mode on Mac OSX 10.11 (El Captain)
Notes on package management with conda
Easy installation of OpenCV on RaspberryPi 3+
Install OpenCV and Chainer on Ubuntu
Notes on using MeCab from Python
[Golang] Notes on frequently used functions
Put python, numpy, opencv3 in ubuntu14
Notes on how to use pywinauto
Introducing OpenCV on Mac with homebrew
Notes on using post-receive and post-merge
Notes on how to use featuretools
How to install OpenCV on Mac
OpenCV installation procedure on Raspberry Pi
Notes on using rstrip with python.
Notes on accessing dashDB from python
Batch processing notes in IPython Notebook
Use OpenCV with Python 3 in Window
Notes on how to use doctest
Try installing OpenCV 3.0 on your AMI
Notes on using matplotlib on the server
Notes on how to write requirements.txt
Notes on installing Ubuntu 18.04 on the XPS 15 7590
(Beginner) Notes on using pyenv on Mac
OpenCV3 & Python3 environment construction on Ubuntu
Understand how to display images on Jupyter (utilization of imshow / matplotlib of OpenCV)
Notes on resolving references to packages in Python projects in IntelliJ IDEA (PyCharm)