Skip to content

Commit

Permalink
attempted fix for cameraStreamTest
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed Nov 24, 2023
1 parent 998b0db commit b85a6ce
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.marginallyclever.robotoverlord.services.camerastream;

import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamEvent;
import com.github.sarxos.webcam.WebcamListener;
import com.github.sarxos.webcam.WebcamResolution;
import com.github.sarxos.webcam.*;
import com.marginallyclever.robotoverlord.renderpanel.texturemanager.ImageWithEvents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.awt.*;
import java.awt.image.BufferedImage;
Expand All @@ -18,6 +17,7 @@
* @since 2.11.0
*/
public class CameraStream implements WebcamListener {
private static final Logger logger = LoggerFactory.getLogger(CameraStream.class);
private final Webcam camera;
private final String name;
private final Dimension [] resolutions;
Expand Down Expand Up @@ -84,7 +84,11 @@ public Dimension getCurrentResolution() {
public void open(Dimension resolution) {
if(camera.isOpen()) camera.close();
camera.setViewSize(resolution);
camera.open();
try {
camera.open();
} catch (WebcamException exception) {
logger.error("Failed to open camera.",exception);
}
}

public void close() {
Expand Down

0 comments on commit b85a6ce

Please sign in to comment.