Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

raspberry pi - unable to capture images using python (image gets corrupted)

so i made a camera app for the hq camera but i cannot take any sort of pictures on my raspberry pi 4!

from guizero import App, PushButton
from picamera import PiCamera

camera = PiCamera()

app = App()
def preview():
    camera.start_preview(fullscreen=False, window = (50,150,2048,1152))
    
button = PushButton(app, command=preview, text="preview")
def stop_preview():
    camera.stop_preview()
    
button = PushButton(app, command=stop_preview, text="stop preview")
def shutter():
    camera.capture('/home/pi/Desktop/image.jpg')
    
button = PushButton(app, command=shutter, text="shutter")
app.display()
question from:https://stackoverflow.com/questions/65867654/unable-to-capture-images-using-python-image-gets-corrupted

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

nevermind i got it working! here is my code!

from picamera import PiCamera

camera = PiCamera()
camera.resolution = (1920, 1080)

app = App()
def preview():
    camera.start_preview(fullscreen=False, window = (50,150,2048,1152))
    
button = PushButton(app, command=preview, text="preview")
def stop_preview():
    camera.stop_preview()
    
button = PushButton(app, command=stop_preview, text="stop preview")
def shutter():
    camera.capture('/home/pi/Desktop/image.jpg')
    
button = PushButton(app, command=shutter, text="shutter")
app.display()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...