From f2fb184e979fb031120d63554d6054539b288dc3 Mon Sep 17 00:00:00 2001 From: "David H. Rogers" Date: Thu, 31 Oct 2024 10:20:32 -0600 Subject: [PATCH] updating script examples --- examples/composite_scalars.py | 94 ++++++++++++++++++++++++++++++ examples/scalar-images_config.yaml | 4 +- scripts/cinematic | 17 +++--- 3 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 examples/composite_scalars.py diff --git a/examples/composite_scalars.py b/examples/composite_scalars.py new file mode 100644 index 0000000..055d19b --- /dev/null +++ b/examples/composite_scalars.py @@ -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() diff --git a/examples/scalar-images_config.yaml b/examples/scalar-images_config.yaml index 308e9aa..9103fc8 100644 --- a/examples/scalar-images_config.yaml +++ b/examples/scalar-images_config.yaml @@ -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 @@ -23,5 +23,5 @@ elements: - name: s1 channel: depth channelrange: [-1.0, 1.0] - colormap: rainbow + colormap: gray nancolor: [0, 0, 0, 0] diff --git a/scripts/cinematic b/scripts/cinematic index 825c5f8..b382a50 100755 --- a/scripts/cinematic +++ b/scripts/cinematic @@ -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)