Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8093

Troubleshooting • Re: Python Program will not autostart

$
0
0
I found the problem. The python script ended, so the RPi returned to the desktop. Hence the blip.

When I inserted the following to the program, it worked fine.

Code:

from picamera2 import Picamera2, Previewfrom libcamera import Transformpicam2 = Picamera2()picam2.start_preview(Preview.QTGL, x=100, y=200, width=800, height=600, transform=Transform(vflip=1))picam2.start()# inserted to keep the program runningwhile True:x=1

Which is one of the things I suggested above.

However I wouldn't do it like that as your code will use 100% of a CPU core which is not desirable.

Try (my changes bracketed by ##):

Code:

##from signal import pause##from picamera2 import Picamera2, Previewfrom libcamera import Transformpicam2 = Picamera2()picam2.start_preview(Preview.QTGL, x=100, y=200, width=800, height=600, transform=Transform(vflip=1))picam2.start()# inserted to keep the program running##pause()##
If you really want to use a while loop try:

Code:

##from time import sleep##from picamera2 import Picamera2, Previewfrom libcamera import Transformpicam2 = Picamera2()picam2.start_preview(Preview.QTGL, x=100, y=200, width=800, height=600, transform=Transform(vflip=1))picam2.start()# inserted to keep the program runningwhile True:    ##    time.sleep(1) # sleep for 1 second    ##

Statistics: Posted by thagrol — Tue Nov 25, 2025 6:15 pm



Viewing all articles
Browse latest Browse all 8093

Trending Articles