Changeset - 95b03a865879
[Not reviewed]
default
0 6 0
Drew Perttula - 11 years ago 2014-06-05 07:42:58
drewp@bigasterisk.com
picamserve networking config. fix snapshot system
Ignore-this: a886b8f63c40cf47614265c16877ecf2
6 files changed with 31 insertions and 6 deletions:
0 comments (0 inline, 0 general)
light9/networking.py
Show inline comments
 
@@ -38,6 +38,7 @@ dmxServer = ServiceAddress(L9['dmxServer
 
oscDmxServer = ServiceAddress(L9['oscDmxServer'])
 
musicPlayer = ServiceAddress(L9['musicPlayer'])
 
keyboardComposer = ServiceAddress(L9['keyboardComposer'])
 
curveCalc = ServiceAddress(L9['curveCalc'])
 
vidref = ServiceAddress(L9['vidref'])
 
effectEval = ServiceAddress(L9['effectEval'])
 
picamserve = ServiceAddress(L9['picamserve'])
light9/subserver/style.css
Show inline comments
 
@@ -35,14 +35,14 @@ a.resource {
 
    vertical-align: top;
 
}
 
.sub.local {
 
    background: rgb(44, 44, 44);
 
}
 
.sub img {
 
    width: 180px;
 
    height: 90px;
 
    width: 196px;
 
    min-height: 40px;
 
    margin: 6px;
 
    background: -webkit-gradient(linear,right top,left bottom,color-stop(0,rgb(121, 120, 120)),color-stop(1,rgb(54, 54, 54)));
 
}
 

	
 
input[type=text] {
 
    border: 1px inset rgb(177, 177, 177);
light9/vidref/main.py
Show inline comments
 
@@ -6,12 +6,13 @@ dvcam test
 
gst-launch dv1394src ! dvdemux name=d ! dvdec ! ffmpegcolorspace ! hqdn3d ! xvimagesink
 

	
 
"""
 
import gobject, logging, traceback
 
import gtk
 
from twisted.python.util import sibpath
 
from light9 import networking
 
from light9.vidref.replay import ReplayViews, framerate
 
from light9.vidref.musictime import MusicTime
 
from light9.vidref.videorecorder import Pipeline
 
from light9.vidref import remotepivideo
 
log = logging.getLogger()
 

	
 
@@ -47,13 +48,13 @@ class Gui(object):
 
                recordingTo=self.recordingTo)
 
        else:
 
            self.pipeline = remotepivideo.Pipeline(
 
                liveVideo=vid3,
 
                musicTime=self.musicTime,
 
                recordingTo=self.recordingTo,
 
                picsUrl='http://10.1.0.125:8001/pics?res=1080&resize=450&x=0&y=.3&w=1&h=.5&awb_mode=auto&exposure_mode=auto')
 
                picsUrl=networking.picamserve.path('pics?res=1080&resize=450&x=0&y=.3&w=1&h=.5&awb_mode=auto&exposure_mode=auto'))
 

	
 
        vid3.props.width_request = 360
 
        vid3.props.height_request = 220
 
        wtree.get_object("frame1").props.height_request = 220
 
        
 

	
light9/vidref/musictime.py
Show inline comments
 
@@ -28,23 +28,27 @@ class MusicTime(object):
 

	
 
        self.position = {}
 
        self.lastHoverTime = None # None means "no recent value"
 
        self.pollMusicTime()
 
        self.pollCurvecalcTime()
 

	
 
    def getLatest(self):
 
    def getLatest(self, frameTime=None):
 
        """
 
        dict with 't' and 'song', etc.
 

	
 
        frameTime is the timestamp from the camera, which will be used
 
        instead of now.
 

	
 
        Note that this may be called in a gst camera capture thread. Very often.
 
        """
 
        if not hasattr(self, 'position'):
 
            return {'t' : 0, 'song' : None}
 
        pos = self.position.copy()
 
        now = frameTime or time.time()
 
        if pos.get('playing'):
 
            pos['t'] = pos['t'] + (time.time() - self.positionFetchTime)
 
            pos['t'] = pos['t'] + (now - self.positionFetchTime)
 
        else:
 
            if self.lastHoverTime is not None:
 
                pos['hoverTime'] = self.lastHoverTime
 
        return pos
 

	
 
    def pollMusicTime(self):
light9/vidref/remotepivideo.py
Show inline comments
 
@@ -2,12 +2,13 @@
 
like videorecorder.py, but talks to a bin/picamserve instance
 
"""
 
import os, time, logging
 
import gtk
 
import numpy
 
import treq
 
from twisted.internet import defer
 
from light9.vidref.replay import framerate, songDir, takeDir, snapshotDir
 
from light9 import prof
 
from PIL import Image
 
from StringIO import StringIO
 
log = logging.getLogger('remotepi')
 

	
 
@@ -18,12 +19,14 @@ class Pipeline(object):
 

	
 
        self.liveVideo = self._replaceLiveVideoWidget(liveVideo)
 
        
 
        self._startRequest(picsUrl)
 
        self._buffer = ''
 

	
 
        self._snapshotRequests = []
 

	
 
    def _replaceLiveVideoWidget(self, liveVideo):
 
        aspectFrame = liveVideo.get_parent()
 
        liveVideo.destroy()
 
        img = gtk.Image()
 
        img.set_visible(True)
 
        #img.set_size_request(320, 240)
 
@@ -52,22 +55,37 @@ class Pipeline(object):
 
    def snapshot(self):
 
        """
 
        returns deferred to the path (which is under snapshotDir()) where
 
        we saved the image.
 
        """
 
        filename = "%s/%s.jpg" % (snapshotDir(), time.time())
 
        return
 
        d = defer.Deferred()
 
        self._snapshotRequests.append((d, filename))
 
        return d
 

	
 
    def setInput(self, name):
 
        pass
 

	
 
    def setLiveVideo(self, on):
 
        print "setLiveVideo", on
 

	
 
    def onFrame(self, jpg, frameTime):
 
        # We could pass frameTime here to try to compensate for lag,
 
        # but it ended up looking worse in a test. One suspect is the
 
        # rpi clock drift might be worse than the lag. The value of
 
        # (now - frameTime) stutters regularly between 40ms, 140ms,
 
        # and 200ms.
 
        position = self.musicTime.getLatest()
 

	
 
        for d, filename in self._snapshotRequests:
 
            with open(filename, 'w') as out:
 
                out.write(jpg)
 
            d.callback(filename)
 
        self._snapshotRequests[:] = []
 
            
 
        
 
        if not position['song']:
 
            self.updateLiveFromTemp(jpg)
 
            return 
 
        outDir = takeDir(songDir(position['song']), position['started'])
 
        outFilename = "%s/%08.03f.jpg" % (outDir, position['t'])
 
        if os.path.exists(outFilename): # we're paused on one time
show/dance2014/networking.n3
Show inline comments
 
@@ -7,7 +7,8 @@ sh:netHome
 
  :effectEval       <http://dash:8070/>;
 
  :musicPlayer      <http://dash:8040/>;
 
  :dmxServer        <http://dash:8030/>;
 
  :oscDmxServer     <udp://dash:9050/>;
 
  :curveCalc        <http://dash:8060/>;
 
  :keyboardComposer <http://dash:8050/>;
 
  :picamserve       <http://10.1.0.125:8001/>;
 
  :vidref           <http://dash:8053/> .
0 comments (0 inline, 0 general)