![](/img/trans.png)
[英]How to fix java.lang.ClassCastException: cannot assign instance of scala.collection.immutable.List to field type scala.collection.Seq?
[英]How can I fix mismatch error in scala where the found : Seq[scala.collection.immutable.Seq required: scala.collection.Seq?
这是错误:
<console>:123: error: type mismatch;
found : Seq[scala.collection.immutable.Seq[scalismo.geometry.Landmark[scalismo.geometry._3D]]]
required: scala.collection.Seq[scalismo.geometry.Landmark[scalismo.geometry._3D]]
val rigidTrans = LandmarkRegistration.rigid3DLandmarkRegistration(landmarks, reflandmarks.toSeq)
在代码片段之后:
val alignedSet = toAlign.map { mesh =>
val landmarks = pointIds.map{id => Landmark("L_"+id, mesh.point(PointId(id)))}
val rigidTrans = LandmarkRegistration.rigid3DLandmarkRegistration(landmarks, reflandmarks.toSeq)
mesh.transform(rigidTrans)
}
如果你仔细看,总之found Seq[Seq[X]]; required Seq[X]
found Seq[Seq[X]]; required Seq[X]
。 尽管您的帖子没有显示错误位置(控制台中的插入符号^
),但我怀疑这是针对reflandmarks.toSeq
的。 所以reflandmarks.toSeq
给出了Seq[Seq[X]]
。 要展平嵌套序列,您可以使用flatten
,因此使用reflandmarks.toSeq.flatten
可能会起作用。
请注意,由于子类型化,在需要collection.Seq
的地方传递参数collection.immutable.Seq
始终是可能的,因此这与实际问题无关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.