Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Try OpenCV.jl
DOCKER_IMAGE=terasakisatoshi/opencvjl
xhost +local:docker
docker run --rm -it \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix \
-v $(pwd):/work \
--device=/dev/video0:/dev/video0 \
-w /work \
${DOCKER_IMAGE} \
bash -c "julia script.jl"
xhost -local:docker
using OpenCV
device_id = Cint(0)
windowname = "cvwindow"
cap = OpenCV.VideoCapture(device_id)
OpenCV.namedWindow(windowname, OpenCV.WINDOW_AUTOSIZE)
@info "Press q to exit"
while true
ret, img = OpenCV.read(cap)
if ret
OpenCV.imshow(windowname, img)
if OpenCV.waitKey(Cint(1)) & 0xFF == Int32('q')
OpenCV.release(cap)
OpenCV.destroyWindow(windowname)
break
end
end
end
@terasakisatoshi

This comment has been minimized.

Copy link
Owner Author

@terasakisatoshi terasakisatoshi commented Dec 1, 2020

Usage

  • Prepare your Linux(x86_64) machine.
  • Download script.jl and run.sh at your workspace.
  • Pull Docker image via docker pull terasakisatoshi/opencvjl.
    • You can build a Docker image by yourself. See mygist

Run

  • Just run bash run.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment