changeset 1574:a261a4bc97a0

straighten out LightSample schema Ignore-this: 6ed550d64787303a9e8960cf8103f34c
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 29 May 2017 06:09:50 +0000
parents 20f48a0e7135
children 0d2247ec8f49
files light9/paint/capture.py light9/paint/solve.py light9/paint/solve_test.py show/dance2017/cam/test/bg.n3
diffstat 4 files changed, 27 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/light9/paint/capture.py	Sun May 28 09:05:37 2017 +0000
+++ b/light9/paint/capture.py	Mon May 29 06:09:50 2017 +0000
@@ -2,7 +2,7 @@
 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 @@
         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),
         ]))
     
--- a/light9/paint/solve.py	Sun May 28 09:05:37 2017 +0000
+++ b/light9/paint/solve.py	Mon May 29 06:09:50 2017 +0000
@@ -53,7 +53,7 @@
     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 @@
 
         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):
--- a/light9/paint/solve_test.py	Sun May 28 09:05:37 2017 +0000
+++ b/light9/paint/solve_test.py	Mon May 29 06:09:50 2017 +0000
@@ -1,6 +1,7 @@
 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 @@
     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 @@
             (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 @@
             (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 @@
         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')
--- a/show/dance2017/cam/test/bg.n3	Sun May 28 09:05:37 2017 +0000
+++ b/show/dance2017/cam/test/bg.n3	Mon May 29 06:09:50 2017 +0000
@@ -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 ] .