Add Java and Python code for trackbar tutorial.

This commit is contained in:
catree
2018-05-17 14:19:08 +02:00
parent ba6b9fd261
commit 9fc0cabdf5
7 changed files with 258 additions and 25 deletions

View File

@@ -6,9 +6,10 @@
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <stdio.h>
#include <iostream>
using namespace cv;
using std::cout;
/** Global Variables */
const int alpha_slider_max = 100;
@@ -29,11 +30,8 @@ Mat dst;
static void 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 );
}
//![on_trackbar]
@@ -50,8 +48,8 @@ int main( void )
src2 = imread("../data/WindowsLogo.jpg");
//![load]
if( src1.empty() ) { printf("Error loading src1 \n"); return -1; }
if( src2.empty() ) { printf("Error loading src2 \n"); return -1; }
if( src1.empty() ) { cout << "Error loading src1 \n"; return -1; }
if( src2.empty() ) { cout << "Error loading src2 \n"; return -1; }
/// Initialize values
alpha_slider = 0;