some fixes

This commit is contained in:
2026-01-04 18:13:21 +01:00
parent 908a4c8bab
commit ddba427205
10 changed files with 328 additions and 39 deletions

View File

@@ -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);
}