mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Add sensor model detection (#194)
This commit is contained in:
committed by
GitHub
parent
be5d8f6518
commit
2ca879c82d
@@ -205,7 +205,7 @@ export default {
|
||||
return `${this.settings.hardwarePlatform}`;
|
||||
},
|
||||
gpuAccel() {
|
||||
return `${this.settings.gpuAcceleration ? "Enabled" : "Unsupported"}${this.settings.gpuAcceleration ? " (" + this.settings.gpuAcceleration + " mode)" : ""}`
|
||||
return `${this.settings.gpuAcceleration ? "Enabled" : "Unsupported"} ${this.settings.gpuAcceleration ? "(" + this.settings.gpuAcceleration + ")" : ""}`
|
||||
},
|
||||
metrics() {
|
||||
console.log(this.$store.state.metrics);
|
||||
|
||||
@@ -111,7 +111,7 @@ public class PhotonConfiguration {
|
||||
generalSubmap.put(
|
||||
"gpuAcceleration",
|
||||
PicamJNI.isSupported()
|
||||
? "Zerocopy MMAL"
|
||||
? "Zerocopy MMAL on " + PicamJNI.getSensorModel().getFriendlyName()
|
||||
: ""); // TODO add support for other types of GPU accel
|
||||
generalSubmap.put("hardwareModel", hardwareConfig.deviceName);
|
||||
generalSubmap.put("hardwarePlatform", Platform.getCurrentPlatform().toString());
|
||||
|
||||
@@ -32,6 +32,30 @@ public class PicamJNI {
|
||||
private static boolean libraryLoaded = false;
|
||||
private static Logger logger = new Logger(PicamJNI.class, LogGroup.Camera);
|
||||
|
||||
public enum SensorModel {
|
||||
Disconnected,
|
||||
OV5647, // Picam v1
|
||||
IMX219, // Picam v2
|
||||
IMX477, // Picam HQ
|
||||
Unknown;
|
||||
|
||||
public String getFriendlyName() {
|
||||
switch (this) {
|
||||
case Disconnected:
|
||||
return "Disconnected Camera";
|
||||
case OV5647:
|
||||
return "Camera Module v1";
|
||||
case IMX219:
|
||||
return "Camera Module v2";
|
||||
case IMX477:
|
||||
return "HQ Camera";
|
||||
case Unknown:
|
||||
default:
|
||||
return "Unknown Camera";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void forceLoad() throws IOException {
|
||||
if (libraryLoaded || !Platform.isRaspberryPi()) return;
|
||||
|
||||
@@ -61,9 +85,26 @@ public class PicamJNI {
|
||||
}
|
||||
|
||||
public static boolean isSupported() {
|
||||
return libraryLoaded;
|
||||
return libraryLoaded && getSensorModel() != SensorModel.Disconnected;
|
||||
}
|
||||
|
||||
public static SensorModel getSensorModel() {
|
||||
switch (getSensorModelRaw().toLowerCase()) {
|
||||
case "":
|
||||
return SensorModel.Disconnected;
|
||||
case "ov5647":
|
||||
return SensorModel.OV5647;
|
||||
case "imx219":
|
||||
return SensorModel.IMX219;
|
||||
case "imx477":
|
||||
return SensorModel.IMX477;
|
||||
default:
|
||||
return SensorModel.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
private static native String getSensorModelRaw();
|
||||
|
||||
// Everything here is static because multiple picams are unsupported at the hardware level
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@ import edu.wpi.cscore.VideoMode;
|
||||
import java.util.HashMap;
|
||||
import org.photonvision.common.configuration.CameraConfiguration;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
import org.photonvision.raspi.PicamJNI;
|
||||
import org.photonvision.vision.frame.FrameProvider;
|
||||
import org.photonvision.vision.frame.provider.AcceleratedPicamFrameProvider;
|
||||
@@ -28,6 +30,7 @@ import org.photonvision.vision.processes.VisionSource;
|
||||
import org.photonvision.vision.processes.VisionSourceSettables;
|
||||
|
||||
public class ZeroCopyPicamSource implements VisionSource {
|
||||
private static final Logger logger = new Logger(ZeroCopyPicamSource.class, LogGroup.Camera);
|
||||
|
||||
private final VisionSourceSettables settables;
|
||||
private final AcceleratedPicamFrameProvider frameProvider;
|
||||
@@ -88,12 +91,10 @@ public class ZeroCopyPicamSource implements VisionSource {
|
||||
super(configuration);
|
||||
|
||||
videoModes = new HashMap<>();
|
||||
PicamJNI.SensorModel sensorModel = PicamJNI.getSensorModel();
|
||||
|
||||
// TODO add IMX219 detection to the picam driver
|
||||
// if(PicamJNI.isIMX219()) {
|
||||
if (false) {
|
||||
// Settings for the Picam V2
|
||||
// TODO determine multipliers
|
||||
if (sensorModel == PicamJNI.SensorModel.IMX219) {
|
||||
// Settings for the IMX219 sensor, which is used on the Pi Camera Module v2
|
||||
videoModes.put(
|
||||
0, new FPSRatedVideoMode(VideoMode.PixelFormat.kUnknown, 320, 240, 120, 120, .39));
|
||||
videoModes.put(
|
||||
@@ -103,7 +104,15 @@ public class ZeroCopyPicamSource implements VisionSource {
|
||||
videoModes.put(
|
||||
3, new FPSRatedVideoMode(VideoMode.PixelFormat.kUnknown, 1920, 1080, 15, 20, .53));
|
||||
} else {
|
||||
// "High Quality" picam falls back on settings for OV sensor
|
||||
if (sensorModel == PicamJNI.SensorModel.IMX477) {
|
||||
logger.warn(
|
||||
"It appears you are using a Pi HQ Camera. This camera is not officially supported. You will have to set your camera FOV differently based on resolution.");
|
||||
} else if (sensorModel == PicamJNI.SensorModel.Unknown) {
|
||||
logger.warn(
|
||||
"You have an unknown sensor connected to your Pi over CSI! This is likely a bug. If it is not, then you will have to set your camera FOV differently based on resolution.");
|
||||
}
|
||||
|
||||
// Settings for the OV5647 sensor, which is used by the Pi Camera Module v1
|
||||
videoModes.put(
|
||||
0, new FPSRatedVideoMode(VideoMode.PixelFormat.kUnknown, 320, 240, 90, 90, 1));
|
||||
videoModes.put(
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user