jviolajones
jviolajones copied to clipboard
Constructor issue
Detector detector = new Detector(haarXml); Error:: The constructor Detector(Document) refers to the missing type Document. Please suggest how to rectify it. Thank you!
What is haarXml?
It should be a string path.
Yes, it's the string path only.
can you post a failing unit test i can run easily?
@Test public void testDetector() throws IOException{ File img = new File("src/Images/20150303090518562.jpg"); InputStream haarXml = Detector.class.getResourceAsStream("/file.xml");
Detector detector = new Detector(haarXml);
List<Rectangle> res = detector.getFaces(img.getAbsolutePath(), 1, 1.25f, 0.1f,1,true);
Rectangle first = res.get(0);
Rectangle second = res.get(1);
assertEquals(2, res.size());
After doing some changes that error changed to "The constructor Detector(InputStream) is undefined", at the same place (Detector detector = new Detector(haarXml);).
Have you tried specifying the filename as a string instead of an inputstream?
Detector detector = new Detector("./file.xml");
Yes, I already tried this one but still not working.
If you git clone this project and run:
→$cd jviolajones/
→$mvn test
What output do you get? This works for me on Mac OS X 10. Do you have Java 8?
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jviolajones 1.0.2
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/jdom/jdom/1.1/jdom-1.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/jdom/jdom/1.1/jdom-1.1.pom (0 B at 0.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/junit/junit/4.8.2/junit-4.8.2.pom
Downloaded: http://repo.maven.apache.org/maven2/junit/junit/4.8.2/junit-4.8.2.pom (0 B at 0.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/jdom/jdom/1.1/jdom-1.1.jar
Downloading: http://repo.maven.apache.org/maven2/junit/junit/4.8.2/junit-4.8.2.jar
Downloaded: http://repo.maven.apache.org/maven2/org/jdom/jdom/1.1/jdom-1.1.jar (0 B at 0.0 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/junit/junit/4.8.2/junit-4.8.2.jar (0 B at 0.0 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ jviolajones ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ jviolajones ---
[INFO] Compiling 6 source files to /Users/tchheng/src/java/jviolajones/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ jviolajones ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ jviolajones ---
[INFO] Compiling 1 source file to /Users/tchheng/src/java/jviolajones/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ jviolajones ---
[INFO] Surefire report directory: /Users/tchheng/src/java/jviolajones/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running jviolajones.DetectorTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.391 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.743s
[INFO] Finished at: Tue Jun 16 10:46:16 PDT 2015
[INFO] Final Memory: 20M/491M
[INFO] ------------------------------------------------------------------------
public static void main(String[] args) throws IOException { new DetectorView(new File(args[2]), args[1]).setVisible(true); }
i can't run, because in DetectorView.java
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 at jviolajones.DetectorView.main(DetectorView.java:31) Java Result: 1 BUILD SUCCESSFUL (total time: 6 seconds) please, help me ...