Changeset - a261a4bc97a0
[Not reviewed]
default
0 4 0
Drew Perttula - 8 years ago 2017-05-29 06:09:50
drewp@bigasterisk.com
straighten out LightSample schema
Ignore-this: 6ed550d64787303a9e8960cf8103f34c
4 files changed with 27 insertions and 18 deletions:
0 comments (0 inline, 0 general)
light9/paint/capture.py
Show inline comments
 
@@ -2,7 +2,7 @@ import os
 
from rdflib import URIRef
 
from light9 import showconfig
 
from light9.rdfdb.patch import Patch
 
from light9.namespaces import L9
 
from light9.namespaces import L9, RDF
 
from light9.paint.solve import loadNumpy
 

	
 
def writeCaptureDescription(graph, ctx, uri, dev, relOutPath, settingsSubgraphCache, settings):
 
@@ -12,6 +12,7 @@ def writeCaptureDescription(graph, ctx, 
 
        settingsSubgraphCache=settingsSubgraphCache)))
 
    graph.patch(Patch(addQuads=[
 
        (dev, L9['capture'], uri, ctx),
 
        (uri, RDF.type, L9['LightSample'], ctx),
 
        (uri, L9['imagePath'], URIRef('/'.join([showconfig.showUri(), relOutPath])), ctx),
 
        ]))
 
    
light9/paint/solve.py
Show inline comments
 
@@ -53,7 +53,7 @@ class Solver(object):
 
    def __init__(self, graph):
 
        self.graph = graph
 
        self.samples = {} # uri: Image array
 
        self.fromPath = {} # basename: image array
 
        self.fromPath = {} # imagePath: image array
 
        self.blurredSamples = {}
 
        self.sampleSettings = {} # (uri, path): DeviceSettings
 
        
 
@@ -62,12 +62,11 @@ class Solver(object):
 

	
 
        with self.graph.currentState() as g:
 
            for samp in g.subjects(RDF.type, L9['LightSample']):
 
                base = g.value(samp, L9['path']).toPython()
 
                path = 'show/dance2017/cam/test/%s' % base
 
                self.samples[samp] = self.fromPath[base] = loadNumpy(path)
 
                pathUri = g.value(samp, L9['imagePath'])
 
                self.samples[samp] = self.fromPath[pathUri] = loadNumpy(pathUri.replace(L9[''], ''))
 
                self.blurredSamples[samp] = self._blur(self.samples[samp])
 
                
 
                key = (samp, g.value(samp, L9['path']).toPython().encode('utf8'))
 
                key = (samp, pathUri)
 
                self.sampleSettings[key] = DeviceSettings.fromResource(self.graph, samp)
 

	
 
    def _blur(self, img):
light9/paint/solve_test.py
Show inline comments
 
import unittest
 
import numpy.testing
 
import solve
 
from rdflib import Namespace
 
from light9.namespaces import RDF, L9, DEV
 
from light9.rdfdb.localsyncedgraph import LocalSyncedGraph
 
from light9.effect.settings import DeviceSettings
 
@@ -31,6 +32,8 @@ class TestSolveBrute(TestSolve):
 
    def setUp(self):
 
        super(TestSolveBrute, self).setUp()
 
        self.solveMethod = self.solver.solveBrute
 

	
 
CAM_TEST = Namespace('http://light9.bigasterisk.com/show/dance2017/cam/test/')
 
        
 
class TestSimulationLayers(unittest.TestCase):
 
    def setUp(self):
 
@@ -49,14 +52,14 @@ class TestSimulationLayers(unittest.Test
 
            (DEV['aura1'], L9['color'], u"#ffffff"),
 
            (DEV['aura1'], L9['rx'], 0.5 ),
 
            (DEV['aura1'], L9['ry'], 0.573)]))
 
        self.assertEqual([{'path': 'bg2-d.jpg', 'color': (1., 1., 1.)}], layers)
 
        self.assertEqual([{'path': CAM_TEST['bg2-d.jpg'], 'color': (1., 1., 1.)}], layers)
 

	
 
    def testPerfect1MatchTinted(self):
 
        layers = self.solver.simulationLayers(settings=DeviceSettings(self.graph, [
 
            (DEV['aura1'], L9['color'], u"#304050"),
 
            (DEV['aura1'], L9['rx'], 0.5 ),
 
            (DEV['aura1'], L9['ry'], 0.573)]))
 
        self.assertEqual([{'path': 'bg2-d.jpg', 'color': (.188, .251, .314)}], layers)
 
        self.assertEqual([{'path': CAM_TEST['bg2-d.jpg'], 'color': (.188, .251, .314)}], layers)
 
        
 
    def testPerfect2Matches(self):
 
        layers = self.solver.simulationLayers(settings=DeviceSettings(self.graph, [
 
@@ -68,8 +71,8 @@ class TestSimulationLayers(unittest.Test
 
            (DEV['aura2'], L9['ry'], 0.573),
 
        ]))
 
        self.assertItemsEqual([
 
            {'path': 'bg2-d.jpg', 'color': (1, 1, 1)},
 
            {'path': 'bg2-f.jpg', 'color': (1, 1, 1)},
 
            {'path': CAM_TEST['bg2-d.jpg'], 'color': (1, 1, 1)},
 
            {'path': CAM_TEST['bg2-f.jpg'], 'color': (1, 1, 1)},
 
                      ], layers)
 

	
 
class TestCombineImages(unittest.TestCase):
 
@@ -80,8 +83,8 @@ class TestCombineImages(unittest.TestCas
 
        self.solver.loadSamples()
 
    def test(self):
 
        out = self.solver.combineImages(layers=[
 
            {'path': 'bg2-d.jpg', 'color': (.2, .2, .3)},
 
            {'path': 'bg2-a.jpg', 'color': (.888, 0, .3)},
 
            {'path': CAM_TEST['bg2-d.jpg'], 'color': (.2, .2, .3)},
 
            {'path': CAM_TEST['bg2-a.jpg'], 'color': (.888, 0, .3)},
 
        ])
 
        solve.saveNumpy('/tmp/t.png', out)
 
        golden = solve.loadNumpy('show/dance2017/cam/test/layers_out1.png')
show/dance2017/cam/test/bg.n3
Show inline comments
 
@@ -8,33 +8,39 @@
 
@prefix set: <http://light9.bigasterisk.com/setting/> .
 

	
 

	
 
:sample0 a :LightSample; :path "bg2-a.jpg"; :setting 
 
:sample0 a :LightSample; :imagePath <http://light9.bigasterisk.com/show/dance2017/cam/test/bg2-a.jpg>;
 
 :setting 
 
[ :device dev:aura1; :deviceAttr :color;  :scaledValue "#ffffff" ],
 
[ :device dev:aura1; :deviceAttr :rx;     :value 0.2 ],
 
[ :device dev:aura1; :deviceAttr :ry;     :value 0.573 ] .
 

	
 
:sample1 a :LightSample; :path "bg2-b.jpg"; :setting 
 
:sample1 a :LightSample; :imagePath <http://light9.bigasterisk.com/show/dance2017/cam/test/bg2-b.jpg>;
 
 :setting 
 
[ :device dev:aura1; :deviceAttr :color;  :scaledValue "#ffffff" ],
 
[ :device dev:aura1; :deviceAttr :rx;     :value 0.3 ],
 
[ :device dev:aura1; :deviceAttr :ry;     :value 0.573 ] .
 

	
 
:sample2 a :LightSample; :path "bg2-c.jpg"; :setting 
 
:sample2 a :LightSample; :imagePath <http://light9.bigasterisk.com/show/dance2017/cam/test/bg2-c.jpg>;
 
 :setting 
 
[ :device dev:aura1; :deviceAttr :color;  :scaledValue "#ffffff" ],
 
[ :device dev:aura1; :deviceAttr :rx;     :value 0.4 ],
 
[ :device dev:aura1; :deviceAttr :ry;     :value 0.573 ] .
 

	
 
:sample3 a :LightSample; :path "bg2-d.jpg"; :setting 
 
:sample3 a :LightSample; :imagePath <http://light9.bigasterisk.com/show/dance2017/cam/test/bg2-d.jpg>;
 
 :setting 
 
[ :device dev:aura1; :deviceAttr :color;  :scaledValue "#ffffff" ],
 
[ :device dev:aura1; :deviceAttr :rx;     :value 0.5 ],
 
[ :device dev:aura1; :deviceAttr :ry;     :value 0.573 ] .
 

	
 
:sample4 a :LightSample; :path "bg2-e.jpg"; :setting 
 
:sample4 a :LightSample; :imagePath <http://light9.bigasterisk.com/show/dance2017/cam/test/bg2-e.jpg>;
 
 :setting 
 
[ :device dev:aura1; :deviceAttr :color;  :scaledValue "#ffffff" ],
 
[ :device dev:aura1; :deviceAttr :rx;     :value 0.6 ],
 
[ :device dev:aura1; :deviceAttr :ry;     :value 0.573 ] .
 

	
 
# note: different device
 
:sample5 a :LightSample; :path "bg2-f.jpg"; :setting 
 
:sample5 a :LightSample; :imagePath <http://light9.bigasterisk.com/show/dance2017/cam/test/bg2-f.jpg>;
 
 :setting 
 
[ :device dev:aura2; :deviceAttr :color;  :scaledValue "#ffffff" ],
 
[ :device dev:aura2; :deviceAttr :rx;     :value 0.7 ],
 
[ :device dev:aura2; :deviceAttr :ry;     :value 0.573 ] .
0 comments (0 inline, 0 general)