Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bennythejudge
Forked from deadprogram/activities.md
Created October 1, 2018 14:49
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 bennythejudge/785903af4d0104ca2d25248a2f938e82 to your computer and use it in GitHub Desktop.
Save bennythejudge/785903af4d0104ca2d25248a2f938e82 to your computer and use it in GitHub Desktop.

Activities

Activity 1 - "Hello, World" of Computer Vision

You must change directory to the directory where GoCV has been installed, then you can run the code.

Windows

chdir %GOPATH%\src\gocv.io\x\gocv
go run cmd\hello\main.go

macOS/Linux

cd $GOPATH/src/gocv.io/x/gocv
go run cmd/hello/main.go

You can also find the code located at this URL:

https://github.com/hybridgroup/gocv/blob/master/cmd/hello/main.go

Activity 2 - Camera input

Windows

chdir %GOPATH%\src\gocv.io\x\gocv
go run cmd\capwindow\main.go 0

macOS/Linux

cd $GOPATH/src/gocv.io/x/gocv
go run cmd/capwindow/main.go 0

You can also find the code located at this URL:

https://github.com/hybridgroup/gocv/blob/master/cmd/capwindow/main.go

Activity 3 - File input

Windows

chdir %GOPATH%\src\gocv.io\x\gocv
go run cmd\capwindow\main.go images\small.mp4

macOS/Linux

cd $GOPATH/src/gocv.io/x/gocv
go run cmd/capwindow/main.go images/small.mp4

You can also find the code located at this URL:

https://github.com/hybridgroup/gocv/blob/master/cmd/capwindow/main.go

Activity 4 - Video output

Windows

chdir %GOPATH%\src\gocv.io\x\gocv
go run cmd\savevideo\main.go 0 testcap.avi

macOS/Linux

cd $GOPATH/src/gocv.io/x/gocv
go run cmd/savevideo/main.go 0 testcap.avi

You can also find the code located at this URL:

https://github.com/hybridgroup/gocv/blob/master/cmd/savevideo/main.go

Activity 5 - Image output

Windows

chdir %GOPATH%\src\gocv.io\x\gocv
go run cmd\saveimage\main.go 0 myimage.jpg

macOS/Linux

cd $GOPATH/src/gocv.io/x/gocv
go run cmd/saveimage/main.go 0 myimage.jpg

You can also find the code located at this URL:

https://github.com/hybridgroup/gocv/blob/master/cmd/saveimage/main.go

Activity 6 - Stream output

Installation

go get -u github.com/hybridgroup/mjpeg

Windows

chdir %GOPATH%\src\gocv.io\x\gocv
go run cmd\mjpeg-streamer\main.go 0 0.0.0.0:8080

macOS/Linux

cd $GOPATH/src/gocv.io/x/gocv
go run cmd/mjpeg-streamer/main.go 0 0.0.0.0:8080

You can also find the code located at this URL:

https://github.com/hybridgroup/gocv/blob/master/cmd/mjpeg-streamer/main.go

Activity 7 - Install/Build CVscope

Installation

Windows

set PATH=%PATH%;%GOPATH%\bin;
go get -u gocv.io/x/cvscope

macOS/Linux

go get -u gocv.io/x/cvscope

Running

cvscope

You can also find the CVscope code located at this URL:

https://github.com/hybridgroup/cvscope

Activity 8 - Try Dilate with CVScope

cvscope dilate

Activity 9 - Try Erode with CVScope

cvscope erode

Activity 10 - Try Threshold with CVScope

cvscope threshold

Activity 11 - Try Gaussian Blur with CVScope

cvscope gaussian

Activity 12 - Face blurring

Windows

chdir %GOPATH%\src\gocv.io\x\gocv
go run cmd\faceblur\main.go 0 data\haarcascade_frontalface_default.xml

macOS/Linux

cd $GOPATH/src/gocv.io/x/gocv
go run cmd/faceblur/main.go 0 data/haarcascade_frontalface_default.xml

You can also find the code located at this URL:

https://github.com/hybridgroup/gocv/blob/master/cmd/faceblur/main.go

Activity 13 - Motion detection

Windows

chdir %GOPATH%\src\gocv.io\x\gocv
go run cmd\motion-detect\main.go 0

macOS/Linux

cd $GOPATH/src/gocv.io/x/gocv
go run cmd/motion-detect/main.go 0

You can also find the code located at this URL:

https://github.com/hybridgroup/gocv/blob/master/cmd/motion-detect/main.go

Activity 14 - Object classifier

Installation

Download and extract the model files from here:

https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip

Windows

chdir %GOPATH%\src\gocv.io\x\gocv
go run cmd\tf-classifier\main.go 0 %USERPROFILE%\Downloads\tensorflow_inception_graph.pb %USERPROFILE%\Downloads\imagenet_comp_graph_label_strings.txt

macOS/Linux

cd $GOPATH/src/gocv.io/x/gocv
go run cmd/tf-classifier/main.go 0 ~/Downloads/tensorflow_inception_graph.pb ~/Downloads/imagenet_comp_graph_label_strings.txt

You can also find the code located at this URL:

https://github.com/hybridgroup/gocv/blob/master/cmd/tf-classifier/main.go

Activity 15 - Object detection and tracking

Installation

Download and extract the Caffe model file from here:

https://github.com/opencv/opencv_3rdparty/raw/dnn_samples_face_detector_20170830/res10_300x300_ssd_iter_140000.caffemodel

Download the config file from here: https://raw.githubusercontent.com/opencv/opencv/master/samples/dnn/face_detector/deploy.prototxt

Windows

chdir %GOPATH%\src\gocv.io\x\gocv
go run cmd\dnn-detection\main.go 0 %USERPROFILE%\Downloads\res10_300x300_ssd_iter_140000.caffemodel %USERPROFILE%\Downloads\deploy.prototxt

macOS/Linux

cd $GOPATH/src/gocv.io/x/gocv
go run cmd/dnn-detection/main.go 0 \
~/Downloads/res10_300x300_ssd_iter_140000.caffemodel \
~/Downloads/deploy.prototxt

You can also find the code located at this URL:

https://github.com/hybridgroup/gocv/blob/master/cmd/dnn-detection/main.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment