Add ignored cameras regex to command-line arguemnts (#849)

This adds a regex that ignores cameras if they match it, for if you have another piece of software running that needs a second camera, or if you have a webcam in your laptop that cscore hates.
This commit is contained in:
person4268
2023-06-03 21:04:04 -04:00
committed by GitHub
parent 80f479344d
commit 6d2eae7f20
20 changed files with 78 additions and 14 deletions

View File

@@ -128,12 +128,16 @@ public class HardwareConfig {
this.blacklistedResIndices = blacklistedResIndices;
}
/** @return True if the FOV has been preset to a sane value, false otherwise */
/**
* @return True if the FOV has been preset to a sane value, false otherwise
*/
public final boolean hasPresetFOV() {
return vendorFOV > 0;
}
/** @return True if any command has been configured to a non-default empty, false otherwise */
/**
* @return True if any command has been configured to a non-default empty, false otherwise
*/
public final boolean hasCommandsConfigured() {
return cpuTempCommand != ""
|| cpuMemoryCommand != ""

View File

@@ -33,6 +33,7 @@ public class FindCirclesPipe
// Output vector of found circles. Each vector is encoded as 3 or 4 element floating-point vector
// (x,y,radius) or (x,y,radius,votes) .
private final Mat circles = new Mat();
/**
* Runs the process for the pipe. The reason we need a separate pipe for circles is because if we
* were to use the FindShapes pipe, we would have to assume that any shape more than 10-20+ sides

View File

@@ -82,6 +82,7 @@ public class FindPolygonPipe
public static class FindPolygonPipeParams {
private final double accuracyPercentage;
// Should be a value between 0-100
public FindPolygonPipeParams(double accuracyPercentage) {
this.accuracyPercentage = accuracyPercentage;

View File

@@ -44,6 +44,7 @@ public class VisionSourceManager {
final List<UsbCameraInfo> knownUsbCameras = new CopyOnWriteArrayList<>();
final List<CameraConfiguration> unmatchedLoadedConfigs = new CopyOnWriteArrayList<>();
private boolean hasWarned;
private String ignoredCamerasRegex = "";
private static class SingletonHolder {
private static final VisionSourceManager INSTANCE = new VisionSourceManager();
@@ -282,12 +283,18 @@ public class VisionSourceManager {
return cfg;
}
public void setIgnoredCamerasRegex(String ignoredCamerasRegex) {
this.ignoredCamerasRegex = ignoredCamerasRegex;
}
private List<UsbCameraInfo> filterAllowedDevices(List<UsbCameraInfo> allDevices) {
List<UsbCameraInfo> filteredDevices = new ArrayList<>();
for (var device : allDevices) {
if (deviceBlacklist.contains(device.name)) {
logger.trace(
"Skipping blacklisted device: \"" + device.name + "\" at \"" + device.path + "\"");
} else if (device.name.matches(ignoredCamerasRegex)) {
logger.trace("Skipping ignored device: \"" + device.name + "\" at \"" + device.path);
} else {
filteredDevices.add(device);
logger.trace(

View File

@@ -49,6 +49,7 @@ public abstract class VisionSourceSettables {
public abstract void setBrightness(int brightness);
public abstract void setGain(int gain);
// Pretty uncommon so instead of abstract this is just a no-op by default
// Overriden by cameras with AWB gain support
public void setRedGain(int red) {}

View File

@@ -16,6 +16,7 @@
*/
package org.photonvision.common;
/*
* Copyright (C) 2020 Photon Vision.
*

View File

@@ -18,6 +18,7 @@
package org.photonvision.vision.frame.provider;
import org.junit.jupiter.api.Test;
// import org.photonvision.raspi.LibCameraJNI;
public class LibcameraTest {