-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from VoycerAG/smartcrop
Add optional face recognition
- Loading branch information
Showing
21 changed files
with
26,786 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
server/resizer/testimages/* | ||
server/resizer/testimages_output/* | ||
!server/resizer/testimages/.gitkeep | ||
!server/resizer/testimages_output/.gitkeep | ||
Godeps/_workspace | ||
Godeps/Readme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// +build facedetection | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
|
||
"github.com/VoycerAG/gridfs-image-server/server/paint" | ||
"github.com/VoycerAG/gridfs-image-server/server/resizer" | ||
) | ||
|
||
// main starts the server and returns an invalid result as exit code | ||
func main() { | ||
haarcascade := flag.String("haarcascade", "", "haarcascade file path") | ||
flag.Parse() | ||
|
||
if *configurationFilepath == "" { | ||
log.Fatal("configuration must be given") | ||
return | ||
} | ||
if *haarcascade == "" { | ||
log.Fatal("haarcascade file must be set") | ||
return | ||
} | ||
|
||
smartcrop := resizer.NewSmartcrop(*haarcascade, paint.CropResizer{}) | ||
paint.AddResizer(resizer.TypeSmartcrop, smartcrop) | ||
|
||
run(*host, *configurationFilepath, *newrelicKey, *serverPort) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"allowedEntries" : [ | ||
{ | ||
"name" : "smart2", | ||
"width" : 200, | ||
"height" : 150, | ||
"type" : "smartcrop" | ||
}, | ||
{ | ||
"name" : "smart0", | ||
"width" : 45, | ||
"height" : 35, | ||
"type" : "smartcrop" | ||
}, | ||
{ | ||
"name" : "45x35", | ||
"width" : 45, | ||
"height" : 35, | ||
"type" : "fit" | ||
}, | ||
{ | ||
"name" : "smart1", | ||
"width" : 294, | ||
"height" : 300, | ||
"type" : "smartcrop" | ||
}, | ||
{ | ||
"name" : "294x300", | ||
"width" : 294, | ||
"height" : 300, | ||
"type" : "fit" | ||
}, | ||
{ | ||
"name" : "294x210", | ||
"width" : 294, | ||
"height" : 210, | ||
"type" : "crop" | ||
}, | ||
{ | ||
"name" : "105x95", | ||
"width" : 105, | ||
"height" : 95, | ||
"type" : "crop" | ||
}, | ||
{ | ||
"name" : "288x200", | ||
"width" : 288, | ||
"height" : 200, | ||
"type" : "crop" | ||
}, | ||
{ | ||
"name" : "50x40", | ||
"width" : 50, | ||
"height" : 40, | ||
"type" : "crop" | ||
}, | ||
{ | ||
"name" : "50x50", | ||
"width" : 50, | ||
"height" : 50, | ||
"type" : "crop" | ||
}, | ||
{ | ||
"name" : "130x260", | ||
"width" : 130, | ||
"height" : 260, | ||
"type" : "fit" | ||
}, | ||
{ | ||
"name" : "310x230", | ||
"width" : 310, | ||
"height" : 230, | ||
"type" : "fit" | ||
}, | ||
{ | ||
"name" : "302x302", | ||
"width" : 302, | ||
"height" : 302, | ||
"type" : "fit" | ||
}, | ||
{ | ||
"name" : "150x150", | ||
"width" : 150, | ||
"height" : 150, | ||
"type" : "crop" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,20 @@ | ||
// +build !facedetection | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"net/http" | ||
|
||
"gopkg.in/mgo.v2" | ||
|
||
"github.com/VoycerAG/gridfs-image-server/server" | ||
) | ||
|
||
// main starts the server and returns an invalid result as exit code | ||
func main() { | ||
configurationFilepath := flag.String("config", "configuration.json", "path to the configuration file") | ||
serverPort := flag.Int("port", 8000, "the server port where we will serve images") | ||
host := flag.String("host", "localhost:27017", "the database host with an optional port, localhost would suffice") | ||
newrelicKey := flag.String("license", "", "your newrelic license key in order to enable monitoring") | ||
|
||
flag.Parse() | ||
|
||
if *configurationFilepath == "" { | ||
log.Fatal("configuration must be given") | ||
return | ||
} | ||
|
||
config, err := server.NewConfigFromFile(*configurationFilepath) | ||
if err != nil { | ||
log.Fatal(err) | ||
return | ||
} | ||
|
||
session, err := mgo.Dial(*host) | ||
if err != nil { | ||
log.Fatal(err) | ||
return | ||
} | ||
|
||
session.SetSyncTimeout(0) | ||
session.SetMode(mgo.Eventual, true) | ||
|
||
storage, err := server.NewGridfsStorage(session) | ||
if err != nil { | ||
log.Fatal(err) | ||
return | ||
} | ||
|
||
imageServer := server.NewImageServerWithNewRelic(config, storage, *newrelicKey) | ||
|
||
handler := imageServer.Handler() | ||
|
||
log.Printf("Server started. Listening on %d database host is %s\n", *serverPort, *host) | ||
|
||
err = http.ListenAndServe(fmt.Sprintf(":%d", *serverPort), handler) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
run(*host, *configurationFilepath, *newrelicKey, *serverPort) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"net/http" | ||
|
||
"github.com/VoycerAG/gridfs-image-server/server" | ||
"gopkg.in/mgo.v2" | ||
) | ||
|
||
var ( | ||
configurationFilepath *string | ||
serverPort *int | ||
host *string | ||
newrelicKey *string | ||
) | ||
|
||
func init() { | ||
configurationFilepath = flag.String("config", "configuration.json", "path to the configuration file") | ||
serverPort = flag.Int("port", 8000, "the server port where we will serve images") | ||
host = flag.String("host", "localhost:27017", "the database host with an optional port, localhost would suffice") | ||
newrelicKey = flag.String("license", "", "your newrelic license key in order to enable monitoring") | ||
} | ||
|
||
func run(mongoHost, configFile, newrelicToken string, port int) { | ||
session, err := mgo.Dial(*host) | ||
if err != nil { | ||
log.Fatal(err) | ||
return | ||
} | ||
|
||
config, err := server.NewConfigFromFile(configFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
return | ||
} | ||
|
||
session.SetSyncTimeout(0) | ||
session.SetMode(mgo.Eventual, true) | ||
|
||
storage, err := server.NewGridfsStorage(session) | ||
if err != nil { | ||
log.Fatal(err) | ||
return | ||
} | ||
|
||
imageServer := server.NewImageServerWithNewRelic(config, storage, newrelicToken) | ||
|
||
handler := imageServer.Handler() | ||
|
||
log.Printf("Server started. Listening on %d database host is %s\n", port, mongoHost) | ||
|
||
err = http.ListenAndServe(fmt.Sprintf(":%d", port), handler) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
Oops, something went wrong.