Skip to content

MethodError when using OpenCV.imdecode #58

@ymtoo

Description

@ymtoo

MWE:

using OpenCV
using ImageCore

img = rand(RGB{N0f8}, 100, 200)
_, data = OpenCV.imencode(".jpg", collect(rawview(channelview(img)))) # data is a Vector{UInt8}
OpenCV.imdecode(data, -1)

throws the following error.

ERROR: MethodError: no method matching imdecode(::Vector{UInt8}, ::Int64)
The function `imdecode` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  imdecode(::Union{OpenCV.CxxMat, AbstractArray{T, 3} where T<:Union{Float32, Float64, Int16, Int32, Int8, UInt16, UInt8}}, ::Int64)
   @ OpenCV ~/.julia/artifacts/12890b1eaf53ee776ede25d1cb4b8dba6d1a55ab/OpenCV/src/cv_cxx_wrap.jl:2123

Stacktrace:
 [1] top-level scope
   @ REPL[13]:1

Why the first argument, which is a byte array, represented as a 3D array?

Julia and package versions:

julia> versioninfo()
Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

(jl_JUYJaI) pkg> st
Status `/private/var/folders/ss/xkdtgy8n4rs0jtwqygpb2dch0000gn/T/jl_JUYJaI/Project.toml`
  [a09fc81d] ImageCore v0.10.5
  [f878e3a2] OpenCV v4.6.1

(jl_JUYJaI) pkg> st --manifest
Status `/private/var/folders/ss/xkdtgy8n4rs0jtwqygpb2dch0000gn/T/jl_JUYJaI/Manifest.toml`
  [3da002f7] ColorTypes v0.12.0
  [c3611d14] ColorVectorSpace v0.11.0
  [5ae59095] Colors v0.13.0
  [1f15a43c] CxxWrap v0.16.2
  [5789e2e9] FileIO v1.17.0
  [53c48c17] FixedPointNumbers v0.8.5
  [a09fc81d] ImageCore v0.10.5
  [692b3bcd] JLLWrappers v1.7.0
  [1914dd2f] MacroTools v0.5.15
  [dbb5928d] MappedArrays v0.4.2
  [e94cdb99] MosaicViews v0.3.4
  [6fe1bfb0] OffsetArrays v1.15.0
  [f878e3a2] OpenCV v4.6.1
  [5432bcbf] PaddedViews v0.5.12
  [aea7be01] PrecompileTools v1.2.1
  [21216c6a] Preferences v1.4.3
  [189a3867] Reexport v1.2.2
  [ae029012] Requires v1.3.1
  [cae243ae] StackViews v0.1.1
  [10745b16] Statistics v1.11.1
  [62fd8b95] TensorCore v0.1.1
  [6e34b625] Bzip2_jll v1.0.9+0
  [2702e6a9] EpollShim_jll v0.0.20230411+1
  [2e619515] Expat_jll v2.6.5+0
  [a3f928ae] Fontconfig_jll v2.15.0+0
  [d7e528f0] FreeType2_jll v2.13.3+1
  [78b55507] Gettext_jll v0.21.0+0
  [7746bdde] Glib_jll v2.82.4+0
⌅ [e9f186c6] Libffi_jll v3.2.2+2
  [d4300ac3] Libgcrypt_jll v1.11.0+0
  [7e76a0d4] Libglvnd_jll v1.7.0+0
  [7add5ba3] Libgpg_error_jll v1.51.1+0
  [94ce4f54] Libiconv_jll v1.18.0+0
  [4b2f31a3] Libmount_jll v2.40.3+0
  [38a345b3] Libuuid_jll v2.40.3+0
  [33b9d88c] OpenCV_jll v4.10.0+0
  [458c3c95] OpenSSL_jll v3.0.16+0
⌅ [c0090381] Qt6Base_jll v6.7.1+1
  [a44049a8] Vulkan_Loader_jll v1.3.243+0
  [a2964d1f] Wayland_jll v1.21.0+2
  [2381bf8a] Wayland_protocols_jll v1.36.0+0
  [02c8fc9c] XML2_jll v2.13.6+1
  [aed1982a] XSLT_jll v1.1.42+0
  [f67eecfb] Xorg_libICE_jll v1.1.1+0
  [c834827a] Xorg_libSM_jll v1.2.4+0
  [4f6342f7] Xorg_libX11_jll v1.8.6+3
  [0c0b7dd1] Xorg_libXau_jll v1.0.12+0
  [a3789734] Xorg_libXdmcp_jll v1.1.5+0
  [1082639a] Xorg_libXext_jll v1.3.6+3
  [ec84b674] Xorg_libXrandr_jll v1.5.4+0
  [ea2f1a96] Xorg_libXrender_jll v0.9.11+1
  [14d82f49] Xorg_libpthread_stubs_jll v0.1.2+0
  [c7cfdc94] Xorg_libxcb_jll v1.17.0+3
  [cc61e674] Xorg_libxkbfile_jll v1.1.2+1
  [e920d4aa] Xorg_xcb_util_cursor_jll v0.1.4+0
  [12413925] Xorg_xcb_util_image_jll v0.4.0+1
  [2def613f] Xorg_xcb_util_jll v0.4.0+1
  [975044d2] Xorg_xcb_util_keysyms_jll v0.4.0+1
  [0d47668e] Xorg_xcb_util_renderutil_jll v0.3.9+1
  [c22f9ab0] Xorg_xcb_util_wm_jll v0.4.1+1
  [35661453] Xorg_xkbcomp_jll v1.4.6+1
  [33bec58e] Xorg_xkeyboard_config_jll v2.39.0+0
  [c5fb5394] Xorg_xtrans_jll v1.5.1+0
  [35ca27e7] eudev_jll v3.2.9+0
  [1a1c6b14] gperf_jll v3.1.1+1
⌅ [3eaa8342] libcxxwrap_julia_jll v0.13.4+0
  [2db6ffa8] libevdev_jll v1.11.0+0
  [36db933b] libinput_jll v1.18.0+0
  [009596ad] mtdev_jll v1.1.6+0
  [d8fb68d0] xkbcommon_jll v1.4.1+2
  [0dad84c5] ArgTools v1.1.2
  [56f22d72] Artifacts v1.11.0
  [2a0f44e3] Base64 v1.11.0
  [ade2ca70] Dates v1.11.0
  [f43a241f] Downloads v1.6.0
  [7b1f6079] FileWatching v1.11.0
  [b27032c2] LibCURL v0.6.4
  [76f85450] LibGit2 v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.11.0
  [56ddb016] Logging v1.11.0
  [d6f4376e] Markdown v1.11.0
  [ca575930] NetworkOptions v1.2.0
  [44cfe95a] Pkg v1.11.0
  [de0858da] Printf v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [fa267f1f] TOML v1.0.3
  [a4e569a6] Tar v1.10.0
  [cf7118a7] UUIDs v1.11.0
  [4ec0a83e] Unicode v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.1.1+0
  [deac9b47] LibCURL_jll v8.6.0+0
  [e37daf67] LibGit2_jll v1.7.2+0
  [29816b5a] LibSSH2_jll v1.11.0+1
  [c8ffd9c3] MbedTLS_jll v2.28.6+0
  [14a3606d] MozillaCACerts_jll v2023.12.12
  [4536629a] OpenBLAS_jll v0.3.27+1
  [efcefdf7] PCRE2_jll v10.42.0+1
  [83775a58] Zlib_jll v1.2.13+1
  [8e850b90] libblastrampoline_jll v5.11.0+0
  [8e850ede] nghttp2_jll v1.59.0+0
  [3f19e933] p7zip_jll v17.4.0+2
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions