Also so richtig bekomme ich es nicht hin.
Hier mal der gesamte Code des Programmes.
Hätte jetzt noch gern eine Art Fadenkreuz über dem Kamerabild.
Vielleicht kann sich das mal jemand anschauen und vielleicht eine Starthilfe geben.
Code: Alles auswählen
from tkinter import *
from tkinter import messagebox
import tkinter as tk
import picamera
APP_TITLE = "Kamera"
APP_XPOS = 10
APP_YPOS = 10
APP_WIDTH = 1280
APP_HEIGHT = 800
Hintergrundbild = "Hintergrund.gif"
camera = picamera.PiCamera(resolution=(1920,1080))
cam_bri = 30
cam_con = 60
cam_shu = 20000
cam_iso = 100
camera.brightness = cam_bri
camera.contrast = cam_con
camera.shutter_speed = cam_shu
camera.iso = cam_iso
camera.vflip=False
camera.hflip=False
camera.awb_mode='auto'
camera.exposure_mode='sports'
camera.video_stabilization=True
camera.preview_fullscreen=False
camera.preview_window=(200, 50, 1050, 800)
class Settings(tk.Toplevel):
def __init__(self, parent, noborder=True):
super().__init__(parent)
self.title("Settings")
self.geometry("{}x{}".format(180, 500))
self.geometry("+{}+{}".format(10, 200))
self.configure(bg='steelblue1')
self.wm_overrideredirect(noborder)
self.cambri_threshold = tk.IntVar(value=cam_bri)
self.camcon_threshold = tk.IntVar(value=cam_con)
self.camiso_threshold = tk.IntVar(value=cam_iso)
self.camshu_threshold = tk.IntVar(value=cam_shu)
main_frame = tk.Frame(self)
main_frame .pack(padx=10, pady=10)
settings_label = Label(self, bg="steelblue1", text="Einstellungen")
settings_label.place(x = 20, y = 5, width=150, height=40)
settings_label.config(font=("Arial", 15))
##Helligkeit##
anweisungs_label = Label(self, bg="steelblue1", text="Helligkeit")
anweisungs_label.place(x = 50, y = 50, width=80, height=40)
anweisungs_label.config(font=("Arial", 12))
bri_label = Label(self, bg="steelblue1", textvariable=self.cambri_threshold)
bri_label.place(x = 50, y = 90, width=80, height=40)
bri_label.config(font=("Arial", 12))
bri1_button = Button(self, text="+", background='steelblue1', activebackground='steelblue3', command=self.cambri1)
bri1_button.place(x = 120, y = 90, width=40, height=40)
bri2_button = Button(self, text="-", background='steelblue1', activebackground='steelblue3', command=self.cambri2)
bri2_button.place(x = 20, y = 90, width=40, height=40)
##Kontrast##
anweisungs_label = Label(self, bg="steelblue1", text="Kontrast")
anweisungs_label.place(x = 50, y = 130, width=80, height=40)
anweisungs_label.config(font=("Arial", 12))
con_label = Label(self, bg="steelblue1", textvariable=self.camcon_threshold)
con_label.place(x = 50, y = 170, width=80, height=40)
con_label.config(font=("Arial", 12))
con1_button = Button(self, text="+", background='steelblue1', activebackground='steelblue3', command=self.con1)
con1_button.place(x = 120, y = 170, width=40, height=40)
con2_button = Button(self, text="-", background='steelblue1', activebackground='steelblue3', command=self.con2)
con2_button.place(x = 20, y = 170, width=40, height=40)
##ISO##
anweisungs_label = Label(self, bg="steelblue1", text="ISO-Wert")
anweisungs_label.place(x = 50, y = 210, width=80, height=40)
anweisungs_label.config(font=("Arial", 12))
iso_label = Label(self, bg="steelblue1", textvariable=self.camiso_threshold)
iso_label.place(x = 50, y = 250, width=80, height=40)
iso_label.config(font=("Arial", 12))
iso1_button = Button(self, text="+", background='steelblue1', activebackground='steelblue3', command=self.Iso1)
iso1_button.place(x = 120, y = 250, width=40, height=40)
iso2_button = Button(self, text="-", background='steelblue1', activebackground='steelblue3', command=self.Iso2)
iso2_button.place(x = 20, y = 250, width=40, height=40)
##Belichtung##
anweisungs_label = Label(self, bg="steelblue1", text="Belichtung")
anweisungs_label.place(x = 50, y = 290, width=80, height=40)
anweisungs_label.config(font=("Arial", 12))
shu_label = Label(self, bg="steelblue1", textvariable=self.camshu_threshold)
shu_label.place(x = 50, y = 330, width=80, height=40)
shu_label.config(font=("Arial", 12))
shu1_button = Button(self, text="+", background='steelblue1', activebackground='steelblue3', command=self.shu1)
shu1_button.place(x = 120, y = 330, width=40, height=40)
shu2_button = Button(self, text="-", background='steelblue1', activebackground='steelblue3', command=self.shu2)
shu2_button.place(x = 20, y = 330, width=40, height=40)
Quit_button = Button(self, text="schließen", background='steelblue1', activebackground='steelblue3', command=self.destroy)
Quit_button.place(x = 25, y = 430, width=120, height=40)
#####################################################
def cambri1(self):
global cam_bri
wert = 5
cam_bri = min(100, cam_bri + wert)
camera.brightness = cam_bri
self.cambri_threshold.set(self.cambri_threshold.get() + wert)
def cambri2(self):
global cam_bri
wert = 5
cam_bri = min(100, cam_bri - wert)
camera.brightness = cam_bri
self.cambri_threshold.set(self.cambri_threshold.get() - wert)
def con1(self):
global cam_con
wert = 5
cam_con = min(100, cam_con + wert)
camera.contrast = cam_con
self.camcon_threshold.set(self.camcon_threshold.get() + wert)
def con2(self):
global cam_con
wert=5
cam_con = min(100, cam_con - wert)
camera.contrast = cam_con
self.camcon_threshold.set(self.camcon_threshold.get() - wert)
def Iso1(self):
global cam_iso
wert = 50
cam_iso = min(800, cam_iso + wert)
camera.iso = cam_iso
self.camiso_threshold.set(self.camiso_threshold.get() + wert)
def Iso2(self):
global cam_iso
wert = 50
cam_iso = min(800, cam_iso - wert)
camera.iso = cam_iso
self.camiso_threshold.set(self.camiso_threshold.get() - wert)
def shu1(self):
global cam_shu
wert = 5000
cam_shu = min(1000000, cam_shu + wert)
camera.shutter_speed = cam_shu
self.camshu_threshold.set(self.camshu_threshold.get() + wert)
def shu2(self):
global cam_shu
wert = 5000
cam_shu = min(1000000, cam_shu - wert)
camera.shutter_speed = cam_shu
self.camshu_threshold.set(self.camshu_threshold.get() - wert)
############## Hauptfenster############
class MainFrame(tk.Frame):
def __init__(self, haupt_fenster):
super().__init__(haupt_fenster)
self.haupt_fenster = haupt_fenster
self.haupt_fenster.protocol("WM_DELETE_WINDOW", self.close)
self.build()
def build(self):
button_frame = tk.Frame(self)
button_frame.pack(pady=5)
button_frame.configure(bg='steelblue1')
tk.Button(button_frame, text=" Starten", background='steelblue1', activebackground='steelblue3', command=self.capture).pack(side='left', padx=4)
tk.Button(button_frame, text="Stopen", background='steelblue1', activebackground='steelblue3', command=self.stop).pack(side='left', padx=4)
tk.Button(button_frame, text="Einstellungen", background='steelblue1',activebackground='steelblue3', command=self.set_fenster).pack(side='left', padx=4)
exit_button = tk.Button(button_frame, text="Beenden", background='steelblue1', activebackground='steelblue3', command=self.close).pack(side='left', padx=4)
tk.Button(button_frame, text="Info", background='steelblue1', activebackground='steelblue3', command=self.action_get_info_dialog).pack(side='left', padx=4)
def capture(self):
print("Capture")
camera.start_preview()
def set_fenster(self):
print("set_fenster")
self.settings = Settings(self.haupt_fenster)
def action_get_info_dialog(self):
print("action_get_info_dialog")
camera.stop_preview()
m_text = "\
************************\n\
Autor: \n\
Date: 31.05.18\n\
Version: 1.03\n\
************************"
messagebox.showinfo(message=m_text, title = "Infos")
# messagebox.askyesno(message=m_text, title = "Infos")
def stop(self):
print("Stop")
camera.stop_preview()
def close(self):
print("Application-Shutdown")
self.master.destroy()
camera.stop_preview()
def main():
haupt_fenster = tk.Tk()
haupt_fenster.title(APP_TITLE)
haupt_fenster.overrideredirect(True)
haupt_fenster.geometry("{0}x{1}+0+0".format(haupt_fenster.winfo_screenwidth(), haupt_fenster.winfo_screenheight()))
#haupt_fenster.geometry("+{}+{}".format(APP_XPOS, APP_YPOS))
#haupt_fenster.geometry("{}x{}".format(APP_WIDTH, APP_HEIGHT))
haupt_fenster.option_add("*highlightThickness", 0)
haupt_fenster.configure(bg='steelblue1')
background_image = tk.PhotoImage(file=Hintergrundbild)
tk.Label(haupt_fenster, image=background_image).place(x=0, y=0)
main_frame = MainFrame(haupt_fenster)
main_frame.pack(fill='both', expand=False, padx=0, pady=0,)
main_frame.configure(bg='steelblue1')
haupt_fenster.mainloop()
if __name__ == '__main__':
main()