Skip to content

Commit

Permalink
Add OpenCV README
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgk committed Nov 3, 2021
1 parent 56f626a commit 1516156
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ nav:
- Extensions:
- Android: 'android/README.md'
- AWS S3 support: 'extensions/aws-ai/README.md'
- Hadoop support: 'extensions/hadoop/README.md'
- fastText: 'extensions/fasttext/README.md'
- Hadoop support: 'extensions/hadoop/README.md'
- OpenCV: 'extensions/opencv/README.md'
- SentencePiece: 'extensions/sentencepiece/README.md'
- Demos:
- Demos: 'docs/demos/README.md'
Expand Down
26 changes: 26 additions & 0 deletions extensions/opencv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Image support with OpenCV

This module contains the image support extension with [OpenCV](https://opencv.org/). It is based on the [Java package from OpenPnP](https://github.com/openpnp/opencv).

Right now, the package provides an `OpenCVImage` that acts as a faster implementation than the native `BufferedImage`. Once this package is added to your classpath, it will automatically be used through the standard DJL `ImageFactory`.

## Documentation

You can build the latest javadocs locally using the following command:

```sh
./gradlew javadoc
```
The javadocs output is built in the `build/doc/javadoc` folder.

## Installation

You can pull the module from the central Maven repository by including the following dependency in your `pom.xml` file:

```xml
<dependency>
<groupId>ai.djl.opencv</groupId>
<artifactId>opencv</artifactId>
<version>0.14.0</version>
</dependency>
```
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public Image fromNDArray(NDArray array) {
array = array.transpose(1, 2, 0);
shape = array.getShape();
}
int width = (int) shape.get(1);
int height = (int) shape.get(0);
int width = Math.toIntExact(shape.get(1));
int height = Math.toIntExact(shape.get(0));
Mat img = new Mat(height, width, CvType.CV_8UC3);
img.put(0, 0, array.toByteArray());
Imgproc.cvtColor(img, img, Imgproc.COLOR_RGB2BGR);
Expand Down

0 comments on commit 1516156

Please sign in to comment.