Stack overflow when reshaping image array

I’m trying to read a few frames of video from a file and reshape the data into a three-dimensional array. I’m getting an infinite recursion when reshaping the array.

using VideoIO
io = VideoIO.testvideo("ladybird")
f = VideoIO.openvideo(io)
viddata = read(f)[:]
for i = 1:10 # read just a few frames
	append!(viddata, read(f))
end
vid = reshape(viddata, f.height, f.width, :) # stack overflow here

ERROR: StackOverflowError:
Stacktrace:
 [1] reshape(::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},1}, ::Tuple{Int32,Int32,Colon}) at /home/username/.julia/packages/OffsetArrays/46NUD/src/OffsetArrays.jl:111 (repeats 79984 times)

I don’t understand why OffsetArrays is getting involved here. My data type is

typeof(viddata)
Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},1}

Any thoughts on what’s gone wrong?
Thanks.

julia> vid = reshape(viddata, Int64(f.height), Int64(f.width), :); size(vid)
(1080, 1920, 11)

this works, this is almost certainly a bug you should report, the f.height was an Int32 which caused the bug, this line creates the stack overflow in the end

2 Likes

Thanks, that’s a good workaround. I’ll report the bug.