C回调和“类型X的参数与类型Y的参数不兼容”

时间:2017-02-27 10:15:55

标签: c++ opencv visual-studio-2015

我有一个ImageProcessing类。这个类有两个方法:on_trackbar和process。

我想从process方法调用on_trackbar方法。代码:

void ImageProcessingBasler::on_trackbar(int, void* )
{
    alpha = (double)alpha_slider / alpha_slider_max;
    beta = (1.0 - alpha);

    addWeighted(src1, alpha, src2, beta, 0.0, dst);

    imshow("Linear Blend", dst);
}

void ImageProcessingBasler::processImages(Mat srcImage, Mat premaskImage)
{
    src1 = anomalyImg;

    if (!src2.data) { printf("Error loading src2 \n"); return -1; }*/

    alpha_slider = 0;

    namedWindow("anomalyImg", 1);

    char TrackbarName[50];
    sprintf(TrackbarName, "Alpha x %d", alpha_slider_max);

    createTrackbar(TrackbarName, "Linear Blend", &alpha_slider,    alpha_slider_max, on_trackbar );
    // Show some stuff
    on_trackbar(alpha_slider, 0);
}

但是当我调用createTrackbar函数时,参数on_trackbar带有红色下划线,错误显示:

void ImageProcessing::on_trackbar(int, void *) argument of type "void(ImageProcessing::*)(int, void *)
is incompatible with parameter of type "cv::TrackbarCallback"

我在这里做错了什么?!

0 个答案:

没有答案