I'm trying to read a video from a file and perform some basic computer vision. As a part of this, I'd like to display the video (with some CV annotations) live. Is there a good Julia package for this?
The best I've go so far is
using VideoIO
using GLMakie
f = Figure()
display(f)
a = Axis(f)
r = openvideo("video.MOV")
img = read(r)
while !eof(r)
read!(r, img)
image!(a, img)
end
Which
image!
functionFor comparison, in Python I would use cv.imshow(img)
which is performant enough to display a full video live with a stable framerate.
Can you time the reading of a frame just to be sure it is fast enough for the desired framerate?
As for the Makie part, it looks like at every iteration you are generating a new plot - which is not optimal. You would want to plot once and then update the underlying data. One option is to use Observables - it might just be enough to give a smooth playback.
If not, there is also an undocumented Buffer
type that I use to update lineplots with lot of points as fast as possible.
fyi Makie's official support is on Discourse and Discord
That's true, Discord is the easiest way to reach devs I guess.
However, this seems to work for me reasonably well (with FullHD video):
using VideoIO
using GLMakie
f = Figure()
a = Axis(f[1,1])
r = openvideo("D:\\Downloads\\file_example_MOV_1920_2_2MB.mov")
img = Observable(read(r))
rot_img = lift(rotr90, img)
image!(a, rot_img)
while !eof(r)
img[] = read(r)
sleep(1/60) #fps
end
jar said:
fyi Makie's official support is on Discourse and Discord
Thanks for letting me know
However, this seems to work for me reasonably well (with FullHD video):
That works for me too; I added aspect=DataAspect()
to preserve the aspect ratio and am now looking for a way to check if the Figure has been closed by a user, but this looks quite promising. Thanks!
Can you time the reading of a frame just to be sure it is fast enough for the desired framerate?
I can read frames at 2000-3000 FPS
Last updated: Nov 22 2024 at 04:41 UTC