Ошибка компиляции С интеграцией OpenCV и NumPy

#python #numpy #opencv #scalapy

Вопрос:

Я пытаюсь загрузить матрицу OpenCV в виде массива NumPy, используя библиотеку ScalaPy, но, похоже, в ней отсутствует неявный писатель, который преобразовывал бы Matrx в массив NumPy. Вот пример кода:

Сначала мой импорт:

 import me.shadaj.scalapy.numpy.NumPy import me.shadaj.scalapy.py import org.bytedeco.opencv.global.opencv_imgcodecs.imread import org.bytedeco.opencv.opencv_core.Mat  val np: NumPy = py.module("numpy").as[NumPy]  def loadImage(imagePath: String) = {  // 0. Load the image and extract class label where a path to the image is assumed to be  // /path/to/dataset/{class}/{image}.jpg  val matrix: Mat = imread(imagePath)  val label = imagePath.split("")   // 1. Run the loaded image through the preprocessors, resulting in a feature vector  //val preProcessedImagesWithLabels = Seq(new ImageResizePreProcessor(appCfg)).map(preProcessor =gt; (preProcessor.preProcess(matrix), label))  val preProcessedImagesWithLabels = Seq(new ImageResizePreProcessor(appCfg)).map(preProcessor =gt; preProcessor.preProcess(matrix))  np.asarray(preProcessedImagesWithLabels) // Fails here as expected }  

Вот ошибка, с которой я сталкиваюсь:

 [error] /home/joesan/Projects/Private/ml-projects/object-classifier/src/main/scala/com/bigelectrons/animalclassifier/ImageLoader.scala:22:7: Symbol 'type me.shadaj.scalapy.py.Writer' is missing from the classpath [error] This symbol is required by 'value me.shadaj.scalapy.numpy.NumPy.writer'. [error] Make sure that type Writer is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. [error] A full rebuild may help if 'NumPy.class' was compiled against an incompatible version of me.shadaj.scalapy.py. [error] np.asarray(preProcessedImagesWithLabels) [error] ^ [error] /home/joesan/Projects/Private/ml-projects/object-classifier/src/main/scala/com/bigelectrons/animalclassifier/ImageLoader.scala:22:17: could not find implicit value for parameter writer: me.shadaj.scalapy.py.Writer[org.bytedeco.opencv.opencv_core.Mat] [error] np.asarray(preProcessedImagesWithLabels) [error] ^ [error] two errors found [error] (Compile / compileIncremental) Compilation failed [error] Total time: 5 s, completed Nov 1, 2021 9:40:45 AM  

Есть две ошибки, с которыми я сталкиваюсь. Должен ли я иметь неявную реализацию writer, которая знает, как преобразовать мат в массив NumPy? Есть какие-нибудь идеи?