Ticker

6/recent/ticker-posts

Raspberry Pi Python to set Brightness of Camera Module and preview

Example code of Python 2, run on Raspberry Pi, to control Camera Module, set Brightness and preview. Control Camera Module with picamera, and implement GUI with Tkinter. It's a Tkinter.Scale to set brightness.


Because the preview will be shown on main display, so I run the Python code remotely on Android tablet with Microsoft Remote Desktop app.


testBrightness.py
import picamera
from time import sleep
import Tkinter

def quit():
camera.stop_preview()
global tkTop
tkTop.destroy()

def setBrightness(ev=None):
global camera
global tkScale
camera.brightness = tkScale.get()

camera = picamera.PiCamera()
camera.start_preview()
camera.brightness = 50

tkTop = Tkinter.Tk()
tkTop.wm_title("Raspberry Pi Camera - Brightness")
tkTop.geometry('400x200')

tkButtonQuit = Tkinter.Button(
tkTop, text="Quit", command=quit)
tkButtonQuit.pack()

tkScale = Tkinter.Scale(
tkTop,
from_=0, to=100,
length=300,
orient=Tkinter.HORIZONTAL,
command=setBrightness)
tkScale
tkScale.set(50)
tkScale.pack(anchor=Tkinter.CENTER)

Tkinter.mainloop()


Next:
Python to capture image from Raspberry Pi Camera Module

إرسال تعليق

0 تعليقات