mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
experimental implementation for OpenCV 3
This commit is contained in:
parent
2c6f30ab25
commit
11c4154b7c
264 changed files with 53296 additions and 51592 deletions
18
examples/alpha_blend.rb
Executable file → Normal file
18
examples/alpha_blend.rb
Executable file → Normal file
|
@ -1,21 +1,15 @@
|
|||
#!/usr/bin/env ruby
|
||||
# -*- mode: ruby; coding: utf-8 -*-
|
||||
|
||||
# Alpha blending sample with GUI
|
||||
|
||||
require 'opencv'
|
||||
include OpenCV
|
||||
|
||||
img1 = IplImage.load('images/lenna.jpg', CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
img2 = IplImage.load('images/tiffany.jpg', CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
img1 = Cv::imread('images/lenna.jpg', -1)
|
||||
img2 = Cv::imread('images/tiffany.jpg', -1)
|
||||
|
||||
window = GUI::Window.new('Alpha blend')
|
||||
window = Cv::Window.new('Alpha blend')
|
||||
max = 100.0
|
||||
val = max / 2.0
|
||||
window.set_trackbar("Alpha", max, val) { |v|
|
||||
a = v.to_f / max
|
||||
window.show CvMat.add_weighted(img1, a, img2, 1.0 - a, 0)
|
||||
window.show(Cv::add_weighted(img1, a, img2, 1.0 - a, 0))
|
||||
}
|
||||
window.show CvMat.add_weighted(img1, val / max, img2, 1.0 - val / max, 0)
|
||||
GUI::wait_key
|
||||
|
||||
window.show(Cv::add_weighted(img1, val / max, img2, 1.0 - val / max, 0))
|
||||
Cv.wait_key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue