November 2018
Beginner to intermediate
348 pages
8h 32m
English
At some point, we would also like to draw on an image, preferably before we output it, either to the display or a file. GoCV handles that admirably. For our purposes in this chapter, we'll just be drawing rectangles to denote where a face might be. GoCV interfaces well with the standard library's Rectangle type.
To draw a rectangle on an image with GoCV, we first define a rectangle:
r := image.Rect(50, 50, 100, 100)
Here, I defined a rectangle that starts at location (50, 50) and is 100 pixels wide and 100 pixels tall.
Then, a color needs to be defined. Again, GoCV plays very nicely with image/color, found in the standard library. So, here's the definition of the color blue:
blue := color.RGBA{0, 0, 255, 0}
And now, ...
Read now
Unlock full access