Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video producer tool using benchmarks in BDV #136

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
# bigdataviewer-core

[![](https://api.github.com/bigdataviewer/bigdataviewer-core/actions/workflows/build-main.yml/badge.svg)](https://github.com/bigdataviewer/bigdataviewer-core/actions/workflows/build-main.yml)

[![Join the chat at https://gitter.im/bigdataviewer/bigdataviewer-core](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bigdataviewer/bigdataviewer-core?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ImgLib2-based viewer for registered SPIM stacks and more
---
Feature added in this fork: **Interactive Video producing using Spline interpolation**

### Install:
`$ ./install.sh`

### Run:
`$ ./bdv INPUT_PATH`
Comment on lines +9 to +13
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention Windows install instructions or recommend WSL2.


### How to use:

1- **Video producer panel** can be opened by clicking `F7` or via `Tools -> Produce Movie`
![](img/1.png)

2- By opening Video Producer you get this panel
![](img/2.png)
- `+` To add current frame
- `-` To delete last frame
- Preview with a frame down-sampling and sleep time between frames
- Accel: you select the interpolation: `Slow start` , `slow end` , `Symmetric` ...
- Export: Can be in `Json` or `PNG sequence`
- Import saved `Json`
=======
[![developer chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://imagesc.zulipchat.com/#narrow/stream/327326-BigDataViewer)

ImgLib2-based viewer for registered SPIM stacks and more

Binary file added img/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# This script is shamelessly adapted from https://github.com/saalfeldlab/n5-utils, thanks @axtimwalde & co!

VERSION="10.3.2-SNAPSHOT"
INSTALL_DIR=${1:-$(pwd)}

echo ""
echo "Installing into $INSTALL_DIR"

# check for operating system
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "Assuming on Linux operating system"
MEM=$(cat /proc/meminfo | grep MemTotal | sed s/^MemTotal:\\\s*\\\|\\\s\\+[^\\\s]*$//g)
MEMGB=$(($MEM/1024/1024))
MEM=$((($MEMGB/5)*4))
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Assuming on MacOS X operating system"
# sysctl returns total hardware memory size in bytes
MEM=$(sysctl hw.memsize | grep hw.memsize | sed s/hw.memsize://g)
MEMGB=$(($MEM/1024/1024/1024))
MEM=$((($MEMGB/5)*4))
else
echo "ERROR - Operating system (arg2) must be either linux or osx - EXITING (on windows please run as a normal Java class from e.g. Eclipse)"
exit
fi

echo "Available memory:" $MEMGB "GB, setting Java memory limit to" $MEM "GB"

mvn clean install
mvn -Dmdep.outputFile=cp.txt -Dmdep.includeScope=runtime dependency:build-classpath

echo ""
echo "Installing 'bdv' command into" $INSTALL_DIR

echo '#!/bin/bash' > bdv
echo '' >> bdv
echo "JAR=\$HOME/.m2/repository/sc/fiji/bigdataviewer-core/${VERSION}/bigdataviewer-core-${VERSION}.jar" >> bdv
echo 'java \' >> bdv
echo " -Xmx${MEM}g \\" >> bdv
echo ' -XX:+UseConcMarkSweepGC \' >> bdv
echo -n ' -cp $JAR:' >> bdv
echo -n $(cat cp.txt) >> bdv
echo ' \' >> bdv
echo ' bdv.BigDataViewer "$@"' >> bdv


chmod a+x bdv

if [ $(pwd) == "$INSTALL_DIR" ]; then
echo "Installation directory equals current directory, we are done."
else
echo "Creating directory $INSTALL_DIR and moving files..."
mkdir -p $INSTALL_DIR
mv bdv $INSTALL_DIR/
fi

rm cp.txt

echo "Installation finished."
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
</repositories>

<dependencies>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij</artifactId>
</dependency>
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2</artifactId>
Expand Down Expand Up @@ -197,6 +201,11 @@
<groupId>com.miglayout</groupId>
<artifactId>miglayout-swing</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make the version a property? Any reason not to use 2.8.6 like in parent POM?

https://github.com/scijava/pom-scijava/blob/ff35ca810a8717c4f461ef24df4986bf1914c673/pom.xml#L1508-L1509

</dependency>
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf</artifactId>
Expand Down
48 changes: 45 additions & 3 deletions src/main/java/bdv/BigDataViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand All @@ -29,6 +29,7 @@
package bdv;

import bdv.tools.PreferencesDialog;
import bdv.tools.movie.ProduceMovieDialog;
import bdv.ui.UIUtils;
import bdv.ui.keymap.Keymap;
import bdv.ui.keymap.KeymapManager;
Expand Down Expand Up @@ -107,6 +108,7 @@
import mpicbg.spim.data.sequence.Channel;
import org.scijava.ui.behaviour.util.Actions;


public class BigDataViewer
{
public static String configDir = ProjectDirectories.from( "sc", "fiji", "bigdataviewer" ).configDir;
Expand All @@ -127,6 +129,8 @@ public class BigDataViewer

protected final RecordMovieDialog movieDialog;

protected final ProduceMovieDialog produceMovieDialog;

protected final RecordMaxProjectionDialog movieMaxProjectDialog;

protected final VisibilityAndGroupingDialog activeSourcesDialog;
Expand Down Expand Up @@ -398,6 +402,8 @@ public BigDataViewer(
cropDialog = ( spimData == null ) ? null : new CropDialog( viewerFrame, viewer, spimData.getSequenceDescription() );

movieDialog = new RecordMovieDialog( viewerFrame, viewer, progressWriter );

produceMovieDialog = new ProduceMovieDialog( viewerFrame, viewer, progressWriter );
// this is just to get updates of window size:
viewer.getDisplay().overlays().add( movieDialog );

Expand Down Expand Up @@ -502,6 +508,10 @@ public boolean accept( final File f )
miMovie.setText( "Record Movie" );
menu.add( miMovie );

final JMenuItem miMovieProducer = new JMenuItem( actionMap.get( BigDataViewerActions.PRODUCE_MOVIE ) );
miMovieProducer.setText( "Produce Movie" );
menu.add( miMovieProducer );

final JMenuItem miMaxProjectMovie = new JMenuItem( actionMap.get( BigDataViewerActions.RECORD_MAX_PROJECTION_MOVIE ) );
miMaxProjectMovie.setText( "Record Max-Projection Movie" );
menu.add( miMaxProjectMovie );
Expand Down Expand Up @@ -775,20 +785,52 @@ public void collapseCardPanel()

public static void main( final String[] args )
{
final String fn = "/Users/pietzsch/workspace/data/111010_weber_resave.xml";
// final String fn = "http://tomancak-mac-17.mpi-cbg.de:8080/openspim/";
// final String fn = "/Users/Pietzsch/Desktop/openspim/datasetHDF.xml";
// final String fn = "/Users/pietzsch/workspace/data/111010_weber_full.xml";
// final String fn = "/Users/Pietzsch/Desktop/spimrec2/dataset.xml";
// final String fn = "/Users/pietzsch/Desktop/HisYFP-SPIM/dataset.xml";
// final String fn = "/Users/Pietzsch/Desktop/bdv example/drosophila 2.xml";
// final String fn = "/Users/pietzsch/Desktop/data/clusterValia/140219-1/valia-140219-1.xml";
// final String fn = "/Users/Pietzsch/Desktop/data/catmaid.xml";
// final String fn = "src/main/resources/openconnectome-bock11-neariso.xml";
// final String fn = "/home/saalfeld/catmaid.xml";
// final String fn = "/home/saalfeld/catmaid-fafb00-v9.xml";
// final String fn = "/home/saalfeld/catmaid-fafb00-sample_A_cutout_3k.xml";
// final String fn = "/home/saalfeld/catmaid-thorsten.xml";
// final String fn = "/home/saalfeld/knossos-example.xml";
// final String fn = "/Users/Pietzsch/Desktop/data/catmaid-confocal.xml";
// final String fn = "/Users/pietzsch/desktop/data/BDV130418A325/BDV130418A325_NoTempReg.xml";
// final String fn = "/Users/pietzsch/Desktop/data/valia2/valia.xml";
// final String fn = "/Users/pietzsch/workspace/data/fast fly/111010_weber/combined.xml";
// final String fn = "/Users/pietzsch/workspace/data/mette/mette.xml";
// final String fn = "/Users/tobias/Desktop/openspim.xml";
// final String fn = "/Users/pietzsch/Desktop/data/fibsem.xml";
// final String fn = "/Users/pietzsch/Desktop/data/fibsem-remote.xml";
// final String fn = "/Users/pietzsch/Desktop/url-valia.xml";
// final String fn = "/Users/pietzsch/Desktop/data/clusterValia/140219-1/valia-140219-1.xml";
// final String fn = "/Users/pietzsch/workspace/data/111010_weber_full.xml";
// final String fn = "/Volumes/projects/tomancak_lightsheet/Mette/ZeissZ1SPIM/Maritigrella/021013_McH2BsGFP_CAAX-mCherry/11-use/hdf5/021013_McH2BsGFP_CAAX-mCherry-11-use.xml";

// final String fn = "/Users/Marwan/Downloads/drosophila_his-yfp/dataset.xml";

try
{
final String fn = args[0];
System.setProperty( "apple.laf.useScreenMenuBar", "true" );
// System.setProperty( "apple.awt.application.appearance", "system" );
UIUtils.installFlatLafInfos();

System.out.println( "reading config files from \"" + configDir + "\"" );
final BigDataViewer bdv = open( fn, new File( fn ).getName(), new ProgressWriterConsole(), ViewerOptions.options() );

// PanelSnapshot.showPanel(bdv.getViewer());
// DumpInputConfig.writeToYaml( System.getProperty( "user.home" ) + "/.bdv/bdvkeyconfig.yaml", bdv.getViewerFrame() );
}
catch ( final Exception e )
{
if (args.length==0)
System.out.println("Please specify the input");
e.printStackTrace();
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/bdv/BigDataViewerActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand Down Expand Up @@ -62,6 +62,7 @@ public class BigDataViewerActions extends Actions
public static final String EXPAND_CARDS = "expand and focus cards panel";
public static final String COLLAPSE_CARDS = "collapse cards panel";
public static final String RECORD_MOVIE = "record movie";
public static final String PRODUCE_MOVIE = "produce movie";
public static final String RECORD_MAX_PROJECTION_MOVIE = "record max projection movie";
public static final String SET_BOOKMARK = "set bookmark";
public static final String GO_TO_BOOKMARK = "go to bookmark";
Expand All @@ -72,6 +73,7 @@ public class BigDataViewerActions extends Actions
public static final String[] VISIBILITY_AND_GROUPING_KEYS = new String[] { "F6" };
public static final String[] SHOW_HELP_KEYS = new String[] { "F1", "H" };
public static final String[] CROP_KEYS = new String[] { "F9" };
public static final String[] PRODUCE_MOVIE_KEYS = new String[] { "F7" };
public static final String[] MANUAL_TRANSFORM_KEYS = new String[] { "T" };
public static final String[] SAVE_SETTINGS_KEYS = new String[] { "F11" };
public static final String[] LOAD_SETTINGS_KEYS = new String[] { "F12" };
Expand Down Expand Up @@ -132,6 +134,7 @@ public static void install( final Actions actions, final BigDataViewer bdv )
toggleDialogAction( actions, bdv.helpDialog, SHOW_HELP, SHOW_HELP_KEYS );
toggleDialogAction( actions, bdv.cropDialog, CROP, CROP_KEYS );
toggleDialogAction( actions, bdv.movieDialog, RECORD_MOVIE, RECORD_MOVIE_KEYS );
toggleDialogAction( actions, bdv.produceMovieDialog, PRODUCE_MOVIE, PRODUCE_MOVIE_KEYS );
toggleDialogAction( actions, bdv.movieMaxProjectDialog, RECORD_MAX_PROJECTION_MOVIE, RECORD_MAX_PROJECTION_MOVIE_KEYS );
toggleDialogAction( actions, bdv.preferencesDialog, PREFERENCES_DIALOG, PREFERENCES_DIALOG_KEYS );
bookmarks( actions, bdv.bookmarkEditor );
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/bdv/tools/movie/ImagePanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package bdv.tools.movie;

import javax.swing.*;
import java.awt.*;
Comment on lines +3 to +4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wildcards?

import java.awt.image.BufferedImage;

public class ImagePanel extends JPanel {
private final BufferedImage image;

public ImagePanel(BufferedImage image) {
super();
setPreferredSize(new Dimension(90, 90));
this.image = scale(image, 90, 90);
}

public static ImagePanel snapshotOf(JPanel panel) {
return new ImagePanel(takeSnapShot(panel));
}

@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, this);
}

public static BufferedImage scale(BufferedImage src, int w, int h) {
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
int x, y;
int ww = src.getWidth();
int hh = src.getHeight();
int[] ys = new int[h];
for (y = 0; y < h; y++)
ys[y] = y * hh / h;
for (x = 0; x < w; x++) {
int newX = x * ww / w;
for (y = 0; y < h; y++) {
int col = src.getRGB(newX, ys[y]);
img.setRGB(x, y, col);
}
}
return img;
}

public static BufferedImage takeSnapShot(JPanel panel){
BufferedImage bufImage = new BufferedImage(panel.getSize().width, panel.getSize().height,BufferedImage.TYPE_INT_RGB);
panel.paint(bufImage.createGraphics());
return bufImage;
}
}
67 changes: 67 additions & 0 deletions src/main/java/bdv/tools/movie/MovieFrame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package bdv.tools.movie;

import net.imglib2.realtransform.AffineTransform3D;

import java.io.Serializable;

public class MovieFrame implements Serializable {
private AffineTransform3D transform;

private int position;
private int frames;
private int accel;
private final static int DEFAULT_FRAMES = 120;
private final static int DEFAULT_ACCEL = 0;


public MovieFrame(int position, AffineTransform3D transform) {
this(position, transform, ((position == 0) ? 0 : DEFAULT_FRAMES), ((position == 0) ? 0 : DEFAULT_ACCEL));
}

public MovieFrame(int position, AffineTransform3D transform, int frames, int accel) {
this.position = position;
this.transform = transform;
this.frames = frames;
this.accel = accel;
}

public AffineTransform3D getTransform() {
return transform;
}

public void setTransform(AffineTransform3D transform) {
this.transform = transform;
}

public int getPosition() {
return position;
}

public void setPosition(int position) {
this.position = position;
}

public int getFrames() {
return frames;
}

public void setFrames(int frames) {
this.frames = frames;
}

public int getAccel() {
return accel;
}

public void setAccel(int accel) {
this.accel = accel;
}

public static int getDefaultFrames() {
return DEFAULT_FRAMES;
}

public static int getDefaultAccel() {
return DEFAULT_ACCEL;
}
}
Loading