I want to use an SVM with the chi-squared kernel for an application I am writing, but it doesn’t appear obvious how I can apply this.
I define the kernel as K(x_i, x_j) = exp( -1/A * D(x_i, x_j)), where A is a scaling parameter I can choose, and D(x_i, x_j) is the chi-squared distance between them.
How can this be done? It is a commonly used kernel in the computer vision literature, so it would be surprising if it was not possible.
I don’t think there is an option for chi-squared or an custom kernel in opencv.
So one option is to use a different SVM Library.
This is a modification of LIBSVM which supports an chi-squared kernel (a different one) and also precomputed kernels. But its targeted for the use with Matlab. So I am not sure how much it takes to make it work with C++.
Another option could be to use the linear SVM and transform your data to approximate the chi-squared kernel, if you want to stick to the opencv svm.
This answer might also give you some more hints.