Detect circles seen by a webcam with OpenCV
- OpenCV
- GoCV
Both can be installed by following the steps below (taken from this guide)
go get -u -d gocv.io/x/gocv
cd $GOPATH/src/gocv.io/x/gocv
make install
The webcam ID is hardcoded into the code and can be changed by changing the parameter in this line
webcam, _ := gocv.OpenVideoCapture(1)
The Circle Hough Transform which is used to detect the circles can be configured by changing the parameters in the following code block
gocv.HoughCirclesWithParams(
img,
&circles,
gocv.HoughGradient,
1, // dp
float64(img.Rows()/8), // minDist
75, // param1
40, // param2
3, // minRadius
60, // maxRadius
)
An explanation of the different parameters can be found on the OpenCV documentation pages here