Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code for non-transcoded video streams #277

Merged
merged 2 commits into from
Nov 22, 2020
Merged

Add code for non-transcoded video streams #277

merged 2 commits into from
Nov 22, 2020

Conversation

dawbarton
Copy link
Contributor

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 the AVPixelFormat values in libavutil_h.jl.

@codecov
Copy link

codecov bot commented Nov 19, 2020

Codecov Report

Merging #277 (079df0c) into master (7e05dc3) will decrease coverage by 0.38%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            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%) ⬇️

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.

@yakir12
Copy link
Contributor

yakir12 commented Nov 20, 2020

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!

@IanButterworth
Copy link
Member

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

@IanButterworth IanButterworth merged commit 78276d7 into JuliaIO:master Nov 22, 2020
@IanButterworth
Copy link
Member

Thanks @dawbarton and thanks for testing @yakir12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

retrieve! for VideoReader{NO_TRANSCODE} does nothing
3 participants