diff --git a/light9/paint/capture.py b/light9/paint/capture.py
--- a/light9/paint/capture.py
+++ b/light9/paint/capture.py
@@ -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),
]))
diff --git a/light9/paint/solve.py b/light9/paint/solve.py
--- a/light9/paint/solve.py
+++ b/light9/paint/solve.py
@@ -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):
diff --git a/light9/paint/solve_test.py b/light9/paint/solve_test.py
--- a/light9/paint/solve_test.py
+++ b/light9/paint/solve_test.py
@@ -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 @@ 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')
diff --git a/show/dance2017/cam/test/bg.n3 b/show/dance2017/cam/test/bg.n3
--- a/show/dance2017/cam/test/bg.n3
+++ b/show/dance2017/cam/test/bg.n3
@@ -8,33 +8,39 @@
@prefix set: .
-:sample0 a :LightSample; :path "bg2-a.jpg"; :setting
+:sample0 a :LightSample; :imagePath ;
+ :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 ;
+ :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 ;
+ :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 ;
+ :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 ;
+ :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 ;
+ :setting
[ :device dev:aura2; :deviceAttr :color; :scaledValue "#ffffff" ],
[ :device dev:aura2; :deviceAttr :rx; :value 0.7 ],
[ :device dev:aura2; :deviceAttr :ry; :value 0.573 ] .