Skip to content

Commit

Permalink
Capture better.
Browse files Browse the repository at this point in the history
  • Loading branch information
penguinencounter committed Aug 3, 2024
1 parent 217876b commit 7db1ffb
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Capture.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.firstinspires.ftc.teamcode;

import static org.firstinspires.ftc.vision.VisionPortal.CameraState.STREAMING;

import android.graphics.Canvas;
import android.os.Environment;
import android.util.Log;
Expand Down Expand Up @@ -65,26 +67,38 @@ public void runOpMode() throws InterruptedException {
.setCameraResolution(new Size(1920, 1080))
.addProcessor(proc)
.build();
ExposureControl exposure = portal.getCameraControl(ExposureControl.class);
long micros = exposure.getMinExposure(TimeUnit.MICROSECONDS);
exposure.setExposure(micros, TimeUnit.MICROSECONDS);

boolean isAPressed = false;
boolean configured = false;

while (opModeInInit()) {
if (gamepad1.a && !isAPressed) {
if (portal.getCameraState() == STREAMING && !configured) {
ExposureControl exposure = portal.getCameraControl(ExposureControl.class);
exposure.setMode(ExposureControl.Mode.Manual);
long micros = exposure.getMinExposure(TimeUnit.MILLISECONDS);
exposure.setExposure(200, TimeUnit.MILLISECONDS);
configured = true;
}
boolean nonVolatileA = gamepad1.a;
if (nonVolatileA && !isAPressed) {
Log.i("Capture", "Saving");
// try to avoid getting deallocated while saving by cloning
Mat imm = proc.latest.clone();
save(imm);
imm.release();
Log.i("Capture", "Done");
}
if (configured) {

ExposureControl exposure = portal.getCameraControl(ExposureControl.class);
telemetry.addData("Exposure (ms)", exposure.getExposure(TimeUnit.MILLISECONDS));
}
telemetry.addData("Frame", proc.frameNo);
telemetry.addData("Push?", isAPressed);
telemetry.addLine("(press A to save)");
telemetry.update();

isAPressed = gamepad1.a;
isAPressed = nonVolatileA;
}
}
}

0 comments on commit 7db1ffb

Please sign in to comment.