This repository was archived by the owner on Dec 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPythonImageProcessor.java
More file actions
53 lines (40 loc) · 1.53 KB
/
Copy pathPythonImageProcessor.java
File metadata and controls
53 lines (40 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import jep.*;
import org.opencv.core.*;
public class PythonImageProcessor {
Jep jep;
public PythonImageProcessor() {
try(Jep jep = new Jep(false)) {
float[] f = new float[] { 1.0f, 2.1f, 3.3f, 4.5f, 5.6f, 6.7f };
NDArray<float[]> nd = new NDArray<>(f, 3, 2);
jep.set("x", nd);
jep.eval("print x");
} catch (JepException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void findPeg(Mat inImg,Mat outImg) {
try(Jep jep = new Jep(false)) {
jep.eval("import cv2");
jep.eval("print cv2.__version__");
jep.eval("import sys");
jep.eval("sys.path.append('C:/Users/Team138/Vision2017')");
jep.eval("import vision2017");
jep.eval("vision2017.filename='C:/Users/Team138/Vision2017/LED Peg/1ftH3ftD0Angle0Brightness.jpg'");
jep.eval("vision2017.processFile()");
//jep.invoke("vision2017.processFile1","'C:/Users/Team138/Vision2017/LED Peg/1ftH3ftD0Angle0Brightness.jpg'");
Object xcenter = jep.getValue("vision2017.xcenter");
Object ycenter = jep.getValue("vision2017.ycenter");
Object width = jep.getValue("vision2017.width");
System.out.println("Xcenter " + xcenter);
System.out.println("Ycenter " + ycenter);
System.out.println("Width " + width);
} catch (JepException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}