Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading 在线程中调用cv2.imshow()时,启动时不会弹出窗口_Multithreading_Opencv_Macos Catalina - Fatal编程技术网

Multithreading 在线程中调用cv2.imshow()时,启动时不会弹出窗口

Multithreading 在线程中调用cv2.imshow()时,启动时不会弹出窗口,multithreading,opencv,macos-catalina,Multithreading,Opencv,Macos Catalina,在线程中调用时,cv2.imshow()不会弹出窗口。docker中会出现python3图标,但没有窗口,也没有绘图。此外,我需要半双工通信的功能,因此我不能只删除线程。如何正确显示线程内的图片?欢迎您的回复 背景:MacOS Catalina,python==3.5,opencv==3.4.2 import cv2 import threading def run(): # start the camera video_reader = cv2.VideoCapture(0)

在线程中调用时,cv2.imshow()不会弹出窗口。docker中会出现python3图标,但没有窗口,也没有绘图。此外,我需要半双工通信的功能,因此我不能只删除线程。如何正确显示线程内的图片?欢迎您的回复

背景:MacOS Catalina,python==3.5,opencv==3.4.2

import cv2
import threading

def run():
    # start the camera
    video_reader = cv2.VideoCapture(0)
    while True:
        # collect image
        ret_val, image = video_reader.read()
        cv2.imshow('image', image)
        if cv2.waitKey(1) == 27:
            break  # esc to quit

t = threading.Thread(target=run, name="run")
t.start()
一些可能有帮助的警告消息:

python3[86286:1964642] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
    0   AppKit                              0x00007fff2fc177f0 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 371
    1   AppKit                              0x00007fff2fc14ce1 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
    2   AppKit                              0x00007fff2fc14753 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
    3   AppKit                              0x00007fff2fea8368 -[NSWindow initWithContentRect:styleMask:backing:defer:screen:] + 52
    4   libopencv_highgui.3.4.2.dylib       0x000000010327bee7 cvNamedWindow + 727
    5   libopencv_highgui.3.4.2.dylib       0x000000010327b7a3 cvShowImage + 195
    6   libopencv_highgui.3.4.2.dylib       0x000000010327860d _ZN2cv6imshowERKNS_6StringERKNS_11_InputArrayE + 477
    7   cv2.cpython-35m-darwin.so           0x00000001014f8393 _ZL18pyopencv_cv_imshowP7_objectS0_S0_ + 387
    8   python3                             0x0000000100ca759f PyCFunction_Call + 127
    9   python3                             0x0000000100d6eec7 PyEval_EvalFrameEx + 18583
    10  python3                             0x0000000100d68faf _PyEval_EvalCodeWithName + 335
    11  python3                             0x0000000100c746aa function_call + 106
    12  python3                             0x0000000100c30b35 PyObject_Call + 69
    13  python3                             0x0000000100d6fc9b PyEval_EvalFrameEx + 22123
    14  python3                             0x0000000100d6efb8 PyEval_EvalFrameEx + 18824
    15  python3                             0x0000000100d6efb8 PyEval_EvalFrameEx + 18824
    16  python3                             0x0000000100d68faf _PyEval_EvalCodeWithName + 335
    17  python3                             0x0000000100c746aa function_call + 106
    18  python3                             0x0000000100c30b35 PyObject_Call + 69
    19  python3                             0x0000000100c53694 method_call + 148
    20  python3                             0x0000000100c30b35 PyObject_Call + 69
    21  python3                             0x0000000100d77bf4 PyEval_CallObjectWithKeywords + 68
    22  python3                             0x0000000100de472a t_bootstrap + 122
    23  libsystem_pthread.dylib             0x00007fff69e8cd76 _pthread_start + 125
    24  libsystem_pthread.dylib             0x00007fff69e895d7 thread_start + 15
)
2019-10-14 15:20:27.485 python3[86286:1964642] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.

Apple只允许在macOS和iOS的主线程上使用本机UI功能。

Apple只允许在macOS和iOS的主线程上使用本机UI功能。

您好。。这为我解决了问题,我运行了你的代码,没有任何更改。除了我使用了一个视频文件插入使用相机,和代码是完美的工作。尝试这样做,并提供您得到的输出。嗨。。这为我解决了问题,我运行了你的代码,没有任何更改。除了我使用了一个视频文件插入使用相机,和代码是完美的工作。尝试这样做,并提供您得到的输出。