We are currently trying to get OpenCV running in a Java job on Google Cloud Dataflow. Unfortunately, we can not replace the Docker container that Dataflow is using with one that has OpenCV installed. (See other question) If we used the Python SDK there is an option to specify a setup.py
file that can be used to invoke apt-get
. Is there something similar for jobs created with the Java SDK?
我们目前正在尝试在Google Cloud Dataflow上的Java作业中运行OpenCV。不幸的是,我们无法将Dataflow正在使用的Docker容器替换为安装了OpenCV的容器。 (参见其他问题)如果我们使用Python SDK,则可以选择指定可用于调用apt-get的setup.py文件。是否有类似于使用Java SDK创建的作业?
thanks for you help!
谢谢你的帮助!
1 个解决方案
#1
0
I came up with a solution, but there might be a more elegant way to do this.
我提出了一个解决方案,但可能有更优雅的方法来做到这一点。
@Setup
public void setupDoFn() {
ProcessBuilder pb = new ProcessBuilder("apt-get", "install", "-y", "libopencv-dev");
try {
Process p = pb.start();
String line;
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
logger.debug("Apt-get: " + line);
}
input.close();
// Initialize the OpenCV Libarary
nu.pattern.OpenCV.loadLibrary();
} catch (IOException e) {
e.printStackTrace();
// If we could not install OpenCV, we have to terminate the stream
System.exit(-1);
}
}
#1
0
I came up with a solution, but there might be a more elegant way to do this.
我提出了一个解决方案,但可能有更优雅的方法来做到这一点。
@Setup
public void setupDoFn() {
ProcessBuilder pb = new ProcessBuilder("apt-get", "install", "-y", "libopencv-dev");
try {
Process p = pb.start();
String line;
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
logger.debug("Apt-get: " + line);
}
input.close();
// Initialize the OpenCV Libarary
nu.pattern.OpenCV.loadLibrary();
} catch (IOException e) {
e.printStackTrace();
// If we could not install OpenCV, we have to terminate the stream
System.exit(-1);
}
}