如何在 OPENCV 中为模式识别定义我们自己的内核?

How to define our own kernel for Pattern recognition in OPENCV?

我想为 OpenCV 上的图像分类编写自己的内核。

但是对于 SVM(Opencv 的内置函数)内核已经定义。

我的问题是,OpenCV 中是否有任何允许我定义内核的内容?

实际上,我想实现图像分类的多核学习。

我查看了一个答案,其中一种解决方法(也在 linked question 中提到)是使用替代 SVM 库,如 LibSVM 等(LibSVM 确实是一个很好的库)。

不过,如果您只想留在 OpenCV 中(这就是您的问题所显示的内容),那么有一个 similar question posted on OpenCV forums 并且某种解决方法是(逐字复制):

This message means that SVM with custom kernel does not support loading from file. You can try following things:

  1. Use one of the standard kernels (obviously)

  2. Implement your kernel as standard and optionally contribute it to the mainline

  3. Set kernel to standard before saving to file and back to custom after loading from file (workaround)

  4. Implement mechanism for saving/loading custom kernels with parameters (can be hard)