i need to inject some picture to webcam feed for some android automation test purposes
Here are what i found so far:
1. using 3rd party app - https://splitcam.com/
2. found interesting repo on github - https://github.com/sarxos/webcam-capture/tree/master/webcam-capture-examples/webcam-capture-transformer
when i see the examples available on poin 2, there's method that could "transform" some BufferedImage
to the webcam, and then previewing it back via java JPanel.
Sample code for transforming image (taken from the point 2 examples):
public BufferedImage transform(BufferedImage image) {
int w = image.getWidth();
int h = image.getHeight();
BufferedImage modified = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = modified.createGraphics();
g2.drawImage(image, null, 0, 0);
g2.drawImage(IMAGE_FRAME, null, 0, 0);
g2.dispose();
modified.flush();
return modified;
}
Sample code for putting it back to JPanel (taken from the point 2 examples):
JFrame window = new JFrame("Test Transformer");
window.setLayout(new FlowLayout(FlowLayout.CENTER));
window.add(panel);
window.pack();
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
what i need is slighty different than on point 2, i want to modify the webcam feed with some images, and then putting it back to webcam feed. is that possible?