Created
June 11, 2023 07:29
-
-
Save Wigny/3800dfce66b64b2dee1480f33378203d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mix.install([evision: "~> 0.1"], | |
system_env: [ | |
EVISION_PREFER_PRECOMPILED: "false", | |
CMAKE_OPENCV_OPTIONS: "-D WITH_FFMPEG=ON" | |
] | |
) | |
alias Evision.VideoCapture | |
url = "rtsp://172.28.6.108:8554/mystream" | |
Stream.resource( | |
fn -> VideoCapture.videoCapture(url, apiPreference: Evision.Constant.cv_CAP_FFMPEG()) end, | |
fn | |
%{isOpened: true} = video -> | |
frame = if VideoCapture.grab(video), do: VideoCapture.retrieve(video) | |
{[frame], video} | |
%{isOpened: false} = video -> | |
{:halt, video} | |
end, | |
fn video -> VideoCapture.release(video) end | |
) | |
|> Stream.each(&IO.inspect/1) | |
|> Stream.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment