eduramiba / webcam-capture-driver-native

Native driver for Webcam Capture API
25 stars 8 forks source link

Inconsistency in WebcamDevice#getImage Method Implementation and its Impact on WebcamPanel Repainting #19

Closed jumkey closed 9 months ago

jumkey commented 9 months ago

The WebcamDevice#getImage method is implemented inconsistently compared to the built-in WebcamDefaultDevice, which returns a new BufferedImage object. This inconsistency currently results in the WebcamPanel not executing repaintPanel().

This line always evaluates to true. https://github.com/sarxos/webcam-capture/blob/fdfcaea80c8f50eeb8f7c24475ff85a3c1fdcb32/webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamPanel.java#L603

eduramiba commented 9 months ago

Hi Jumkey,

To avoid unnecessary allocation of memory each frame, this driver returns the same image with data updated.

The recommended use is to have a custom panel or similar, but if you want to use WebcamPanel, you can wrap our class into another decorator class that creates a copy of the image each time it's requested.