Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/20168#discussion_r161665337
--- Diff: python/pyspark/ml/image.py ---
@@ -55,25 +72,66 @@ def imageSchema(self):
"""
if self._imageSchema is None:
- ctx = SparkContext._active_spark_context
+ ctx = SparkContext.getOrCreate()
jschema =
ctx._jvm.org.apache.spark.ml.image.ImageSchema.imageSchema()
self._imageSchema = _parse_datatype_json_string(jschema.json())
return self._imageSchema
@property
def ocvTypes(self):
"""
- Returns the OpenCV type mapping supported.
+ Return the supported OpenCV types.
- :return: a dictionary containing the OpenCV type mapping supported.
+ :return: a list containing the supported OpenCV types.
.. versionadded:: 2.3.0
"""
if self._ocvTypes is None:
- ctx = SparkContext._active_spark_context
- self._ocvTypes =
dict(ctx._jvm.org.apache.spark.ml.image.ImageSchema.javaOcvTypes())
- return self._ocvTypes
+ ctx = SparkContext.getOrCreate()
+ ocvTypeList =
ctx._jvm.org.apache.spark.ml.image.ImageSchema.javaOcvTypes()
+ self._ocvTypes = [self._OcvType(name=x.name(),
+ mode=x.mode(),
+ nChannels=x.nChannels(),
+ dataType=x.dataType(),
+
nptype=self._ocvToNumpyMap[x.dataType()])
+ for x in ocvTypeList]
+ return self._ocvTypes[:]
+
+
+ def ocvTypeByName(self, name):
--- End diff --
`getOcvTypeByName` or `findOcvTypeByName`?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]