Skip to content

Commit 62fff80

Browse files
author
xinzhifu
committed
人脸识别完整demo
1 parent 2cc57ce commit 62fff80

34 files changed

+2062
-23
lines changed

.idea/compiler.xml

Lines changed: 18 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* Copyright 2007-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import java.util.Properties;
17+
18+
public class MavenWrapperDownloader {
19+
20+
private static final String WRAPPER_VERSION = "0.5.6";
21+
/**
22+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
23+
*/
24+
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
25+
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
26+
27+
/**
28+
* Path to the maven-wrapper.properties file, which might contain BaiDuFaceSearchResult downloadUrl property to
29+
* use instead of the default one.
30+
*/
31+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
32+
".mvn/wrapper/maven-wrapper.properties";
33+
34+
/**
35+
* Path where the maven-wrapper.jar will be saved to.
36+
*/
37+
private static final String MAVEN_WRAPPER_JAR_PATH =
38+
".mvn/wrapper/maven-wrapper.jar";
39+
40+
/**
41+
* Name of the property which should be used to override the default download url for the wrapper.
42+
*/
43+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
44+
45+
public static void main(String args[]) {
46+
System.out.println("- Downloader started");
47+
File baseDirectory = new File(args[0]);
48+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
49+
50+
// If the maven-wrapper.properties exists, read it and check if it contains BaiDuFaceSearchResult custom
51+
// wrapperUrl parameter.
52+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
53+
String url = DEFAULT_DOWNLOAD_URL;
54+
if(mavenWrapperPropertyFile.exists()) {
55+
FileInputStream mavenWrapperPropertyFileInputStream = null;
56+
try {
57+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
58+
Properties mavenWrapperProperties = new Properties();
59+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
60+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
61+
} catch (IOException e) {
62+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
63+
} finally {
64+
try {
65+
if(mavenWrapperPropertyFileInputStream != null) {
66+
mavenWrapperPropertyFileInputStream.close();
67+
}
68+
} catch (IOException e) {
69+
// Ignore ...
70+
}
71+
}
72+
}
73+
System.out.println("- Downloading from: " + url);
74+
75+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
76+
if(!outputFile.getParentFile().exists()) {
77+
if(!outputFile.getParentFile().mkdirs()) {
78+
System.out.println(
79+
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
80+
}
81+
}
82+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
83+
try {
84+
downloadFileFromURL(url, outputFile);
85+
System.out.println("Done");
86+
System.exit(0);
87+
} catch (Throwable e) {
88+
System.out.println("- Error downloading");
89+
e.printStackTrace();
90+
System.exit(1);
91+
}
92+
}
93+
94+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
95+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
96+
String username = System.getenv("MVNW_USERNAME");
97+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
98+
Authenticator.setDefault(new Authenticator() {
99+
@Override
100+
protected PasswordAuthentication getPasswordAuthentication() {
101+
return new PasswordAuthentication(username, password);
102+
}
103+
});
104+
}
105+
URL website = new URL(urlString);
106+
ReadableByteChannel rbc;
107+
rbc = Channels.newChannel(website.openStream());
108+
FileOutputStream fos = new FileOutputStream(destination);
109+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
110+
fos.close();
111+
rbc.close();
112+
}
113+
114+
}
49.5 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
Binary file not shown.

0 commit comments

Comments
 (0)