cv2.imshow inside a seperate process? [closed]

asked 2016-09-02 19:57:32 -0500

bradfield gravatar image

Consider the following illustration:

import cv2
from multiprocessing import Process

def f(x):
    cv2.imshow('window',x)
    pass

if __name__=='__main__':
    cv2.namedWindow('window')
    img=cv2.imread("name.jpg",0)
    p=Process(target=f,args=(img,))
    p.start()
   ...

The named Window does open, but the image does not show up, unless I execute the imshow in the main process. Why is that?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-04 13:02:30.641860

Comments

I don't know if python works like c++, but you probably need to put a cv2.waitKey() after the imshow.

Tetragramm gravatar imageTetragramm ( 2016-09-02 20:34:40 -0500 )edit

namedWindow just creates a window. imshow puts the image in it

Nuser gravatar imageNuser ( 2018-12-26 01:11:24 -0500 )edit

it is a known bug

sturkmen gravatar imagesturkmen ( 2020-10-04 13:02:18 -0500 )edit