MM-14617 Dependency upgrades and adding modules support. (#10517)

* Dependency upgrades and adding modules support.

* Commenting out file tests playload verification portion.

* Fixing viper.

* Fixing hclog.
Этот коммит содержится в:
Christopher Speller
2019-04-10 07:56:17 -07:00
коммит произвёл GitHub
родитель bd8a54bb08
Коммит 41d117c37b
550 изменённых файлов: 22572 добавлений и 114088 удалений

25
vendor/github.com/muesli/smartcrop/.travis.yml сгенерированный поставляемый
Просмотреть файл

@@ -6,22 +6,33 @@ os:
go:
- 1.4
- 1.5
- 1.6
- 1.7
- 1.8
- 1.5.x
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- tip
matrix:
exclude:
- os: osx
go: 1.4
- os: osx
go: 1.5.x
- os: osx
go: 1.6.x
before_install:
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- if [[ $TRAVIS_GO_VERSION == 1.9* ]]; then go get github.com/axw/gocov/gocov github.com/mattn/goveralls; fi
# - sudo add-apt-repository -y ppa:kubuntu-ppa/backports
# - sudo apt-get update -qq
# - sudo apt-get install libcv-dev libopencv-dev libopencv-contrib-dev libhighgui-dev libopencv-photo-dev libopencv-imgproc-dev libopencv-stitching-dev libopencv-superres-dev libopencv-ts-dev libopencv-videostab-dev
script:
- go test -v -tags ci ./...
- $GOPATH/bin/goveralls -service=travis-ci
- if [[ $TRAVIS_GO_VERSION == 1.9* ]]; then $GOPATH/bin/goveralls -service=travis-ci; fi
notifications:
email:

47
vendor/github.com/muesli/smartcrop/README.md сгенерированный поставляемый
Просмотреть файл

@@ -4,14 +4,15 @@ smartcrop
smartcrop finds good image crops for arbitrary sizes. It is a pure Go implementation, based on Jonas Wagner's [smartcrop.js](https://github.com/jwagner/smartcrop.js)
![Example](./examples/gopher.jpg)
Image: [https://www.flickr.com/photos/usfwspacific/8182486789](https://www.flickr.com/photos/usfwspacific/8182486789) CC BY U.S. Fish & Wildlife
Image: [https://www.flickr.com/photos/usfwspacific/8182486789](https://www.flickr.com/photos/usfwspacific/8182486789) by Washington Dept of Fish and Wildlife, originally licensed under [CC-BY-2.0](https://creativecommons.org/licenses/by/2.0/) when the image was imported back in September 2014
![Example](./examples/goodtimes.jpg)
Image: [https://www.flickr.com/photos/endogamia/5682480447](https://www.flickr.com/photos/endogamia/5682480447) by N. Feans
Image: [https://www.flickr.com/photos/endogamia/5682480447](https://www.flickr.com/photos/endogamia/5682480447) by Leon F. Cabeiro (N. Feans), licensed under [CC-BY-2.0](https://creativecommons.org/licenses/by/2.0/)
## Installation
Make sure you have a working Go environment. See the [install instructions](http://golang.org/doc/install.html).
Make sure you have a working Go environment (Go 1.4 or higher is required).
See the [install instructions](http://golang.org/doc/install.html).
To install smartcrop, simply run:
@@ -28,42 +29,42 @@ To compile it from source:
package main
import (
"fmt"
"image"
_ "image/png"
"os"
"fmt"
"image"
_ "image/png"
"os"
"github.com/muesli/smartcrop"
"github.com/muesli/smartcrop"
"github.com/muesli/smartcrop/nfnt"
)
func main() {
f, _ := os.Open("image.png")
img, _, _ := image.Decode(f)
f, _ := os.Open("image.png")
img, _, _ := image.Decode(f)
analyzer := smartcrop.NewAnalyzer()
topCrop, _ := analyzer.FindBestCrop(img, 250, 250)
analyzer := smartcrop.NewAnalyzer(nfnt.NewDefaultResizer())
topCrop, _ := analyzer.FindBestCrop(img, 250, 250)
// The crop will have the requested aspect ratio, but you need to copy/scale it yourself
fmt.Printf("Top crop: %+v\n", topCrop)
// The crop will have the requested aspect ratio, but you need to copy/scale it yourself
fmt.Printf("Top crop: %+v\n", topCrop)
type SubImager interface {
SubImage(r image.Rectangle) image.Image
}
croppedimg := img.(SubImager).SubImage(topCrop)
...
type SubImager interface {
SubImage(r image.Rectangle) image.Image
}
croppedimg := img.(SubImager).SubImage(topCrop)
// ...
}
```
Also see the test cases in crop_test.go for further working examples.
Also see the test cases in smartcrop_test.go for further working examples.
## Sample Data
You can find a bunch of test images for the algorithm [here](https://github.com/muesli/smartcrop-samples).
## Development
API docs can be found [here](http://godoc.org/github.com/muesli/smartcrop).
Join us on IRC: irc.freenode.net/#smartcrop
[![Build Status](https://secure.travis-ci.org/muesli/smartcrop.png)](http://travis-ci.org/muesli/smartcrop)
[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/muesli/smartcrop)
[![Build Status](https://travis-ci.org/muesli/smartcrop.svg?branch=master)](https://travis-ci.org/muesli/smartcrop)
[![Coverage Status](https://coveralls.io/repos/github/muesli/smartcrop/badge.svg?branch=master)](https://coveralls.io/github/muesli/smartcrop?branch=master)
[![Go ReportCard](http://goreportcard.com/badge/muesli/smartcrop)](http://goreportcard.com/report/muesli/smartcrop)

1
vendor/github.com/muesli/smartcrop/debug.go сгенерированный поставляемый
Просмотреть файл

@@ -22,6 +22,7 @@
* Authors:
* Christian Muehlhaeuser <muesli@gmail.com>
* Michael Wendland <michael@michiwend.com>
* Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
*/
/*

53
vendor/github.com/muesli/smartcrop/nfnt/resizer.go сгенерированный поставляемый Обычный файл
Просмотреть файл

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2014-2018 Christian Muehlhaeuser
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Christian Muehlhaeuser <muesli@gmail.com>
* Michael Wendland <michael@michiwend.com>
* Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
*/
package nfnt
import (
"image"
"github.com/muesli/smartcrop/options"
"github.com/nfnt/resize"
)
type nfntResizer struct {
interpolationType resize.InterpolationFunction
}
func (r nfntResizer) Resize(img image.Image, width, height uint) image.Image {
return resize.Resize(width, height, img, r.interpolationType)
}
// NewResizer creates a new Resizer with the given interpolation type.
func NewResizer(interpolationType resize.InterpolationFunction) options.Resizer {
return nfntResizer{interpolationType: interpolationType}
}
// NewDefaultResizer creates a new Resizer with the default interpolation type.
func NewDefaultResizer() options.Resizer {
return NewResizer(resize.Bicubic)
}

38
vendor/github.com/muesli/smartcrop/options/resizer.go сгенерированный поставляемый Обычный файл
Просмотреть файл

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2014-2018 Christian Muehlhaeuser
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Christian Muehlhaeuser <muesli@gmail.com>
* Michael Wendland <michael@michiwend.com>
* Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
*/
package options
import (
"image"
)
// Resizer is used to resize images. See the nfnt package for a default implementation using
// github.com/nfnt/resize.
type Resizer interface {
Resize(img image.Image, width, height uint) image.Image
}

86
vendor/github.com/muesli/smartcrop/smartcrop.go сгенерированный поставляемый
Просмотреть файл

@@ -22,6 +22,7 @@
* Authors:
* Christian Muehlhaeuser <muesli@gmail.com>
* Michael Wendland <michael@michiwend.com>
* Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
*/
/*
@@ -39,9 +40,9 @@ import (
"math"
"time"
"golang.org/x/image/draw"
"github.com/muesli/smartcrop/options"
"github.com/nfnt/resize"
"golang.org/x/image/draw"
)
var (
@@ -95,33 +96,32 @@ type Crop struct {
Score Score
}
// CropSettings contains options to change cropping behaviour
type CropSettings struct {
InterpolationType resize.InterpolationFunction
DebugMode bool
Log *log.Logger
// Logger contains a logger.
type Logger struct {
DebugMode bool
Log *log.Logger
}
type smartcropAnalyzer struct {
cropSettings CropSettings
logger Logger
options.Resizer
}
// NewAnalyzer returns a new analyzer with default settings
func NewAnalyzer() Analyzer {
cropSettings := CropSettings{
InterpolationType: resize.Bicubic,
DebugMode: false,
// NewAnalyzer returns a new Analyzer using the given Resizer.
func NewAnalyzer(resizer options.Resizer) Analyzer {
logger := Logger{
DebugMode: false,
}
return NewAnalyzerWithCropSettings(cropSettings)
return NewAnalyzerWithLogger(resizer, logger)
}
// NewAnalyzerWithCropSettings returns a new analyzer with the given settings
func NewAnalyzerWithCropSettings(cropSettings CropSettings) Analyzer {
if cropSettings.Log == nil {
cropSettings.Log = log.New(ioutil.Discard, "", 0)
// NewAnalyzerWithLogger returns a new analyzer with the given Resizer and Logger.
func NewAnalyzerWithLogger(resizer options.Resizer, logger Logger) Analyzer {
if logger.Log == nil {
logger.Log = log.New(ioutil.Discard, "", 0)
}
return &smartcropAnalyzer{cropSettings: cropSettings}
return &smartcropAnalyzer{Resizer: resizer, logger: logger}
}
func (o smartcropAnalyzer) FindBestCrop(img image.Image, width, height int) (image.Rectangle, error) {
@@ -141,29 +141,29 @@ func (o smartcropAnalyzer) FindBestCrop(img image.Image, width, height int) (ima
if f := prescaleMin / math.Min(float64(img.Bounds().Dx()), float64(img.Bounds().Dy())); f < 1.0 {
prescalefactor = f
}
o.cropSettings.Log.Println(prescalefactor)
o.logger.Log.Println(prescalefactor)
smallimg := resize.Resize(
uint(float64(img.Bounds().Dx())*prescalefactor),
0,
smallimg := o.Resize(
img,
o.cropSettings.InterpolationType)
uint(float64(img.Bounds().Dx())*prescalefactor),
0)
lowimg = toRGBA(smallimg)
} else {
lowimg = toRGBA(img)
}
if o.cropSettings.DebugMode {
if o.logger.DebugMode {
writeImage("png", lowimg, "./smartcrop_prescale.png")
}
cropWidth, cropHeight := chop(float64(width)*scale*prescalefactor), chop(float64(height)*scale*prescalefactor)
realMinScale := math.Min(maxScale, math.Max(1.0/scale, minScale))
o.cropSettings.Log.Printf("original resolution: %dx%d\n", img.Bounds().Dx(), img.Bounds().Dy())
o.cropSettings.Log.Printf("scale: %f, cropw: %f, croph: %f, minscale: %f\n", scale, cropWidth, cropHeight, realMinScale)
o.logger.Log.Printf("original resolution: %dx%d\n", img.Bounds().Dx(), img.Bounds().Dy())
o.logger.Log.Printf("scale: %f, cropw: %f, croph: %f, minscale: %f\n", scale, cropWidth, cropHeight, realMinScale)
topCrop, err := analyse(o.cropSettings, lowimg, cropWidth, cropHeight, realMinScale)
topCrop, err := analyse(o.logger, lowimg, cropWidth, cropHeight, realMinScale)
if err != nil {
return topCrop, err
}
@@ -249,43 +249,43 @@ func score(output *image.RGBA, crop Crop) Score {
return score
}
func analyse(settings CropSettings, img *image.RGBA, cropWidth, cropHeight, realMinScale float64) (image.Rectangle, error) {
func analyse(logger Logger, img *image.RGBA, cropWidth, cropHeight, realMinScale float64) (image.Rectangle, error) {
o := image.NewRGBA(img.Bounds())
now := time.Now()
edgeDetect(img, o)
settings.Log.Println("Time elapsed edge:", time.Since(now))
debugOutput(settings.DebugMode, o, "edge")
logger.Log.Println("Time elapsed edge:", time.Since(now))
debugOutput(logger.DebugMode, o, "edge")
now = time.Now()
skinDetect(img, o)
settings.Log.Println("Time elapsed skin:", time.Since(now))
debugOutput(settings.DebugMode, o, "skin")
logger.Log.Println("Time elapsed skin:", time.Since(now))
debugOutput(logger.DebugMode, o, "skin")
now = time.Now()
saturationDetect(img, o)
settings.Log.Println("Time elapsed sat:", time.Since(now))
debugOutput(settings.DebugMode, o, "saturation")
logger.Log.Println("Time elapsed sat:", time.Since(now))
debugOutput(logger.DebugMode, o, "saturation")
now = time.Now()
var topCrop Crop
topScore := -1.0
cs := crops(o, cropWidth, cropHeight, realMinScale)
settings.Log.Println("Time elapsed crops:", time.Since(now), len(cs))
logger.Log.Println("Time elapsed crops:", time.Since(now), len(cs))
now = time.Now()
for _, crop := range cs {
nowIn := time.Now()
crop.Score = score(o, crop)
settings.Log.Println("Time elapsed single-score:", time.Since(nowIn))
logger.Log.Println("Time elapsed single-score:", time.Since(nowIn))
if crop.totalScore() > topScore {
topCrop = crop
topScore = crop.totalScore()
}
}
settings.Log.Println("Time elapsed score:", time.Since(now))
logger.Log.Println("Time elapsed score:", time.Since(now))
if settings.DebugMode {
if logger.DebugMode {
drawDebugCrop(topCrop, o)
debugOutput(true, o, "final")
}
@@ -472,11 +472,3 @@ func toRGBA(img image.Image) *image.RGBA {
draw.Copy(out, image.Pt(0, 0), img, img.Bounds(), draw.Src, nil)
return out
}
// SmartCrop applies the smartcrop algorithms on the the given image and returns
// the top crop or an error if something went wrong.
// This is still here for legacy/backwards-compat reasons
func SmartCrop(img image.Image, width, height int) (image.Rectangle, error) {
analyzer := NewAnalyzer()
return analyzer.FindBestCrop(img, width, height)
}