Closed dawbarton closed 3 years ago
Merging #277 (079df0c) into master (7e05dc3) will decrease coverage by
0.38%
. The diff coverage is0.00%
.
@@ Coverage Diff @@
## master #277 +/- ##
==========================================
- Coverage 76.48% 76.09% -0.39%
==========================================
Files 14 14
Lines 591 594 +3
==========================================
Hits 452 452
- Misses 139 142 +3
Impacted Files | Coverage Δ | |
---|---|---|
src/avio.jl | 73.59% <0.00%> (-0.74%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 7e05dc3...079df0c. Read the comment docs.
on my RPI this:
using VideoIO, BenchmarkTools
cam = VideoIO.opencamera()
img = read(cam)
@btime read!($cam, $img)
results in 11.039 ms.
Using this PR, and transcode=false
results in 845.115 μs! A ~13 times speedup!
For anyone doing a test like this ^ in the future, you may want to
@btime read!($cam, $img) setup=(sleep(0.1))
to give the camera time to make a new frame available, if the camera buffer waits for new, otherwise the timing may depend on framerate
Thanks @dawbarton and thanks for testing @yakir12
Fixes #111 and enables frames to be grabbed from a webcam without transcoding. This is particularly useful when only luminance values are required and the transcoding to RGB is actually unhelpful.
I use this within a Raspberry Pi computer vision system for control. As such, speed is important - without transcoding I can grab a frame in 1.5ms whereas with transcoding it takes 63.5ms.
The data is returned in a UInt8 array rather than a more specifically typed array but this seems to be in line with the original (unimplemented) intent. To interpret this data, the specific webcam pixel format needs to be known but that is relatively trivial (see
cam = VideoIO.opencamera(;transcode=false); cam.format
and compare against theAVPixelFormat
values inlibavutil_h.jl
.