Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pressing q for fullscreen crashes the program #9

Open
fuzzy7k opened this issue Dec 17, 2023 · 9 comments
Open

Pressing q for fullscreen crashes the program #9

fuzzy7k opened this issue Dec 17, 2023 · 9 comments

Comments

@fuzzy7k
Copy link

fuzzy7k commented Dec 17, 2023

While running on PurseOS 10 with Phosh, attempting to run fullscreen causes the window to crash. There are no messages on the console or in the journal. It just closes and I am not sure how to debug further.

@fuzzy7k
Copy link
Author

fuzzy7k commented Dec 18, 2023

Initializing the window fullscreen works good.

@tew2012
Copy link

tew2012 commented Dec 19, 2023

got the same problem on a Raspberry Pi, no error message. What did you do to get it work? I don't need to switch it. It could always run in fullscreen mode.

@fuzzy7k
Copy link
Author

fuzzy7k commented Dec 19, 2023

-dispFullscreen = False
-cv2.namedWindow('Thermal',cv2.WINDOW_GUI_NORMAL)
+dispFullscreen = True
+cv2.namedWindow('Thermal',cv2.WND_PROP_FULLSCREEN)
+cv2.setWindowProperty('Thermal',cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)

@tew2012
Copy link

tew2012 commented Dec 19, 2023

Thanks for the fast reply!

I tried it, but it still doesn't start in fullscreen on a Pi (4). And when I press q (for fullscreen) there is a frameless picture of the output on the left top side for a few milli seconds on the desktop. Then the script stopped working, no error message (even with -v).

the scale option (keys d and c) doesn't change the window size. It changes the font and crosshair size. (maybe that explains why fullscreen doesn't work?)

When I change lines 294 and 302 from

if dispFullscreen == False and isPi == False:

to if dispFullscreen == False and isPi == True:

then the script executes cv2.resizeWindow('Thermal', newWidth,newHeight) after rescaling and that works on a Pi as expected.

below is a link to an example of a py (MLX) thermal script from another project which uses the same commands to go into fullscreen and this script actually works (with an MLX chip). Any ideas to make the PyThermalCamera script go into fullscreen on a Pi (4).

https://myshare.leuphana.de/?t=8096f1b371e565d325914e8ff45cd9a9

    cv2.namedWindow('Thermal Image', cv2.WND_PROP_FULLSCREEN)
    cv2.setWindowProperty('Thermal Image',cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)

@tew2012
Copy link

tew2012 commented Dec 19, 2023

I found the problem. q starts fullscreen mode and at the same time quits the application. It works after changing the quit key (second block).

	if keyPress == ord('q'): #enable fullscreen
		dispFullscreen = True

....
if keyPress == ord('q'):
break
capture.release()
cv2.destroyAllWindows()

@fuzzy7k
Copy link
Author

fuzzy7k commented Dec 19, 2023

I found the problem. q starts fullscreen mode and at the same time quits the application. It works after changing the quit key (second block).

Hah! good catch.

I suppose I should have included line numbers with those modifications. I changed the init code toward the top.

diff --git a/src/tc001v4.2.py b/src/tc001v4.2.py
index a537d36..625bed7 100644
--- a/src/tc001v4.2.py
+++ b/src/tc001v4.2.py
@@ -69,8 +69,9 @@ newHeight = height*scale
 alpha = 1.0 # Contrast control (1.0-3.0)
 colormap = 0
 font=cv2.FONT_HERSHEY_SIMPLEX
-dispFullscreen = False
-cv2.namedWindow('Thermal',cv2.WINDOW_GUI_NORMAL)
+dispFullscreen = True
+cv2.namedWindow('Thermal',cv2.WND_PROP_FULLSCREEN)
+cv2.setWindowProperty('Thermal',cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
 cv2.resizeWindow('Thermal', newWidth,newHeight)
 rad = 0 #blur radius
 threshold = 2

@fuzzy7k
Copy link
Author

fuzzy7k commented Dec 19, 2023

Instead of changing the quit key, I changed the Fullscreen key to 'e'.

@tew2012
Copy link

tew2012 commented Dec 19, 2023

Thank you!!

@fuzzy7k
Copy link
Author

fuzzy7k commented Dec 27, 2023

Not sure where to drop this, so I'll do it here. I started a branch to make this more user friendly on the Librem5. It works on the Pinephone too. It includes a patch that triggers fullscreen on phosh devices. q remains Quit. https://github.com/fuzzy7k/PyThermalCamera/

It still needs some work to restore rotation settings after closing. I might create some pull requests, but the author does not seem entirely active.

There is a helper/install script to install udev and systemd files on linux that will automatically launch the program on plugin. The automatic launch on plugin only works on the p2pro, as that is what I have, Adding tc001 vid,pid to the udev file should make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants