Opencv 创建滑动条

  今天参照Opencv的官方文档写了一个将两幅图片进行线性混叠的程序,并且使用了滑动条来实现混叠的参数alpha,下面是代码:

#include 
#include 
#include 
using namespace std;
using namespace cv;

const int slide_value_max=100;
Mat src1,src2,dst;
void on_trackbar(int slide_alpha,void *)
{
    double alpha= (double)slide_alpha/slide_value_max;
    double beta=1.0-alpha;
    addWeighted(src1,alpha,src2,beta,0.0,dst);
    imshow("Linear Blend",dst);
}
int main(int argc, char **argv)
{
    src1=imread("LinuxLogo.jpg");
    src2=imread("WindowsLogo.jpg");//src1 and src2 must be the same size

    if(!src1.data || !src2.data)
    {
        cerr<<"error in loading picture"<
  • 1

参考链接:http://docs.opencv.org/doc/tutorials/highgui/trackbar/trackbar.html#adding-trackbars`

你可能感兴趣的:(opencv,计算机视觉,人工智能)