VideoIO.jl
VideoIO.jl copied to clipboard
Loading package and videocapture() in VideoIO
It currently takes almost 19s on my OSX 10.9.5, with 2.53 Ghz Intel i5 (8GB RAM) from opening the built-in iSight camera to viewing the first frame (img) captured with ImageView.view(img)
. Average capture inter-frame interval is 0.048 ± 0.020 s (std, n = 253) which is not too far from 25 fps. I understand that there will be some improvement with Speed.jl, but I wonder whether this likely to happen in the near future? and where such improvements in loading time are likely to come from?
using Images, ImageView
using VideoIO
julia> f = @time(opencamera())
[avfoundation @ 0x7fab87b63800] Selected pixel format (yuv420p) is not supported by the input device.
[avfoundation @ 0x7fab87b63800] Supported pixel formats:
[avfoundation @ 0x7fab87b63800] uyvy422
[avfoundation @ 0x7fab87b63800] yuyv422
[avfoundation @ 0x7fab87b63800] nv12
[avfoundation @ 0x7fab87b63800] 0rgb
[avfoundation @ 0x7fab87b63800] bgr0
elapsed time: 6.240201195 seconds (31583716 bytes allocated)
VideoReader(...)
julia> img = @time(read(f, Image))
elapsed time: 1.170095548 seconds (12171060 bytes allocated, 4.92% gc time)
RGB Image with:
data: 640x480 Array{RGB{UfixedBase{Uint8,8}},2}
properties:
spatialorder: x y
julia> canvas, _ = @time(ImageView.view(img))
elapsed time: 11.55115924 seconds (122917292 bytes allocated, 0.96% gc time)
(ImageCanvas,ImageSlice2d: zoom = BoundingBox(0.0,640.0,0.0,480.0))
julia> totaltime = 6.240201195 + 1.170095548 + 11.55115924
18.961455983
# Record video stream and save the capture and display times to compute the mean and std
record_fps = Float64[];
while !eof(f)
tic()
read!(f, img)
ImageView.view(canvas, img)
push!(record_fps, toq())
end
julia> mean(record_fps)
0.0480580370632411
julia> std(record_fps)
0.020814071398637227
On my Lenovo T430 with i7, it's "only" about 7-8s:
julia> f = @time(opencamera())
elapsed time: 2.881025252 seconds (65974908 bytes allocated, 1.05% gc time)
VideoReader(...)
julia> img = @time(read(f, Image))
elapsed time: 0.447659627 seconds (12206196 bytes allocated)
RGB Image with:
data: 640x480 Array{RGB{UfixedBase{UInt8,8}},2}
properties:
spatialorder: x y
julia> canvas, _ = @time(ImageView.view(img))
elapsed time: 4.265758018 seconds (119209036 bytes allocated, 1.49% gc time)
(ImageCanvas,ImageSlice2d: zoom = BoundingBox(0.0,640.0,0.0,480.0))
julia> # Record video stream and save the capture and display times to compute the mean and std
record_fps = Float64[];
julia> while !eof(f)
tic()
read!(f, img)
ImageView.view(canvas, img)
push!(record_fps, toq())
end
^CERROR: interrupt
in pump at /home/beyer/.julia/v0.4/VideoIO/src/avio.jl:139
in eof at /home/beyer/.julia/v0.4/VideoIO/src/avio.jl:504
in eof at /home/beyer/.julia/v0.4/VideoIO/src/avio.jl:514
in anonymous at no file:5
julia> mean(record_fps)
0.01144968711607143
julia> std(record_fps)
0.009055393831337669
Most of the time is taken by creating the window, which might get fixed in the Gtk branch of ImageView (See timholy/ImageView.jl#46.)
The numbers show I should've gotten ~87FPS, but it felt more like ~15.
You could use timholy/ProfileView.jl if you want to dig deeper.
Still an issue.
julia> using Makie, VideoIO
[ Info: Recompiling stale cache file /Users/kevinsquire/.julia/compiled/v1.3/Makie/iZ1Bl.ji for Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a]
julia> @time(viewcam()) # Manually closed the camera window after the video started
36.152654 seconds (90.21 M allocations: 4.915 GiB, 7.28% gc time)
Same for me. The 2nd time I run viewcam()
it's a lot faster, so I assume it's a compilation issue