Skip to content

Commit

Permalink
updating script examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrogers committed Oct 31, 2024
1 parent 165e7e5 commit f2fb184
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 12 deletions.
94 changes: 94 additions & 0 deletions examples/composite_scalars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import pycinema
import pycinema.filters
import pycinema.theater
import pycinema.theater.views

# pycinema settings
PYCINEMA = { 'VERSION' : '3.1.0'}

# filters
CinemaDatabaseReader_0 = pycinema.filters.CinemaDatabaseReader()
TableQuery_0 = pycinema.filters.TableQuery()
TableQuery_1 = pycinema.filters.TableQuery()
TableQuery_2 = pycinema.filters.TableQuery()
ImageReader_0 = pycinema.filters.ImageReader()
ImageReader_1 = pycinema.filters.ImageReader()
ImageReader_2 = pycinema.filters.ImageReader()
ColorMapping_0 = pycinema.filters.ColorMapping()
ColorMapping_1 = pycinema.filters.ColorMapping()
ColorMapping_2 = pycinema.filters.ColorMapping()
DepthCompositing_0 = pycinema.filters.DepthCompositing()
DepthCompositing_1 = pycinema.filters.DepthCompositing()
ImageView_0 = pycinema.filters.ImageView()
ImageView_1 = pycinema.filters.ImageView()

# properties
CinemaDatabaseReader_0.inputs.path.set("/Users/dhr/LANL/dev/cinemascience/pycinema/data/scalar-images.cdb", False)
CinemaDatabaseReader_0.inputs.file_column.set("FILE", False)
TableQuery_0.inputs.table.set(CinemaDatabaseReader_0.outputs.table, False)
TableQuery_0.inputs.sql.set("SELECT * FROM input WHERE object_id = 's1'", False)
TableQuery_1.inputs.table.set(CinemaDatabaseReader_0.outputs.table, False)
TableQuery_1.inputs.sql.set("SELECT * FROM input WHERE object_id = 's0'", False)
TableQuery_2.inputs.table.set(CinemaDatabaseReader_0.outputs.table, False)
TableQuery_2.inputs.sql.set("SELECT * FROM input WHERE object_id = 'p'", False)
ImageReader_0.inputs.table.set(TableQuery_2.outputs.table, False)
ImageReader_0.inputs.file_column.set("FILE", False)
ImageReader_0.inputs.cache.set(True, False)
ImageReader_1.inputs.table.set(TableQuery_1.outputs.table, False)
ImageReader_1.inputs.file_column.set("FILE", False)
ImageReader_1.inputs.cache.set(True, False)
ImageReader_2.inputs.table.set(TableQuery_0.outputs.table, False)
ImageReader_2.inputs.file_column.set("FILE", False)
ImageReader_2.inputs.cache.set(True, False)
ColorMapping_0.inputs.map.set("rainbow", False)
ColorMapping_0.inputs.nan.set((0, 0, 0, 0), False)
ColorMapping_0.inputs.range.set((-1, 1), False)
ColorMapping_0.inputs.channel.set("depth", False)
ColorMapping_0.inputs.images.set(ImageReader_0.outputs.images, False)
ColorMapping_0.inputs.composition_id.set(-1, False)
ColorMapping_1.inputs.map.set("plasma", False)
ColorMapping_1.inputs.nan.set((0, 0, 0, 0), False)
ColorMapping_1.inputs.range.set((-1, 1), False)
ColorMapping_1.inputs.channel.set("depth", False)
ColorMapping_1.inputs.images.set(ImageReader_1.outputs.images, False)
ColorMapping_1.inputs.composition_id.set(-1, False)
ColorMapping_2.inputs.map.set("gray", False)
ColorMapping_2.inputs.nan.set((0, 0, 0, 0), False)
ColorMapping_2.inputs.range.set((-1, 1), False)
ColorMapping_2.inputs.channel.set("depth", False)
ColorMapping_2.inputs.images.set(ImageReader_2.outputs.images, False)
ColorMapping_2.inputs.composition_id.set(-1, False)
DepthCompositing_0.inputs.images_a.set(ColorMapping_0.outputs.images, False)
DepthCompositing_0.inputs.images_b.set(ColorMapping_1.outputs.images, False)
DepthCompositing_0.inputs.depth_channel.set("depth", False)
DepthCompositing_0.inputs.compose.set((None, {}), False)
DepthCompositing_1.inputs.images_a.set(DepthCompositing_0.outputs.images, False)
DepthCompositing_1.inputs.images_b.set(ColorMapping_2.outputs.images, False)
DepthCompositing_1.inputs.depth_channel.set("depth", False)
DepthCompositing_1.inputs.compose.set((None, {}), False)
ImageView_0.inputs.images.set(DepthCompositing_1.outputs.images, False)
ImageView_0.inputs.selection.set([], False)
ImageView_1.inputs.images.set(DepthCompositing_0.outputs.images, False)
ImageView_1.inputs.selection.set([], False)

# layout
tabFrame1 = pycinema.theater.TabFrame()
splitFrame1 = pycinema.theater.SplitFrame()
splitFrame1.setHorizontalOrientation()
view1 = pycinema.theater.views.NodeEditorView()
splitFrame1.insertView( 0, view1 )
splitFrame1.setSizes([1464])
tabFrame1.insertTab(0, splitFrame1)
tabFrame1.setTabText(0, 'Layout 1')
splitFrame2 = pycinema.theater.SplitFrame()
splitFrame2.setHorizontalOrientation()
view2 = pycinema.theater.views.FilterView( ImageView_0 )
splitFrame2.insertView( 0, view2 )
splitFrame2.setSizes([1464])
tabFrame1.insertTab(1, splitFrame2)
tabFrame1.setTabText(1, 'Layout 2')
tabFrame1.setCurrentIndex(1)
pycinema.theater.Theater.instance.setCentralWidget(tabFrame1)

# execute pipeline
CinemaDatabaseReader_0.update()
4 changes: 2 additions & 2 deletions examples/scalar-images_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ elements:
- name: p
channel: depth
channelrange: [-1.0, 1.0]
colormap: gray
colormap: rainbow
nancolor: [0, 0, 0, 0]
- name: s0
channel: depth
Expand All @@ -23,5 +23,5 @@ elements:
- name: s1
channel: depth
channelrange: [-1.0, 1.0]
colormap: rainbow
colormap: gray
nancolor: [0, 0, 0, 0]
17 changes: 7 additions & 10 deletions scripts/cinematic
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,18 @@ class Composite:
for element in config['elements']:
self.elements.append(Element(self, element, config))

# composite
# composite each element together
curDepthCompositing = None
aImages = self.elements[0].outputs.images
if True:
for element in self.elements[1:]:
curDepthCompositing = pycinema.filters.DepthCompositing()
curDepthCompositing.inputs.images_a.set(aImages)
curDepthCompositing.inputs.images_b.set(element.outputs.images)
# remember output of compositor
aImages = curDepthCompositing.outputs.images
for element in self.elements[1:]:
curDepthCompositing = pycinema.filters.DepthCompositing()
curDepthCompositing.inputs.images_a.set(aImages)
curDepthCompositing.inputs.images_b.set(element.outputs.images)
# remember output of compositor
aImages = curDepthCompositing.outputs.images

# write the resulting images to a new cdb
self.writer = pycinema.filters.CinemaDatabaseWriter()
# self.writer.inputs.images.set(self.elements[0].output.images, False)
curDepthCompositing.update()
self.writer.inputs.images.set(curDepthCompositing.outputs.images, False)
self.writer.inputs.path.set(config['config']['output'], False)
self.writer.inputs.ignore.set(['^id', '^camera', '^FILE'], False)
Expand Down

0 comments on commit f2fb184

Please sign in to comment.