Oh, I'm well aware of your great contributions to VideoIO. And OpenCV looks
like an even bigger one.
However, I think quite a bit of "live processing" is already supported via the
`map/MapInfo` framework. For example, below is a complete, high-performance
GUI for interactively setting a threshold. Because the whole MapInfo framework
is lazy, it can be used with both static images and video.
--Tim
using Base.Cartesian
using Images, Tk, ImageView, Color
import Base: map!
export threshold_slider
# Threshold pixels using a slider
type ThresholdSlider{To,A<:AbstractArray,From,M<:Images.MapInfo} <:
Images.MapInfo{To}
value::A
slider_min::From
slider_max::From
mapi0::M
slider
end
function ThresholdSlider(value::AbstractArray, mapi0, s,
extrma=extrema(value))
smin, smax = promote(extrma[1], extrma[2])
ThresholdSlider{Uint32,typeof(value),typeof(smin),typeof(mapi0)}(value,
smin, smax, mapi0, s)
end
function threshold_slider(img, value, extrma=extrema(value); mapi0 =
mapinfo(RGB24, img))
w = Toplevel()
f = Frame(w)
pack(f, expand=true, fill="both")
l = Label(f, "Threshold: $(extrma[1])")
pack(l, side="top")
s = Slider(f, extrma[1], extrma[2])
ts = ThresholdSlider(value, mapi0, s, extrma)
imgc, imsl = view(img, scalei=ts)
pack(s, side="top", expand=true, fill="both", anchor="w")
bind(s, "command", path -> (set_value(l, @sprintf("%4.2e", get_value(s)));
ImageView.redraw(imgc, imsl)))
end
function map!{T,N}(mapi::ThresholdSlider{Uint32}, dest::Array{Uint32,N},
src::AbstractImageDirect{T,N})
value = sub(mapi.value, data(src).indexes[1:N])
map_thresh!(mapi, dest, src, value, get_value(mapi.slider))
end
@ngenerate N typeof(dest) function map_thresh!{T,N}
(mapi::ThresholdSlider{Uint32}, dest::Array{Uint32,N},
src::AbstractImageDirect{T,N}, value, thresh)
size(dest) == size(src) || throw(DimensionMismatch())
mapi0 = mapi.mapi0
@nloops N i dest begin
c = map(mapi0, @nref N src i)
x = @nref N value i
(@nref N dest i) = x > thresh? convert(RGB24, c) : RGB24(0)
end
dest
end
On Saturday, December 06, 2014 04:34:55 AM Max Suster wrote:
> Hi Tim,
>
> Thanks for your feedback. By no means, OpenCV.jl is meant to be a
> replacement of your outstanding contributions to Images.jl and Kevin´s
> wonderful VideoIO.jl package. As you may know, I spent some time recently
> contributing to VideoIO´s options API - so I realize that these packages
> are highly valuable :)
>
> Having said that, I think you will see that already the README.md file
> describes the following which are not currently available at all in Julia
> (or to the same extent via C++):
>
> - Highly efficient pixel scanning and manipulation using pointers in C++
> (smooth interface between Julia and C++)
> - Conversion between images in Images.jl and OpenCV Mat format (to take
> advantage of hundreds of algorithms readily available in C++)
> - Convenient live image processing with adjustable trackbars (e.g.,
> thresholding, and dozens of image processing filters possible without
> much effort), including options for Qt GUI support
> - Object tracking (which is not currently available for Julia) is