jviolajones icon indicating copy to clipboard operation
jviolajones copied to clipboard

Constructor issue

Open Pallavi1 opened this issue 10 years ago • 9 comments

Detector detector = new Detector(haarXml); Error:: The constructor Detector(Document) refers to the missing type Document. Please suggest how to rectify it. Thank you!

Pallavi1 avatar Jun 10 '15 11:06 Pallavi1

What is haarXml?

It should be a string path.

tc avatar Jun 10 '15 22:06 tc

Yes, it's the string path only.

Pallavi1 avatar Jun 11 '15 05:06 Pallavi1

can you post a failing unit test i can run easily?

tc avatar Jun 12 '15 20:06 tc

@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());

Pallavi1 avatar Jun 14 '15 08:06 Pallavi1

After doing some changes that error changed to "The constructor Detector(InputStream) is undefined", at the same place (Detector detector = new Detector(haarXml);).

Pallavi1 avatar Jun 15 '15 06:06 Pallavi1

Have you tried specifying the filename as a string instead of an inputstream?

        Detector detector = new Detector("./file.xml");

tc avatar Jun 15 '15 17:06 tc

Yes, I already tried this one but still not working.

Pallavi1 avatar Jun 16 '15 06:06 Pallavi1

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] ------------------------------------------------------------------------

tc avatar Jun 16 '15 17:06 tc

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 ...

fendi66 avatar Apr 17 '17 13:04 fendi66