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

giaphage sync #2

Open
wants to merge 1 commit into
base: giaphage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions Source/BasicControls.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

from Dialog import *
from Mapping import *
from NotePage import *
from Utils import *
from NotePage import *
from Utils import *
from VideoParams import *
from PhotoParams import *
from ImageEffects import *
Expand Down Expand Up @@ -96,6 +96,7 @@ def BuildPage ( self ):
self.FixedResolutionChanged)
self.FixedResolutionsCombo.grid(row=0,column=1,columnspan=3,sticky='W')
ToolTip(self.FixedResolutionsCombo,121)

#------------ Capture Width and Height ----------------
# OrderedDict is used to ensure the keys stay in the same order as
# entered. I want the combobox to display in this order
Expand Down Expand Up @@ -355,10 +356,13 @@ def Reset ( self ):
self.effects.current(0)
self.UseRadio.focus_set()
self.FlashModeOffRadio.invoke()

def UseVideoPort ( self , val):
pass #self.camera.use_video_port = val

def LedOnChecked ( self ):
self.camera.led = self.LedOn.get()

def SetupLabelCombo ( self, parent, textname, rownum, colnum,
minto, maxto, callback, cameraVal, label=''):
l = Label(parent,text=textname)
Expand All @@ -373,40 +377,52 @@ def SetupLabelCombo ( self, parent, textname, rownum, colnum,
scale.set(val) # this would attempt to call any callback
scale.config(command=callback) # now supply the callback
return label, scale, val

def UpdateMe( self, newVal, label ):
val = int(float(newVal))
label.config(text='%d' % val,
foreground='red' if val < 0 else 'blue' if val > 0 else 'black' )
return val

def CameraBrightnessChanged ( self, newVal ):
self.brightness.focus_set()

self.camera.brightness = self.UpdateMe(newVal,self.brightLabel)

def ContrastChanged ( self, newVal ):
self.contrast.focus_set()
self.camera.contrast = self.UpdateMe(newVal,self.contrastLabel)

def SaturationChanged ( self, newVal ):
self.saturation.focus_set()
self.camera.saturation = self.UpdateMe(newVal,self.saturationLabel)

def SharpnessChanged ( self, newVal ):
self.sharpness.focus_set()
self.camera.sharpness = self.UpdateMe(newVal,self.sharpnessLabel)

def ResetGeneralSliders ( self ):
self.brightness.set(50)
self.contrast.set(0)
self.saturation.set(0)
self.sharpness.set(0)
#self.ResetGeneralButton.focus_set()

def UpdateWidthHeightLabels ( self ):
res = self.camera.resolution # in case a different default value
self.WidthLabel.config(text='%d' % int(res[0]))
self.HeightLabel.config(text='%d' % int(res[1]))

def ResolutionChanged(self,event):
self.camera.resolution = (int(self.cb.get()),int(self.cb1.get()))

self.UpdateWidthHeightLabels()

def FixedResolutionChanged ( self, event ):
key = self.FixedResolutionsCombo.get().split(':')[0]
self.camera.resolution = self.StandardResolutions[key]
self.UpdateWidthHeightLabels()

def UseFixedResRadios ( self ):
states = {False:'disabled', True:'readonly'}
useFixedRes = self.UseFixedResolutions.get()
Expand All @@ -419,20 +435,24 @@ def UseFixedResRadios ( self ):
self.FixedResolutionsCombo.config(state=states[useFixedRes])
self.cb.config(state=states[not useFixedRes])
self.cb1.config(state=states[not useFixedRes])

def Zoom ( self, newVal, scale ):
self.camera.zoom = (float(self.Xzoom.get()),float(self.Yzoom.get()),
float(self.Widthzoom.get()),float(self.Heightzoom.get()))
scale.focus_set()

def SetZoom ( self, x, y, w, h ):
self.Xzoom.set(x)
self.Yzoom.set(y)
self.Widthzoom.set(w)
self.Heightzoom.set(h)

def ZoomReset ( self ):
self.Xzoom.set(0.0)
self.Yzoom.set(0.0)
self.Widthzoom.set(1.0)
self.Heightzoom.set(1.0)

def AllowImageResizeAfter ( self, allowResizeAfter ):
if allowResizeAfter:
state = 'readonly'
Expand All @@ -443,11 +463,14 @@ def AllowImageResizeAfter ( self, allowResizeAfter ):
state = 'disabled'
self.resizeWidthAfterCombo.config(state=state)
self.resizeHeightAfterCombo.config(state=state)

def ResizeAfterChanged ( self, event ):
self.resizeAfter = ( int(self.resizeWidthAfterCombo.get()),
int(self.resizeHeightAfterCombo.get()) )

def GetResizeAfter ( self ):
return self.resizeAfter

def EffectsChecked ( self, EffectsEnabled ):
if EffectsEnabled == True:
self.effects.config(state='readonly')
Expand All @@ -457,6 +480,7 @@ def EffectsChecked ( self, EffectsEnabled ):
self.effects.config(state='disabled')
self.ModParams.config(state='disabled')
self.camera.image_effect = 'none'

def EffectsChanged ( self, event ):
self.camera.image_effect = self.effects.get()
if self.camera.image_effect in ['solarize', 'colorpoint',
Expand All @@ -469,15 +493,20 @@ def EffectsChanged ( self, event ):
Effects1Page.EffectParam[self.camera.image_effect]
else:
self.ModParams.config(state='disabled')

def ModifyEffectsParamsPressed ( self ):
ImageEffectsDialog(self,title='Image Effects Parameters',
camera=self.camera,okonly=False)

def ImageDenoiseChecked ( self ):
self.camera.image_denoise = self.ImageDenoise.get()

def VideoDenoiseChecked ( self ):
self.camera.video_denoise = self.VideoDenoise.get()

def VideoStabChecked ( self ):
self.camera.video_stabilization = self.VideoStab.get()

def FlashModeButton ( self, FlashMode ):
if FlashMode == 'set':
self.FlashModeCombo.config(state='readonly')
Expand All @@ -486,6 +515,6 @@ def FlashModeButton ( self, FlashMode ):
else:
self.FlashModeCombo.config(state='disabled')
self.camera.flash_mode = FlashMode

def FlashModeChanged ( self, event ):
self.camera.flash_mode = self.FlashModeCombo.get()

169 changes: 169 additions & 0 deletions Source/Livestream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
# Timelapse.py
#
# Copyright 2018 Bill Williams
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
'''
from time import sleep
from Dialog import *
from Mapping import *
from NotePage import *

class Livestream ( BasicNotepage ):
def BuildPage ( self ):
f = ttk.LabelFrame(self,text='Time lapse settings',padding=(5,5,5,5))
f.grid(row=0,column=0,columnspan=4,sticky='NEWS',pady=5)
f.columnconfigure(2,weight=1)
f.columnconfigure(4,weight=1)

Label(f,text='Default').grid(row=0,column=0,sticky='E')
self.LowLightCaptureButton = Button(f,text='Low Light',width=15, \
command=self.CaptureLowLight)
self.LowLightCaptureButton.grid(row=1,column=0,sticky='W')
self.StartDelayCaptureButton = Button(f,text='Delay Capture',width=15, \
command=self.StartDelayCapture)
self.StartDelayCaptureButton.grid(row=2,column=0,sticky='W')

def CaptureLowLight ( self ):
self.camera.capture('foo.jpg')
pass
def StartDelayCapture ( self ):
pass
#### TODO: Implement Reset NEEDS LOTS OF WORK!!
def Reset ( self ):
pass

'''
What controls are needed for this page?
Photo captures:
Type of Time lapse
Burst
Timed
etc
Whether the image settings stay the same for each picture - Checkbox
Whether the Video port is used or not (faster) - Checkbox
Filename (Textbox entry)
Start
Immediately
Delay XXX YYY SEC, MIN HR
On a specific date/time
Delay between each shot.... or at a specific time each day, etc....
e.g., Every XX YYY where XX is a number YYY is SEC, MIN, HR, DAY
e.g., On every MIN, 1/2 HR, HOUR
e.g., Every Day at XX:XX Time
When does the capture end
After XXX shots XXX from 1 to 1000?
After XXX minutes, Hours, Days
On XXXX date
Append a number or a date/time to 'Filename' - or both
Use Drop down ComboBox
e.g. Bill_1.jpg, Bill_2.jpg, ... etc
or Bill_Date_Time.jpg, Bill_Date_Time.jpg, ... etc
or both Bill_Date_Time_1.jpg, Bill_Date_Time_2.jpg, ... etc
What about video captures?
'''


'''
Examples from the picamera documentation
https://picamera.readthedocs.io/en/release-1.13/recipes1.html

The following script provides a brief example of configuring these settings:

from time import sleep
from picamera import PiCamera

camera = PiCamera(resolution=(1280, 720), framerate=30)
# Set ISO to the desired value
camera.iso = 100
# Wait for the automatic gain control to settle
sleep(2)
# Now fix the values
camera.shutter_speed = camera.exposure_speed
camera.exposure_mode = 'off'
g = camera.awb_gains
camera.awb_mode = 'off'
camera.awb_gains = g
# Finally, take several photos with the fixed settings
camera.capture_sequence(['image%02d.jpg' % i for i in range(10)])

from time import sleep
from picamera import PiCamera

camera = PiCamera()
camera.start_preview()
sleep(2)
for filename in camera.capture_continuous('img{counter:03d}.jpg'):
print('Captured %s' % filename)
sleep(300) # wait 5 minutes
'''

'''
from time import sleep
from picamera import PiCamera
from datetime import datetime, timedelta

def wait():
# Calculate the delay to the start of the next hour
next_hour = (datetime.now() + timedelta(hour=1)).replace(
minute=0, second=0, microsecond=0)
delay = (next_hour - datetime.now()).seconds
sleep(delay)

camera = PiCamera()
camera.start_preview()
wait()
for filename in camera.capture_continuous('img{timestamp:%Y-%m-%d-%H-%M}.jpg'):
print('Captured %s' % filename)
wait()


3.7. Capturing in low light
Using similar tricks to those in Capturing consistent images, the Pi’s
camera can capture images in low light conditions. The primary objective
is to set a high gain, and a long exposure time to allow the camera to
gather as much light as possible. However, the shutter_speed attribute
is constrained by the camera’s framerate so the first thing we need to
do is set a very slow framerate. The following script captures an image
with a 6 second exposure time (the maximum the Pi’s V1 camera module is
capable of; the V2 camera module can manage 10 second exposures):

from picamera import PiCamera
from time import sleep
from fractions import Fraction

# Force sensor mode 3 (the long exposure mode), set
# the framerate to 1/6fps, the shutter speed to 6s,
# and ISO to 800 (for maximum gain)
camera = PiCamera(
resolution=(1280, 720),
framerate=Fraction(1, 6),
sensor_mode=3)
camera.shutter_speed = 6000000
camera.iso = 800
# Give the camera a good long time to set gains and
# measure AWB (you may wish to use fixed AWB instead)
sleep(30)
camera.exposure_mode = 'off'
# Finally, capture an image with a 6s exposure. Due
# to mode switching on the still port, this will take
# longer than 6 seconds
camera.capture('dark.jpg')
'''
52 changes: 52 additions & 0 deletions Source/MotorControls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
# Timelapse.py
#
# Copyright 2018 Bill Williams
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
'''
from time import sleep
from Dialog import *
from Mapping import *
from NotePage import *

class MotorControls ( BasicNotepage ):
def BuildPage ( self ):
f = ttk.LabelFrame(self,text='Time lapse settings',padding=(5,5,5,5))
f.grid(row=0,column=0,columnspan=4,sticky='NEWS',pady=5)
f.columnconfigure(2,weight=1)
f.columnconfigure(4,weight=1)

Label(f,text='Default').grid(row=0,column=0,sticky='E')
self.LowLightCaptureButton = Button(f,text='Low Light',width=15, \
command=self.CaptureLowLight)
self.LowLightCaptureButton.grid(row=1,column=0,sticky='W')
self.StartDelayCaptureButton = Button(f,text='Delay Capture',width=15, \
command=self.StartDelayCapture)
self.StartDelayCaptureButton.grid(row=2,column=0,sticky='W')

def CaptureLowLight ( self ):
self.camera.capture('foo.jpg')
pass
def StartDelayCapture ( self ):
pass
#### TODO: Implement Reset NEEDS LOTS OF WORK!!
def Reset ( self ):
pass

2 changes: 1 addition & 1 deletion Source/PhotoParams.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
'''
'''
try:
from Tkinter import *
except ImportError:
Expand Down
Loading