You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by tomasatdatabricks <gi...@git.apache.org> on 2018/01/16 22:18:06 UTC
[GitHub] spark pull request #20168: [SPARK-22730][ML] Add ImageSchema support for all...
Github user tomasatdatabricks commented on a diff in the pull request:
https://github.com/apache/spark/pull/20168#discussion_r161903575
--- Diff: mllib/src/main/scala/org/apache/spark/ml/image/ImageSchema.scala ---
@@ -37,20 +37,67 @@ import org.apache.spark.sql.types._
@Since("2.3.0")
object ImageSchema {
- val undefinedImageType = "Undefined"
+ /**
+ * OpenCv type representation
+ *
+ * @param mode ordinal for the type
+ * @param dataType open cv data type
+ * @param nChannels number of color channels
+ */
+ case class OpenCvType(mode: Int, dataType: String, nChannels: Int) {
+ def name: String = if (mode == -1) { "Undefined" } else { s"CV_$dataType" + s"C$nChannels" }
+ override def toString: String = s"OpenCvType(mode = $mode, name = $name)"
+ }
/**
- * (Scala-specific) OpenCV type mapping supported
+ * Return the supported OpenCvType with matching name or raise error if there is no matching type.
+ *
+ * @param name: name of existing OpenCvType
+ * @return OpenCvType that matches the given name
*/
- val ocvTypes: Map[String, Int] = Map(
- undefinedImageType -> -1,
- "CV_8U" -> 0, "CV_8UC1" -> 0, "CV_8UC3" -> 16, "CV_8UC4" -> 24
- )
+ def ocvTypeByName(name: String): OpenCvType = {
--- End diff --
I prefer the ocvTypeByName unless there is a consensus otherwise. Find suggests slightly different usage patterns in my opinion and so does get, to some extent, + get would not be consistent with the rest of the python api. I don't feel particularly strong about this so if more people think it should be change I'd be happy to change it .
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org