using CondaPkg using PythonCall using Images using ImageView import VideoIO using GLMakie cv2 = pyimport("cv2") ### py2a(frame) = pyconvert(Array{Float32, 3}, frame) / 255; py2a(frame) = PyArray(frame) a2rgb(frame) = RGB{N0f8}.((@view frame[:, :, 3])/255 .* 1, (@view frame[:, :, 2])/255 .* 1, (@view frame[:, :, 1])/255 .* 1) py2rgb(frame) = frame |> py2a |> a2rgb blueth(pixel, th) = pixel.b > th ? 1.0f0 : 0.0f0 ## vid = cv2.VideoCapture(0) vid.set(3,1920) vid.set(4,1080) _, img = vid.read() a = img |> PyArray; frame = img |> py2rgb |> GLMakie.rotr90; image(frame) vid.release() ## vid = cv2.VideoCapture(0) vid.set(3,1920) vid.set(4,1080) try _, frame = vid.read() frame = py2rgb(frame) obs_img = GLMakie.Observable(GLMakie.rotr90(frame)) scene = GLMakie.Scene(camera=GLMakie.campixel!, size=reverse(size(frame))) GLMakie.image!(scene, obs_img) display(scene) while GLMakie.isopen(scene) _, img = vid.read() frame = img |> py2rgb |> GLMakie.rotr90 obs_img[] = frame #blueth.(frame, 0.97) sleep(1/9000) end finally vid.release() end ## vid = cv2.VideoCapture(0) for i = 1:100 ret, frame = vid.read() cv2.imshow("frame", frame) sleep(1/60) end vid.release()