Skip to content

Instantly share code, notes, and snippets.

@terasakisatoshi
Created December 1, 2020 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terasakisatoshi/4cd7f9f56018355f2f75d0f7da1169fd to your computer and use it in GitHub Desktop.
Save terasakisatoshi/4cd7f9f56018355f2f75d0f7da1169fd to your computer and use it in GitHub Desktop.
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
Copy link
Author

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