Skip to content

Commit

Permalink
Fix to build basel-face-model-viewer #15 (#16)
Browse files Browse the repository at this point in the history
* Update the scala version to 2.13.0
Update the scalismo-faces version to 0.90.0
Fix 2.13 warning

Signed-off-by: wolfviking0 <[email protected]>

* Fix IntelliJ warning

Signed-off-by: Anthony Liot <[email protected]>

Co-authored-by: Anthony Liot <[email protected]>
  • Loading branch information
wolfviking0 and Anthony Liot authored May 6, 2021
1 parent 014edcf commit 63697df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name := """model-viewer"""
version := "1.0"

scalaVersion := "2.11.12"
scalaVersion := "2.13.0"

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

resolvers += Resolver.jcenterRepo

resolvers += Resolver.bintrayRepo("unibas-gravis", "maven")

libraryDependencies += "ch.unibas.cs.gravis" %% "scalismo-faces" % "0.9.2+"
libraryDependencies += "ch.unibas.cs.gravis" %% "scalismo-faces" % "0.90.0"

mainClass in assembly := Some("faces.apps.ModelViewer")

Expand Down
20 changes: 10 additions & 10 deletions src/main/scala/faces/apps/ModelViewer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,28 @@

import java.awt.Dimension
import java.io.{File, IOException}

import javax.swing._
import javax.swing.event.{ChangeEvent, ChangeListener}
import breeze.linalg.min
import scalismo.color.{RGB, RGBA}
import scalismo.faces.gui.{GUIBlock, GUIFrame, ImagePanel}
import scalismo.faces.gui.GUIBlock._
import scalismo.faces.parameters.RenderParameter
import scalismo.faces.io.{MeshIO, MoMoIO, PixelImageIO, RenderParameterIO}
import scalismo.faces.sampling.face.MoMoRenderer
import scalismo.faces.color.RGB
import scalismo.faces.image.PixelImage
import scalismo.utils.Random
import scalismo.faces.color.RGBA
import scalismo.faces.momo.MoMo

import scala.math.Ordering.Double
import scala.reflect.io.Path
import scala.util.{Failure, Try}

object ModelViewer extends App {

final val DEFAULT_DIR = new File(".")

val modelFile: Option[File] = getModelFile(args)
val modelFile: Option[File] = getModelFile(args.toIndexedSeq)
modelFile.map(SimpleModelViewer(_))

private def getModelFile(args: Seq[String]): Option[File] = {
Expand Down Expand Up @@ -131,9 +130,9 @@ case class SimpleModelViewer(
(value / maximalSigma * sliderSteps).toInt
}

val bg = PixelImage(imageWidth, imageHeight, (_, _) => RGBA.Black)
val bg: PixelImage[RGBA] = PixelImage(imageWidth, imageHeight, (_, _) => RGBA.Black)

val imageWindow = ImagePanel(renderWithBG(init))
val imageWindow: ImagePanel[RGB] = ImagePanel(renderWithBG(init))

//--- SHAPE -----
val shapeSlider: IndexedSeq[JSlider] = for (n <- 0 until shapeRank) yield {
Expand Down Expand Up @@ -323,13 +322,13 @@ case class SimpleModelViewer(
else renderer = MoMoRenderer(model, RGBA.BlackTransparent).cached(5)

showExpressionModel = !showExpressionModel
updateToggleExpressioButton()
updateToggleExpressionButton()
addRemoveExpressionTab()
updateImage()
}
})

def updateToggleExpressioButton(): Unit = {
def updateToggleExpressionButton(): Unit = {
if ( showExpressionModel ) toggleExpressionButton.setText("expressions off")
else toggleExpressionButton.setText("expressions on")
}
Expand All @@ -355,7 +354,7 @@ case class SimpleModelViewer(
if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
var file = fc.getSelectedFile
if (file.isDirectory) file = new File(file,"instance.ply")
if ( !file.getName.endsWith(".ply")) file = new File( file+".ply")
if ( !file.getName.endsWith(".ply")) file = new File( file.getAbsolutePath+".ply")
if (!file.exists() || askToOverwrite(file)) {
MeshIO.write(VCM3D, file)
} else {
Expand All @@ -382,7 +381,7 @@ case class SimpleModelViewer(
if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
var file = fc.getSelectedFile
if (file.isDirectory) file = new File(file,"instance.png")
if ( !file.getName.endsWith(".png")) file = new File( file+".png")
if ( !file.getName.endsWith(".png")) file = new File( file.getAbsolutePath+".png")
if (!file.exists() || askToOverwrite(file)) {
PixelImageIO.write(img, file)
} else {
Expand Down Expand Up @@ -446,6 +445,7 @@ case class SimpleModelViewer(
{
for {rpsFile <- askUserForRPSFile(new File("."))
rpsParams <- RenderParameterIO.read(rpsFile)} {
implicit val order: Double.TotalOrdering.type = Ordering.Double.TotalOrdering
val maxSigma = (rpsParams.momo.shape ++ rpsParams.momo.color ++ rpsParams.momo.expression).map(math.abs).max
if ( maxSigma > maximalSigma ) {
maximalSigma = math.ceil(maxSigma).toInt
Expand Down

0 comments on commit 63697df

Please sign in to comment.