What we want to do is build a program that reads an image from a webcam, passes the image into a face detector and then draws rectangles in the image. Finally, we want to display the image with the rectangles drawn on.
Face detection program
Grabbing an image from the webcam
First, we'll open a connection to the webcam:
```
func main() {
// open webcam
webcam, err := gocv.VideoCaptureDevice(0)
if err != nil {
log.Fatal(err)
}
defer webcam.Close()
}
```
Here, I used VideoCaptureDevice(0) because, on my computer, which runs Ubuntu, the webcam is device 0. Your webcam may differ in device numbering. Also, do note defer webcam.Close(). This is the aforementioned resource metaphor that GoCV sticks very strongly to. A webcam...