oh, there is a gabor kernel in opencv:
#include "opencv2/imgproc/imgproc.hpp"
cv::Mat kernel = cv::getGaborKernel(cv::Size(kernel_size,kernel_size), sig, th, lm, gm, ps);
Mat src_f; // img converted to float
Mat dest;
cv::filter2D(src_f, dest, CV_32F, kernel);