How to construct a video object for display by ImageView.imshow()

imshow() is described as being able to display a video. The example in the documentation is testimage(“mri”). The type of this object is:

`AxisArray{Gray{Normed{UInt8,8}},3,Array{Gray{Normed{UInt8,8}},3},Tuple{AxisArrays.Axis{:P,StepRange{Int64,Int64}},AxisArrays.Axis{:R,StepRange{Int64,Int64}},AxisArrays.Axis{:S,StepRange{Int64,Int64}}}}

As a julia beginner it’s rather difficult for me to parse this type information and infer the correct process for constructing my own video of the correct type.

The (short) video I have is loaded from a file using VideoIO like this:

f = VideoIO.openvideo( VIDEO )
video = []
framecount = 0
while !eof( f )
    global framecount
    global video
    frame = read( f )
    push!( video, frame )
    framecount += 1
end

I want to work with it as a single in memory object which (among many other things) I would like to be able to display as a video and maybe step through the frames.

Of course the simple array I’m using is not the AxisArray expected by imshow so how can I get my data into the correct structure ?

Answering my own question in case anyone else encounters the same problem.

The following code does the job:

function loadvideo( filename )
    f = VideoIO.openvideo( filename )
    framecount = 0
    frames = []
    while !eof( f )
        frame = read( f )
        push!( frames, frame )
        framecount += 1
    end
 
    video = Array{ eltype( frames[1] ) }( undef, 
                                          size( frames[1] )[1], 
                                          size( frames[1] )[2], 
                                          length( frames ) )    
    for i = 1:length( frames )
        video[ :, :, i ] = frames[i]
    end
    return video
end

This is inefficient because it loads the frames into a simple array first but when I tried constructing the multidimensional array on the fly with cat the performance was terrible and actually required me to kill the julia process.