0

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?

thekucays
  • 568
  • 3
  • 9
  • 32
  • It might be easier and more reliable to create a virtual webcam than altering an existing webcam's feed. – Matthew Dec 05 '18 at 21:00
  • @Matthew could show me links that related to this? :D – thekucays Dec 06 '18 at 06:47
  • this SO questions answer has a lot of links that may help you. https://stackoverflow.com/questions/8557723/virtual-webcam-input-as-byte-stream – Matthew Dec 06 '18 at 14:07
  • @Matthew thanks, gonna check that – thekucays Dec 06 '18 at 14:11
  • It would be a lot easier to just use a 3rd party app than write your own. There are plenty of streaming applications that are free and allow you to capture your screen, add overlays, animations etc... – Matthew Dec 06 '18 at 14:16

0 Answers0