Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use javacv for loading opencv #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions video-stream-collector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
</dependency>
<!-- opencv -->
<dependency>
<groupId>opencv</groupId>
<artifactId>opencv</artifactId>
<version>3.2.0</version>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>1.5.6</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -101,4 +101,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.iot.video.app.kafka.collector;

import java.sql.Timestamp;
import java.util.Base64;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.apache.commons.lang.StringUtils;
import org.apache.kafka.clients.producer.Callback;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.log4j.Logger;
import org.opencv.core.Core;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.opencv.opencv_java;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
import org.opencv.videoio.VideoCapture;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.sql.Timestamp;
import java.util.Base64;

/**
* Class to convert Video Frame into byte array and generate JSON event using Kafka Producer.
Expand All @@ -40,7 +40,7 @@ public VideoEventGenerator(String cameraId, String url, Producer<String, String>

//load OpenCV native lib
static {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Loader.load(opencv_java.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@ public class PropertyFileReader {
private static Properties prop = new Properties();
public static Properties readPropertyFile() throws Exception {
if (prop.isEmpty()) {
InputStream input = PropertyFileReader.class.getClassLoader().getResourceAsStream("stream-collector.properties");
try {
try (InputStream input = PropertyFileReader.class.getClassLoader().getResourceAsStream("stream-collector.properties")) {
prop.load(input);
} catch (IOException ex) {
logger.error(ex);
throw ex;
} finally {
if (input != null) {
input.close();
}
}
}
return prop;
Expand Down
12 changes: 9 additions & 3 deletions video-stream-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@
</dependency>
<!-- opencv -->
<dependency>
<groupId>opencv</groupId>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencv</artifactId>
<version>3.2.0</version>
<version>4.5.3-1.5.6</version>
<scope>compile</scope>
</dependency>
</dependencies>

Expand Down Expand Up @@ -118,4 +124,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.List;

import org.apache.log4j.Logger;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.opencv.opencv_java;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
Expand All @@ -32,7 +34,7 @@ public class VideoMotionDetector implements Serializable {

//load native lib
static {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Loader.load(opencv_java.class);
}

/**
Expand Down