Skip to content

Commit

Permalink
* Turn Mat.createFrom() into a static factory method, and make `Ma…
Browse files Browse the repository at this point in the history
…t.copyFrom()` call `Mat.create()` as appropriate (issue #1)
  • Loading branch information
saudet committed May 6, 2014
1 parent e5a6385 commit e0782d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Turn `Mat.createFrom()` into a static factory method, and make `Mat.copyFrom()` call `Mat.create()` as appropriate ([issue #1](https://github.com/bytedeco/javacpp-presets/issues/1))
* Add missing `native_camera` modules of `opencv_highgui` for Android
* Fix functions from `opencv_stitching` not accepting a `MatVector` as apparently intended by the API (issue javacv:466)

Expand Down
2 changes: 1 addition & 1 deletion opencv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv</artifactId>
<version>2.4.9-${project.parent.version}-1-SNAPSHOT</version>
<version>2.4.9-${project.parent.version}-2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>JavaCPP Presets for OpenCV</name>

Expand Down
17 changes: 11 additions & 6 deletions opencv/src/main/java/org/bytedeco/javacpp/helper/opencv_core.java
Original file line number Diff line number Diff line change
Expand Up @@ -2297,13 +2297,18 @@ public static abstract class AbstractMat extends AbstractArray {
public AbstractMat() { }
public AbstractMat(Pointer p) { super(p); }

public void createFrom(BufferedImage image) {
createFrom(image, 1.0);
public static Mat createFrom(BufferedImage image) {
return createFrom(image, 1.0);
}
public static Mat createFrom(BufferedImage image, double gamma) {
return createFrom(image, gamma, false);
}
public void createFrom(BufferedImage image, double gamma) {
createFrom(image, gamma, false);
public static Mat createFrom(BufferedImage image, double gamma, boolean flipChannels) {
Mat m = new Mat();
m.copyFrom(image, gamma, flipChannels, null);
return m;
}
public void createFrom(BufferedImage image, double gamma, boolean flipChannels) {
@Override public void copyFrom(BufferedImage image, double gamma, boolean flipChannels, Rectangle roi) {
if (image == null) {
release();
return;
Expand Down Expand Up @@ -2331,7 +2336,7 @@ public void createFrom(BufferedImage image, double gamma, boolean flipChannels)
}
}
create(image.getWidth(), image.getHeight(), CV_MAKETYPE(depth, numChannels));
copyFrom(image, gamma, flipChannels);
super.copyFrom(image, gamma, flipChannels, roi);
}

public abstract void create(int rows, int cols, int type);
Expand Down

0 comments on commit e0782d1

Please sign in to comment.