Skip to content

Commit

Permalink
add depthai_sdk (#1436)
Browse files Browse the repository at this point in the history
Co-authored-by: GroG <[email protected]>
  • Loading branch information
hairygael and GroG authored Jan 7, 2025
1 parent 3895076 commit 2ba5e79
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/main/java/org/myrobotlab/service/OakD.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

/**
*
* https://github.com/luxonis/depthai
* python3 depthai_demo.py -cb callbacks.py
* https://github.com/luxonis/depthai python3 depthai_demo.py -cb callbacks.py
*
* https://github.com/luxonis/depthai-experiments/tree/master/gen2-face-recognition
*
Expand Down Expand Up @@ -69,6 +68,7 @@ public void installDepthAi() {

// git.clone("./", config.depthaiCloneUrl)
List<String> packages = new ArrayList<>();
packages.add("depthai_sdk==1.15.1");
packages.add("depthai==2.29.0");
packages.add("blobconverter==1.4.3");
packages.add("opencv-python");
Expand All @@ -79,19 +79,19 @@ public void installDepthAi() {
}
// py4j.exec("");
}

public void startRecognition() {

}

public void stopRecognition() {

}

/**
* FIXME - turn into interface
* Will publish processing messages to the processor(s) currently
* subscribed.
* FIXME - turn into interface Will publish processing messages to the
* processor(s) currently subscribed.
*
* @param method
* @param data
*/
Expand All @@ -102,9 +102,8 @@ public void processMessage(String method, Object data) {
}

/**
* FIXME - turn into interface
* Processing publishing point, where everything InMoov2 wants to be processed
* is turned into a message and published.
* FIXME - turn into interface Processing publishing point, where everything
* InMoov2 wants to be processed is turned into a message and published.
*
* @param msg
* @return
Expand All @@ -113,7 +112,6 @@ public Message publishProcessMessage(Message msg) {
return msg;
}


public Classification publishClassification(Classification classification) {
classification.src = getName();
// we have a detection or recognition event ... publish the associated image
Expand All @@ -122,19 +120,19 @@ public Classification publishClassification(Classification classification) {
// imageToWeb("classification.png");
invoke("imageToWeb", "classification.png");
}

return classification;
}

public String imageToWeb(String filePath) {
byte[] content = null;
try (FileInputStream fileInputStream = new FileInputStream(new File(filePath))) {
content = new byte[(int) new File(filePath).length()];
fileInputStream.read(content);
String img = Base64.getEncoder().encodeToString(content);
return String.format("data:image/png;base64,%s", img);
content = new byte[(int) new File(filePath).length()];
fileInputStream.read(content);
String img = Base64.getEncoder().encodeToString(content);
return String.format("data:image/png;base64,%s", img);
} catch (IOException e) {
error(e);
error(e);
}
return null;
}
Expand Down

0 comments on commit 2ba5e79

Please sign in to comment.