some fixes
This commit is contained in:
@@ -14,9 +14,13 @@ public class WebcamCaptureLoop {
|
||||
this.webcam = webcam;
|
||||
this.onFrameCaptured = onFrameCaptured;
|
||||
|
||||
// Configure webcam
|
||||
Dimension[] sizes = webcam.getViewSizes();
|
||||
webcam.setViewSize(sizes[sizes.length - 1]);
|
||||
// this is some of the most stupid shit ive seen in years, this is needed for opening the stream.
|
||||
// the webcam package may not know the res before its opened and well this is before we open it. that is below in the thread.
|
||||
// so this freaks out and doesnt want to cooperate.
|
||||
if (!webcam.getName().toLowerCase().contains("ipcam")) {
|
||||
Dimension[] sizes = webcam.getViewSizes();
|
||||
webcam.setViewSize(sizes[sizes.length - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
@@ -24,11 +28,13 @@ public class WebcamCaptureLoop {
|
||||
running = true;
|
||||
|
||||
Thread captureThread = new Thread(() -> {
|
||||
// this is where we open it. if the res isnt known then it fucks up.
|
||||
webcam.open();
|
||||
|
||||
while (running) {
|
||||
BufferedImage img = webcam.getImage();
|
||||
if (img != null) {
|
||||
//System.err.println(img);
|
||||
onFrameCaptured.accept(img);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user