Check the corresponding tutorial for more details
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
using std::cout;
const int alpha_slider_max = 100;
int alpha_slider;
double alpha;
double beta;
static void on_trackbar( int, void* )
{
alpha = (double) alpha_slider/alpha_slider_max ;
beta = ( 1.0 - alpha );
imshow(
"Linear Blend", dst );
}
int main( void )
{
src1 =
imread(
"../data/LinuxLogo.jpg");
src2 =
imread(
"../data/WindowsLogo.jpg");
if( src1.
empty() ) { cout <<
"Error loading src1 \n";
return -1; }
if( src2.
empty() ) { cout <<
"Error loading src2 \n";
return -1; }
alpha_slider = 0;
char TrackbarName[50];
sprintf( TrackbarName, "Alpha x %d", alpha_slider_max );
createTrackbar( TrackbarName,
"Linear Blend", &alpha_slider, alpha_slider_max, on_trackbar );
on_trackbar( alpha_slider, 0 );
return 0;
}