Last active
August 1, 2024 01:10
-
-
Save yuriploc/8f098cb8366941403e13f77be73a14df to your computer and use it in GitHub Desktop.
Basic opencv with evision without async genserver
This file contains hidden or 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
defmodule Eye do | |
alias Evision, as: Cv | |
def read(video, frame_read, count) when frame_read != false do | |
scale = 0.5 | |
{height, width, _channels} = frame_read.shape | |
new_width = trunc(width * scale) | |
new_height = trunc(height * scale) | |
frame_read | |
|> Cv.resize({new_width, new_height}) | |
|> then(&Cv.HighGui.imshow("janela", &1)) | |
Cv.HighGui.waitKey(1) | |
# Cv.HighGui.destroyWindow("janela") | |
frame_read = Cv.VideoCapture.read(video) | |
read(video, frame_read, count - 1) | |
end | |
def read(_, false, _) do | |
Cv.HighGui.destroyAllWindows() | |
end | |
def run do | |
rtsp_url = System.fetch_env!("RTSP_CAM") | |
video = Cv.VideoCapture.videoCapture(rtsp_url) | |
frame_read = Cv.VideoCapture.read(video) | |
read(video, frame_read, video.frame_count) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment