Skip to content

Commit

Permalink
Merge branch 'master' into 2023-11-08_mrcal
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 authored Jan 5, 2024
2 parents 34f66cd + 4d9f228 commit 33a1de2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ext {
openCVversion = "4.8.0-2"
joglVersion = "2.4.0-rc-20200307"
javalinVersion = "5.6.2"
photonGlDriverLibVersion = "dev-v2023.1.0-8-g38bbe74"
photonGlDriverLibVersion = "dev-v2023.1.0-9-g75fc678"
frcYear = "2024"
mrcalVersion = "dev-v2024.0.0-7-gc976aaa";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.photonvision.vision.frame.provider;

import org.opencv.core.Mat;
import org.photonvision.common.logging.LogGroup;
import org.photonvision.common.logging.Logger;
import org.photonvision.common.util.math.MathUtils;
import org.photonvision.raspi.LibCameraJNI;
import org.photonvision.vision.camera.LibcameraGpuSettables;
Expand All @@ -31,6 +33,8 @@
public class LibcameraGpuFrameProvider implements FrameProvider {
private final LibcameraGpuSettables settables;

static final Logger logger = new Logger(LibcameraGpuFrameProvider.class, LogGroup.Camera);

public LibcameraGpuFrameProvider(LibcameraGpuSettables visionSettables) {
this.settables = visionSettables;

Expand All @@ -43,21 +47,30 @@ public String getName() {
return "AcceleratedPicamFrameProvider";
}

int i = 0;
int badFrameCounter = 0;

@Override
public Frame get() {
// We need to make sure that other threads don't try to change video modes while
// we're waiting
// for a frame
// we're waiting for a frame
// System.out.println("GET!");
synchronized (settables.CAMERA_LOCK) {
var p_ptr = LibCameraJNI.awaitNewFrame(settables.r_ptr);

if (p_ptr == 0) {
System.out.println("No new frame");
logger.error("No new frame from " + settables.getConfiguration().nickname);
badFrameCounter++;
if (badFrameCounter > 3) {
logger.error(
"No new frame from "
+ settables.getConfiguration().nickname
+ " for 3 seconds attempting recreate!");
settables.setVideoMode(settables.getCurrentVideoMode());
badFrameCounter = 0;
}
return new Frame();
}
badFrameCounter = 0;

var colorMat = new CVMat(new Mat(LibCameraJNI.takeColorFrame(p_ptr)));
var processedMat = new CVMat(new Mat(LibCameraJNI.takeProcessedFrame(p_ptr)));
Expand Down

0 comments on commit 33a1de2

Please sign in to comment.