Issues found in OpenCV.jl

Hi, @Ashwani_Rathee thanks for creating this package.
I have found some issues in OpenCV.jl while I am recently using this package.

  1. Some array operations like findall slow and using high memory on OpenCV.Mat compared Array{T, 3}. Here is WME
using Random
using BenchmarkTools
using OpenCV

Random.seed!(1234)

mat = rand(UInt8(0):UInt8(255), 3, 2^10, 2^10)
ocmat = OpenCV.Mat(mat)

f = >=(UInt8(100))

@assert findall(f, mat) == findall(f, ocmat)
@assert findall(f, mat) == findall(f, ocmat.data)
@assert findall(f, mat) == findall(f, ocmat.data_raw)

@benchmark findall($(f), $(mat))

@benchmark findall($(f), $(ocmat))

@benchmark findall($(f), $(ocmat.data))

@benchmark findall($(f), $(ocmat.data_raw))

Results

julia> @benchmark findall($(f), $(mat))
BenchmarkTools.Trial: 269 samples with 1 evaluation.
 Range (min … max):  15.501 ms … 44.234 ms  ┊ GC (min … max): 3.47% … 3.38%
 Time  (median):     17.868 ms              ┊ GC (median):    8.16%
 Time  (mean ± σ):   18.622 ms ±  3.149 ms  ┊ GC (mean ± σ):  8.28% ± 1.30%

         ██▆▃ ▁
  ▄▁▁▁▁▁▆██████▅▁▁▁▁▄▁▁▁▁▅▁▁▁▁▁▄▄▅▁▁▄▁▁▁▁▁▁▄▅▁▁▁▁▁▄▁▁▁▁▁▁▁▁▁▆ ▅
  15.5 ms      Histogram: log(frequency) by time      31.9 ms <

 Memory estimate: 44.25 MiB, allocs estimate: 6.

julia> @benchmark findall($(f), $(ocmat))
BenchmarkTools.Trial: 2 samples with 1 evaluation.
 Range (min … max):  2.491 s …   2.524 s  ┊ GC (min … max): 0.79% … 0.78%
 Time  (median):     2.507 s              ┊ GC (median):    0.78%
 Time  (mean ± σ):   2.507 s ± 23.730 ms  ┊ GC (mean ± σ):  0.78% ± 0.01%

  █                                                       █
  █▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█ ▁
  2.49 s         Histogram: frequency by time        2.52 s <

 Memory estimate: 542.59 MiB, allocs estimate: 26367765.

julia> @benchmark findall($(f), $(ocmat.data))
BenchmarkTools.Trial: 252 samples with 1 evaluation.
 Range (min … max):  15.296 ms … 46.063 ms  ┊ GC (min … max): 2.31% … 6.62%
 Time  (median):     18.633 ms              ┊ GC (median):    8.80%
 Time  (mean ± σ):   19.874 ms ±  3.541 ms  ┊ GC (mean ± σ):  8.27% ± 1.33%

             ▆█▇▄▄▁
  ▄▄▁▁▁▁▁▁▁▁▇██████▆█▄▄▆▄▇▁▆▇▄▁▄▄▁▄▁▆▁▁▁▄▁▁▆▄▄▁▄▄▆▇▆▆▄▄▁▁▄▁▄▆ ▆
  15.3 ms      Histogram: log(frequency) by time        30 ms <

 Memory estimate: 44.25 MiB, allocs estimate: 6.

julia> @benchmark findall($(f), $(ocmat.data_raw))
BenchmarkTools.Trial: 239 samples with 1 evaluation.
 Range (min … max):  16.272 ms … 62.863 ms  ┊ GC (min … max): 9.46% … 2.66%
 Time  (median):     19.361 ms              ┊ GC (median):    8.68%
 Time  (mean ± σ):   20.880 ms ±  4.555 ms  ┊ GC (mean ± σ):  8.28% ± 1.82%

          ▇█
  ▃▁▁▂▁▃▃████▇▆▅▇▅▃▂▂▃▁▃▂▃▃▄▃▂▃▃▃▃▁▁▃▂▁▁▃▃▃▂▃▁▂▂▁▁▁▁▁▂▁▁▁▁▂▁▂ ▃
  16.3 ms         Histogram: frequency by time        32.9 ms <

 Memory estimate: 44.25 MiB, allocs estimate: 6.

but using with data and data_raw properties, I am getting similar results as Array{T, 3}



2. OpenCV.VideoWriter_fourcc not working.

julia> OpenCV.VideoWriter_fourcc("h264"...)
ERROR: MethodError: no method matching jlopencv_cv_cv_VideoWriter_fourcc(::Char, ::Char, ::Char, ::Char)
Stacktrace:
 [1] VideoWriter_fourcc(c1::Char, c2::Char, c3::Char, c4::Char)
   @ OpenCV C:\Users\rakesh\.julia\artifacts\fb232e63f59cec37f3a904b5decdaa33513a13b1\OpenCV\src\cv_cxx_wrap.jl:1016
 [2] top-level scope
   @ REPL[39]:1

while python version given this

cv2.VideoWriter.fourcc(*"h264")
875967080




3. Failed to recognize OpenH264 library even using FFMPEG

julia> OpenCV.VideoWriter("julia.mp4", 875967080, 24.0, OpenCV.Size(Int32(1920), Int32(1080)))
OpenCV: FFMPEG: tag 0x34363268/'h264' is not supported with codec id 27 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'

Failed to load OpenH264 library: openh264-1.8.0-win64.dll
        Please check environment and/or download library: https://github.com/cisco/openh264/releases

[libopenh264 @ 000002c281a763c0] Incorrect library version loaded
[ERROR:0@0.008] global /build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (2985) open Could not open codec libopenh264, error: Unspecified error (-22)
[ERROR:0@0.008] global /build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (3002) open VIDEOIO/FFMPEG: Failed to initialize VideoWriter
OpenCV.VideoWriterAllocated(Ptr{Nothing} @0x000002c290993e10)



julia> OpenCV.VideoWriter("julia.mp4", 828601953, 24.0, OpenCV.Size(Int32(1920), Int32(1080)))

Failed to load OpenH264 library: openh264-1.8.0-win64.dll
        Please check environment and/or download library: https://github.com/cisco/openh264/releases

[libopenh264 @ 000001f27a5c7580] Incorrect library version loaded
[ERROR:0@0.003] global /build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (2985) open Could not open codec libopenh264, error: Unspecified error (-22)
[ERROR:0@0.003] global /build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (3002) open VIDEOIO/FFMPEG: Failed to initialize VideoWriter
OpenCV.VideoWriterAllocated(Ptr{Nothing} @0x000001f27a234fa0)




4. Some functions not dispatched correctly like OpenCV.drawContours. Issue exists in github



Version Information

julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a (2023-08-24 14:43 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 16 × AMD Ryzen 7 PRO 5850U with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
  Threads: 1 on 16 virtual cores
  
(jl_F5GCjK) pkg> st
Status `C:\Users\rakesh\AppData\Local\Temp\jl_F5GCjK\Project.toml`
  [6e4b80f9] BenchmarkTools v1.3.2
  [c87230d0] FFMPEG v0.4.1
  [916415d5] Images v0.26.0
  [f878e3a2] OpenCV v4.5.3

@Ashwani_Rathee Any suggestion on how to solve issue 3.