JuliaIO/VideoIO.jl

Can't get images from webcamera (Ubuntu Julia 1.7)

Closed this issue · 3 comments

import VideoIO
f = VideoIO.opencamera()
ERROR: MethodError: no method matching unsafe_convert(::Type{Ptr{Ptr{VideoIO.libffmpeg.AVDictionary}}}, ::VideoIO.AVDict)
Closest candidates are:
  unsafe_convert(::Type{Ptr{T}}, !Matched::FFTW.FakeArray{T}) where T at ~/.julia/packages/FFTW/pHa9y/src/fft.jl:121
  unsafe_convert(::Type{Ptr{T}}, !Matched::Base.ReinterpretArray{T, N, S, A} where {N, A<:(AbstractArray{S})}) where {T, S} at ~/julia-1.7.0/share/julia/base/reinterpretarray.jl:315
  unsafe_convert(::Type{Ptr{T}}, !Matched::SharedArrays.SharedArray{T}) where T at ~/julia-1.7.0/share/julia/stdlib/v1.7/SharedArrays/src/SharedArrays.jl:361

I'm also getting this issue from directly running the docs example on 1.6 in Windows.

using VideoIO
cam = VideoIO.opencamera()
for i in 1:100
    img = read(cam)
    sleep(1/VideoIO.framerate(cam))
end

returns

ERROR: LoadError: MethodError: no method matching unsafe_convert(::Type{Ptr{Ptr{VideoIO.libffmpeg.AVDictionary}}}, ::VideoIO.AVDict)
Closest candidates are:
  unsafe_convert(::Type{Ptr{Tv}}, ::SuiteSparse.CHOLMOD.Sparse{Tv}) where Tv at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\SuiteSparse\src\cholmod.jl:296
  unsafe_convert(::Type{Ptr{T}}, ::Base.ReshapedArray{T, N, P, MI} where {N, P<:AbstractArray, MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}, N} where N}}) where T at reshapedarray.jl:281
  unsafe_convert(::Type{Ptr{T}}, ::SharedArrays.SharedArray{T, N} where N) where T at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\SharedArrays\src\SharedArrays.jl:354

This would be helpful,usually works for me, change:

import Base.cconvert #add this at top
Base.cconvert(::Type{Ptr{Ptr{VideoIO.AVDictionary}}}, d::VideoIO.AVDict) = d.ref_ptr_dict #update the line that looks like this with this instead.

in avddictionary.jl in source code of the packages(could be found in ~/.julia/packages/VideoIO/something/src/avd.dictionary.jl)

Fixed by #345