Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
oskopek committed Aug 26, 2014
2 parents f900000 + 6a18a2b commit 42f033e
Show file tree
Hide file tree
Showing 43 changed files with 570 additions and 415 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
global:
- WILDFLY="8.0.0.CR1"
- JBOSS_HOME=$HOME/wildfly-$WILDFLY
- MAVEN_PROFILES="it,wildfly-it-travis"
- secure: WrQYhD3HBLqpKj83AxUH+Gf1EL1vlAX/kcfTAMPSJdjyIcYR/U1b0BYl9ne8Glro8UopZrH8X+3I0oP6GXXG7ihnb8L2sawCutC9EyccQOvFcfuMttSMhTpJpnLSLqEw5Gdp3qb4WDHOFALfo0G4hd/Yr2iIxSp/x6DQAuIz76M=

cache:
Expand All @@ -23,12 +24,11 @@ before_script:
- cd $ROOT_DIR
- cp carcv-webapp/src/test/resources/wildfly_configuration_standalone/standalone.xml $JBOSS_HOME/standalone/configuration/standalone.xml

script: "mvn clean verify -Pwildfly-it-travis"
script: "mvn clean verify -P$MAVEN_PROFILES"

install: /bin/true

after_success:
- mvn clean cobertura:cobertura coveralls:cobertura -Pwildfly-it-travis
after_success: "mvn clean cobertura:cobertura coveralls:cobertura -P$MAVEN_PROFILES"

notifications:
irc:
Expand All @@ -37,4 +37,4 @@ notifications:
on_success: change
on_failure: always
template:
- '%{repository} (%{branch}:%{commit} by %{author}): %{message} (%{build_url})'
- "%{repository} (%{branch}:%{commit} by %{author}): %{message} (%{build_url})"
2 changes: 1 addition & 1 deletion AUTHORS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
|Matej Pribis
|mattblackhand
|matejpribis@gmail.com
|WebApp HTML and CSS code... destroying what's left
|WebApp HTML and CSS code

|===
92 changes: 36 additions & 56 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
== CarCV

image:https://travis-ci.org/oskopek/carcv.png?branch=master["Build Status", link="https://travis-ci.org/oskopek/carcv"]
image:https://coveralls.io/repos/oskopek/carcv/badge.png?branch=develop["Coverage status", link="https://coveralls.io/r/oskopek/carcv?branch=develop"]
image:https://travis-ci.org/oskopek/carcv.svg?branch=master["Build Status", link="https://travis-ci.org/oskopek/carcv"]
image:https://coveralls.io/repos/oskopek/carcv/badge.png?branch=master["Coverage status", link="https://coveralls.io/r/oskopek/carcv?branch=master"]
image:https://www.ohloh.net/p/carcv/widgets/project_thin_badge.gif["Ohloh widget", link="https://www.ohloh.net/p/carcv"]

A car recognizing and speed calculation platform.

== Info

CarCV uses http://semver.org/[semantic versioning] and a branching model similar to http://nvie.com/posts/a-successful-git-branching-model/[this].

== Modules
=== Screenshot
image:http://cdn.imghack.se/images/a6f3be78f72232fa6e9f09a11c53f7a6.png["CarCV screenshot", scalewidth="20%"]

=== Modules
CarCV consists of several modules:

* *carcv-core* -- CarCV Core
* *carcv-cpp* -- CarCV CPP is an old and deprecated implementation of this project in C++ with heavy use of OpenCV
* *carcv-webapp* -- CarCV WebApp is an example implementation of CarCV Core
* *carcv-core* -- core detection and recognition module
* *carcv-cpp* -- an old and deprecated implementation of this project in C++ with heavy use of OpenCV
* *carcv-webapp* -- a Java EE web-app implementation of the CarCV Core

== Building
CarCV uses http://semver.org/[semantic versioning].

* *Recomennded*: +mvn clean install -DskipTests+
=== Building
* See: How-to setup your *build environment*:
link:./docs/howto-setup-environment-windows.adoc[Windows], link:./docs/howto-setup-environment-linux.adoc[Linux & Mac]
* *Recommended*: +mvn clean install -DskipTests+
* To run *unit tests*: +mvn clean install+
* To run *integration tests*: +mvn clean install -Pwildfly-it+
(see link:./docs/howto-setup-environment.adoc[How-to setup your build environment])
* To run *integration tests*: +mvn clean install -Pit,wildfly-it+
* To *clean*, run: +mvn clean+
* Run a simple link:./docs/core/core-usage.adoc[carcv-core demo]

=== Getting help

* Post questions or comments on our Google Groups link:https://groups.google.com/d/forum/carcv[mailing list]
* Join our *IRC channel*: Join *#carcv* on *irc.freenode.net*

=== Contributing
*Everyone* is encouraged to help improve this project.

Here are some ways *you* can contribute:

* by using alpha, beta, and prerelease versions
* by using alpha, beta, and pre-release versions
* by reporting bugs
* by suggesting new features
* by implementing link:./docs/goals.adoc[planned features]
* by translating to a new language
* by writing or editing documentation
* by link:./docs/howto-write-documentation.adoc[writing or editing documentation]
* by writing specifications
* by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
* by refactoring code
Expand All @@ -51,50 +57,24 @@ that includes a stack trace and any details that may be necessary to reproduce
the bug, including your Java version and operating system.

=== Submitting a Pull Request
. http://help.github.com/fork-a-repo/[Fork the repository.]
. http://learn.github.com/p/branching.html[Create a topic branch.]
. Implement your feature or bug fix.
. Run +mvn clean install+ or if you contributed to _carcv-webapp_ run mvn clean install. If the tests fails, return to step 3.
. If applicable, add tests for your feature or bug fix.
. Add, commit, and push your changes.
. http://help.github.com/send-pull-requests/[Submit a pull request.]


== Configuring the project with the m2eclipse plugin

. http://help.github.com/fork-a-repo/[Fork the repository]
. http://learn.github.com/p/branching.html[Create a topic branch]
. Implement your feature or bug fix
. If applicable, add tests for your feature or bug fix
. Run +mvn clean install -Pit+
.. If you contributed to *carcv-webapp*, run: `mvn clean install -Pit,wildfly-it`
. If the tests fail, return to step 3 and 4
. Add, commit, and push your changes
. http://help.github.com/send-pull-requests/[Submit a pull request]


=== Configuring the project for Eclipse with the m2eclipse plugin
The m2eclipse plugin is a plugin in Eclipse for Maven.
This is the new way (and compatible with tycho).

* Open Eclipse
* Follow http://m2eclipse.sonatype.org/[the installation instructions of m2eclipse].
* Follow link:http://m2eclipse.sonatype.org/m2eclipse[the installation instructions of m2eclipse].
** Follow the link *Installing m2eclipse* at the bottom.
* Click menu *File*, menu item *Import*, tree item *Maven*, tree item *Existing Maven Projects*.
* Click button *Browse*, select a repository directory. For example `~/git/carcv`.
* Click button *Browse*, select a repository directory. For example: `~/git/carcv`.

For more information, see http://www.sonatype.com/books/m2eclipse-book/reference/[the m2eclipse book]

== Configuring the project with the deprecated maven-eclipse-plugin

[WARNING]
====
Note: This way of configuring the project is old and deprecated.
Please read the section
link:#configuring-the-project-with-the-m2eclipse-plugin[Configuring the project with the m2eclipse plugin]
above.
====

The maven-eclipse-plugin plugin is a plugin in Maven for Eclipse.
This is the old way (of which the development has stopped).

Run this command to generate `.project` and `.classpath` files:

`mvn eclipse:eclipse`

* Open Eclipse
* Menu item *Import existing projects*, navigate to the project base directory, select all the projects (= modules) it lists.

[NOTE]
====
`mvn eclipse:eclipse` does not work for our eclipse plugins because it is not compatible with tycho
(and never will be).
====
56 changes: 51 additions & 5 deletions carcv-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -14,6 +14,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTests>false</skipTests>
<skipUTs>${skipTests}</skipUTs>
<skipITs>true</skipITs>
</properties>

<build>
Expand All @@ -33,6 +36,31 @@
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skipTests>${skipUTs}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<skipTests>${skipTests}</skipTests>
<skipITs>${skipITs}</skipITs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
Expand Down Expand Up @@ -65,13 +93,18 @@
<dependency>
<groupId>net.sf.javaanpr</groupId>
<artifactId>javaanpr</artifactId>
<version>1.2.6</version>
<version>1.2.7</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>20030203.000129</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>13.0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -81,13 +114,26 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<type>pom</type>
<scope>provided</scope> <!-- TODO 3 may cause problems in .jar package -->
<!-- TODO 3 Provided scope may cause problems in .jar package -->
<scope>provided</scope>
</dependency>
</dependencies>
</project>

<profiles>
<profile>
<id>it</id>
<!-- Integration Tests -->
<properties>
<skipTests>false</skipTests>
<skipITs>${skipTests}</skipITs>
<skipUTs>${skipTests}</skipUTs>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

import javax.xml.parsers.ParserConfigurationException;

Expand All @@ -31,34 +27,40 @@

import org.carcv.core.detect.NumberPlateDetector;
import org.carcv.core.model.AbstractCarImage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.carcv.impl.core.util.CollectionUtils;
import org.xml.sax.SAXException;

/**
* A Singleton implementation of <code>NumberPlateDetector</code> based on <a
* An implementation of <code>NumberPlateDetector</code> based on <a
* href="https://github.com/oskopek/javaanpr.git">JavaANPR</a>.
*
* <p>
* Make sure all images are loaded in advance!
*
*/
public class NumberPlateDetectorImpl extends NumberPlateDetector {

final private static Logger LOGGER = LoggerFactory.getLogger(NumberPlateDetectorImpl.class);

private static NumberPlateDetectorImpl detector = new NumberPlateDetectorImpl();

private NumberPlateDetectorImpl() {
private static NumberPlateDetectorImpl detector;
private Intelligence intel;

public NumberPlateDetectorImpl() throws IllegalStateException {
try {
intel = new Intelligence();
} catch (ParserConfigurationException | SAXException | IOException e) {
IllegalStateException ise = new IllegalStateException("Error occurred while initializing detector");
ise.addSuppressed(e);
throw ise;
}
}

/**
* Returns a reference to the static singleton instantiation of NumberPlateDetectorImpl
*
* @return reference to static NumberPlateDetectorImpl instance
* @return reference to static NumberPlateDetectorImpl instance, null if an error occurs during initialization
*/
public static NumberPlateDetectorImpl getInstance() {
public static NumberPlateDetectorImpl getInstance() throws IllegalStateException {
if (detector == null) {
detector = new NumberPlateDetectorImpl();
}
return detector;
}

Expand All @@ -69,46 +71,15 @@ public String detect(final List<? extends AbstractCarImage> images) {

@Override
public String detectPlateText(final List<? extends AbstractCarImage> images) {

Intelligence intel;
try {
intel = new Intelligence();
} catch (ParserConfigurationException | SAXException | IOException e) {
LOGGER.error("Error occured while detecting plate text!");
e.printStackTrace();
return null;
}

ArrayList<String> numberPlates = new ArrayList<>();

for (AbstractCarImage image : images) {
numberPlates.add(intel.recognize(new CarSnapshot(image.getImage())));
}

return getAverageNumberPlate(numberPlates);
return CollectionUtils.highestCountElement(numberPlates);
}

@Override
public String detectPlateOrigin(final List<? extends AbstractCarImage> images) {
return "UN"; // TODO 3 Unimplemented number plate origin
}

private static String getAverageNumberPlate(final List<String> numberPlates) {
HashMap<String, Integer> map = new HashMap<>();

for (String s : numberPlates) {
Integer count = map.get(s);
map.put(s, count != null ? count + 1 : 0);
}

String popular = Collections.max(map.entrySet(), new Comparator<Entry<String, Integer>>() {

@Override
public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
return o1.getValue().compareTo(o2.getValue());
}
}).getKey();

return popular;
}
}
}
Loading

0 comments on commit 42f033e

Please sign in to comment.