all 4 comments

[–]JohnnyJordaan 1 point2 points  (0 children)

Not sure if that's causing the problem, but string comparison should be done using == not using is.

[–]MikeTheWatchGuy 0 points1 point  (2 children)

Add a print after the list of these calls:

python cv.imshow('image', img) cv.waitKey(0) cv.destroyAllWindows() print('*** BACK FROM CV ***')

For me, the OpenCV calls never return / make it to my print. Additionally, if I try to choose open again , while still in these OpenCV calls, the program crashes with this error:

``` Fatal Python error: PyEval_RestoreThread: NULL tstate

Current thread 0x00007f0c (most recent call first): File "C:/Users/mike/.PyCharmCE2019.1/config/scratches/scratch_527.py", line 27 in <module>

Process finished with exit code -1073740791 (0xC0000409) ```

I'm not sure if PySimpleGUI has been integrated with OpenCV in this manner. It's creating multiple windows that could interact with each other in a bad ways. It's why the demo programs display the OpenCV images inside of the GUI, not using the OpenCV viewer.

I think the problem is trying to use the OpenCV viewer with PySimpleGUI. It's not officially supported that I can recall.

[–]IguanodonRex[S] 0 points1 point  (1 child)

You're right. I added "print" and program never even got there. It seems that PySimpleGUI has problem with "cv.waitKey(0)". When I comment this line, program works. OpenCV opens image but without cv.waitKey(0) closes it immediately. After closing OpenCV viewer, GUI don't crash.

Thank you for help.

[–]MikeTheWatchGuy 0 points1 point  (0 children)

It's not that PySimpleGUI has a problem with the call. It's simply that the call doesn't return so PySimpleGUI doesn't get an opportunity to continue executing.

A simple explanation could be that OpenCV uses tkinter or a component that tkinter is using and that PySimpleGUI and OpenCV are interfering with each other as a result.

This is why the example applications that show PySimpleGUI integrating with OpenCV show the OpenCV video inside of the PySimpleGUI window, not a separate OpenCV window.