mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-23 01:21:40 +00:00
@@ -19,11 +19,11 @@ package org.photonvision.common.hardware.GPIO.pi;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* A class that defines the exceptions that can be thrown by Pigpio.
|
||||
*
|
||||
* <p>Credit to nkolban
|
||||
* https://github.com/nkolban/jpigpio/blob/master/JPigpio/src/jpigpio/PigpioException.java
|
||||
*/
|
||||
* A class that defines the exceptions that can be thrown by Pigpio.
|
||||
*
|
||||
* <p>Credit to nkolban
|
||||
* https://github.com/nkolban/jpigpio/blob/master/JPigpio/src/jpigpio/PigpioException.java
|
||||
*/
|
||||
@SuppressWarnings({"SpellCheckingInspection", "unused", "RedundantSuppression"})
|
||||
public class PigpioException extends Exception {
|
||||
private int rc = -99999999;
|
||||
@@ -65,10 +65,10 @@ public class PigpioException extends Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the error code that was returned by the underlying Pigpio call.
|
||||
*
|
||||
* @return The error code that was returned by the underlying Pigpio call.
|
||||
*/
|
||||
* Retrieve the error code that was returned by the underlying Pigpio call.
|
||||
*
|
||||
* @return The error code that was returned by the underlying Pigpio call.
|
||||
*/
|
||||
public int getErrorCode() {
|
||||
return rc;
|
||||
} // End of getErrorCode
|
||||
|
||||
@@ -22,14 +22,14 @@ public class PigpioPulse {
|
||||
int delayMicros;
|
||||
|
||||
/**
|
||||
* Initialises a pulse.
|
||||
*
|
||||
* @param gpioOn GPIO number to switch on at the start of the pulse. If zero, then no GPIO will be
|
||||
* switched on.
|
||||
* @param gpioOff GPIO number to switch off at the start of the pulse. If zero, then no GPIO will
|
||||
* be switched off.
|
||||
* @param delayMicros the delay in microseconds before the next pulse.
|
||||
*/
|
||||
* Initialises a pulse.
|
||||
*
|
||||
* @param gpioOn GPIO number to switch on at the start of the pulse. If zero, then no GPIO will be
|
||||
* switched on.
|
||||
* @param gpioOff GPIO number to switch off at the start of the pulse. If zero, then no GPIO will
|
||||
* be switched off.
|
||||
* @param delayMicros the delay in microseconds before the next pulse.
|
||||
*/
|
||||
public PigpioPulse(int gpioOn, int gpioOff, int delayMicros) {
|
||||
this.gpioOn = gpioOn != 0 ? 1 << gpioOn : 0;
|
||||
this.gpioOff = gpioOff != 0 ? 1 << gpioOff : 0;
|
||||
|
||||
@@ -40,12 +40,12 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and starts a socket connection to a pigpio daemon on a remote host with the specified
|
||||
* address and port
|
||||
*
|
||||
* @param addr Address of remote pigpio daemon
|
||||
* @param port Port of remote pigpio daemon
|
||||
*/
|
||||
* Creates and starts a socket connection to a pigpio daemon on a remote host with the specified
|
||||
* address and port
|
||||
*
|
||||
* @param addr Address of remote pigpio daemon
|
||||
* @param port Port of remote pigpio daemon
|
||||
*/
|
||||
public PigpioSocket(String addr, int port) {
|
||||
try {
|
||||
commandSocket = new PigpioSocketLock(addr, port);
|
||||
@@ -55,10 +55,10 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconnects to the pigpio daemon
|
||||
*
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Reconnects to the pigpio daemon
|
||||
*
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public void reconnect() throws PigpioException {
|
||||
try {
|
||||
commandSocket.reconnect();
|
||||
@@ -69,10 +69,10 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminates the connection to the pigpio daemon
|
||||
*
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Terminates the connection to the pigpio daemon
|
||||
*
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public void gpioTerminate() throws PigpioException {
|
||||
try {
|
||||
commandSocket.terminate();
|
||||
@@ -83,12 +83,12 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the GPIO level
|
||||
*
|
||||
* @param pin Pin to read from
|
||||
* @return Value of the pin
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Read the GPIO level
|
||||
*
|
||||
* @param pin Pin to read from
|
||||
* @return Value of the pin
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public boolean gpioRead(int pin) throws PigpioException {
|
||||
try {
|
||||
int retCode = commandSocket.sendCmd(PigpioCommand.PCMD_READ.value, pin);
|
||||
@@ -101,12 +101,12 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the GPIO level
|
||||
*
|
||||
* @param pin Pin to write to
|
||||
* @param value Value to write
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Write the GPIO level
|
||||
*
|
||||
* @param pin Pin to write to
|
||||
* @param value Value to write
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public void gpioWrite(int pin, boolean value) throws PigpioException {
|
||||
try {
|
||||
int retCode = commandSocket.sendCmd(PigpioCommand.PCMD_WRITE.value, pin, value ? 1 : 0);
|
||||
@@ -118,10 +118,10 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all waveforms and any data added by calls to {@link #waveAddGeneric(ArrayList)}
|
||||
*
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Clears all waveforms and any data added by calls to {@link #waveAddGeneric(ArrayList)}
|
||||
*
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public void waveClear() throws PigpioException {
|
||||
try {
|
||||
int retCode = commandSocket.sendCmd(PigpioCommand.PCMD_WVCLR.value);
|
||||
@@ -133,12 +133,12 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a number of pulses to the current waveform
|
||||
*
|
||||
* @param pulses ArrayList of pulses to add
|
||||
* @return the new total number of pulses in the current waveform
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Adds a number of pulses to the current waveform
|
||||
*
|
||||
* @param pulses ArrayList of pulses to add
|
||||
* @return the new total number of pulses in the current waveform
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
private int waveAddGeneric(ArrayList<PigpioPulse> pulses) throws PigpioException {
|
||||
// pigpio wave message format
|
||||
|
||||
@@ -174,12 +174,12 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates pulses and adds them to the current waveform
|
||||
*
|
||||
* @param pulseTimeMillis Pulse length in milliseconds
|
||||
* @param blinks Number of times to pulse. -1 for repeat
|
||||
* @param pinNo Pin to pulse
|
||||
*/
|
||||
* Creates pulses and adds them to the current waveform
|
||||
*
|
||||
* @param pulseTimeMillis Pulse length in milliseconds
|
||||
* @param blinks Number of times to pulse. -1 for repeat
|
||||
* @param pinNo Pin to pulse
|
||||
*/
|
||||
private void addBlinkPulsesToWaveform(int pulseTimeMillis, int blinks, int pinNo) {
|
||||
boolean repeat = blinks == -1;
|
||||
|
||||
@@ -207,13 +207,13 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and sends a waveform to the given pins with the specified parameters.
|
||||
*
|
||||
* @param pulseTimeMillis Pulse length in milliseconds
|
||||
* @param blinks Number of times to pulse. -1 for repeat
|
||||
* @param pins Pins to pulse
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Generates and sends a waveform to the given pins with the specified parameters.
|
||||
*
|
||||
* @param pulseTimeMillis Pulse length in milliseconds
|
||||
* @param blinks Number of times to pulse. -1 for repeat
|
||||
* @param pins Pins to pulse
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public void generateAndSendWaveform(int pulseTimeMillis, int blinks, int... pins)
|
||||
throws PigpioException {
|
||||
if (pins.length == 0) return;
|
||||
@@ -262,11 +262,11 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the transmission of the current waveform
|
||||
*
|
||||
* @return success
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Stops the transmission of the current waveform
|
||||
*
|
||||
* @return success
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public boolean waveTxStop() throws PigpioException {
|
||||
try {
|
||||
int retCode = commandSocket.sendCmd(PigpioCommand.PCMD_WVHLT.value);
|
||||
@@ -279,12 +279,12 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a waveform from the data provided by the prior calls to {@link
|
||||
* #waveAddGeneric(ArrayList)} Upon success a wave ID greater than or equal to 0 is returned
|
||||
*
|
||||
* @return ID of the created waveform
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Creates a waveform from the data provided by the prior calls to {@link
|
||||
* #waveAddGeneric(ArrayList)} Upon success a wave ID greater than or equal to 0 is returned
|
||||
*
|
||||
* @return ID of the created waveform
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public int waveCreate() throws PigpioException {
|
||||
try {
|
||||
int retCode = commandSocket.sendCmd(PigpioCommand.PCMD_WVCRE.value);
|
||||
@@ -297,11 +297,11 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the waveform with specified wave ID
|
||||
*
|
||||
* @param waveId ID of the waveform to delete
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Deletes the waveform with specified wave ID
|
||||
*
|
||||
* @param waveId ID of the waveform to delete
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public void waveDelete(int waveId) throws PigpioException {
|
||||
try {
|
||||
int retCode = commandSocket.sendCmd(PigpioCommand.PCMD_WVDEL.value, waveId);
|
||||
@@ -313,12 +313,12 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmits the waveform with specified wave ID. The waveform is sent once
|
||||
*
|
||||
* @param waveId ID of the waveform to transmit
|
||||
* @return The number of DMA control blocks in the waveform
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Transmits the waveform with specified wave ID. The waveform is sent once
|
||||
*
|
||||
* @param waveId ID of the waveform to transmit
|
||||
* @return The number of DMA control blocks in the waveform
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public int waveSendOnce(int waveId) throws PigpioException {
|
||||
try {
|
||||
int retCode = commandSocket.sendCmd(PigpioCommand.PCMD_WVTX.value, waveId);
|
||||
@@ -330,13 +330,13 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmits the waveform with specified wave ID. The waveform cycles until cancelled (either by
|
||||
* the sending of a new waveform or {@link #waveTxStop()}
|
||||
*
|
||||
* @param waveId ID of the waveform to transmit
|
||||
* @return The number of DMA control blocks in the waveform
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Transmits the waveform with specified wave ID. The waveform cycles until cancelled (either by
|
||||
* the sending of a new waveform or {@link #waveTxStop()}
|
||||
*
|
||||
* @param waveId ID of the waveform to transmit
|
||||
* @return The number of DMA control blocks in the waveform
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public int waveSendRepeat(int waveId) throws PigpioException {
|
||||
try {
|
||||
int retCode = commandSocket.sendCmd(PigpioCommand.PCMD_WVTXR.value, waveId);
|
||||
@@ -348,14 +348,14 @@ public class PigpioSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts hardware PWM on a GPIO at the specified frequency and dutycycle
|
||||
*
|
||||
* @param pin GPIO pin to start PWM on
|
||||
* @param pwmFrequency Frequency to run at (1Hz-125MHz). Frequencies above 30MHz are unlikely to
|
||||
* work
|
||||
* @param pwmDuty Duty cycle to run at (0-1,000,000)
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
* Starts hardware PWM on a GPIO at the specified frequency and dutycycle
|
||||
*
|
||||
* @param pin GPIO pin to start PWM on
|
||||
* @param pwmFrequency Frequency to run at (1Hz-125MHz). Frequencies above 30MHz are unlikely to
|
||||
* work
|
||||
* @param pwmDuty Duty cycle to run at (0-1,000,000)
|
||||
* @throws PigpioException on failure
|
||||
*/
|
||||
public void hardwarePWM(int pin, int pwmFrequency, int pwmDuty) throws PigpioException {
|
||||
try {
|
||||
ByteBuffer bb = ByteBuffer.allocate(4);
|
||||
|
||||
@@ -23,9 +23,9 @@ import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Credit to nkolban
|
||||
* https://github.com/nkolban/jpigpio/blob/master/JPigpio/src/jpigpio/SocketLock.java
|
||||
*/
|
||||
* Credit to nkolban
|
||||
* https://github.com/nkolban/jpigpio/blob/master/JPigpio/src/jpigpio/SocketLock.java
|
||||
*/
|
||||
final class PigpioSocketLock {
|
||||
private static final int replyTimeoutMillis = 1000;
|
||||
|
||||
@@ -81,16 +81,16 @@ final class PigpioSocketLock {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send extended command to pigpiod and return result code
|
||||
*
|
||||
* @param cmd Command to send
|
||||
* @param p1 Command parameter 1
|
||||
* @param p2 Command parameter 2
|
||||
* @param p3 Command parameter 3 (usually length of extended data - see paramater ext)
|
||||
* @param ext Array of bytes containing extended data
|
||||
* @return Command result code
|
||||
* @throws IOException in case of network connection error
|
||||
*/
|
||||
* Send extended command to pigpiod and return result code
|
||||
*
|
||||
* @param cmd Command to send
|
||||
* @param p1 Command parameter 1
|
||||
* @param p2 Command parameter 2
|
||||
* @param p3 Command parameter 3 (usually length of extended data - see paramater ext)
|
||||
* @param ext Array of bytes containing extended data
|
||||
* @return Command result code
|
||||
* @throws IOException in case of network connection error
|
||||
*/
|
||||
@SuppressWarnings("UnusedAssignment")
|
||||
public synchronized int sendCmd(int cmd, int p1, int p2, int p3, byte[] ext) throws IOException {
|
||||
ByteBuffer bb = ByteBuffer.allocate(16 + ext.length);
|
||||
@@ -135,11 +135,11 @@ final class PigpioSocketLock {
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all remaining bytes coming from pigpiod
|
||||
*
|
||||
* @param data Array to store read bytes.
|
||||
* @throws IOException if unable to read from network
|
||||
*/
|
||||
* Read all remaining bytes coming from pigpiod
|
||||
*
|
||||
* @param data Array to store read bytes.
|
||||
* @throws IOException if unable to read from network
|
||||
*/
|
||||
public void readBytes(byte[] data) throws IOException {
|
||||
in.readFully(data);
|
||||
}
|
||||
|
||||
@@ -232,12 +232,12 @@ public class Logger {
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an error message with the stack trace of a Throwable. The stacktrace will only be printed
|
||||
* if the current LogLevel is TRACE
|
||||
*
|
||||
* @param message
|
||||
* @param t
|
||||
*/
|
||||
* Logs an error message with the stack trace of a Throwable. The stacktrace will only be printed
|
||||
* if the current LogLevel is TRACE
|
||||
*
|
||||
* @param message
|
||||
* @param t
|
||||
*/
|
||||
public void error(String message, Throwable t) {
|
||||
log(message, LogLevel.ERROR);
|
||||
log(convertStackTraceToString(t), LogLevel.ERROR, LogLevel.DEBUG);
|
||||
|
||||
@@ -43,12 +43,12 @@ public class ShellExec {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a bash command. We can handle complex bash commands including multiple executions (; |
|
||||
* and ||), quotes, expansions ($), escapes (\), e.g.: "cd /abc/def; mv ghi 'older ghi '$(whoami)"
|
||||
*
|
||||
* @param command Bash command to execute
|
||||
* @return true if bash got started, but your command may have failed.
|
||||
*/
|
||||
* Execute a bash command. We can handle complex bash commands including multiple executions (; |
|
||||
* and ||), quotes, expansions ($), escapes (\), e.g.: "cd /abc/def; mv ghi 'older ghi '$(whoami)"
|
||||
*
|
||||
* @param command Bash command to execute
|
||||
* @return true if bash got started, but your command may have failed.
|
||||
*/
|
||||
public int executeBashCommand(String command, boolean wait) throws IOException {
|
||||
logger.debug("Executing \"" + command + "\"");
|
||||
|
||||
@@ -71,25 +71,25 @@ public class ShellExec {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a command in current folder, and wait for process to end
|
||||
*
|
||||
* @param command command ("c:/some/folder/script.bat" or "some/folder/script.sh")
|
||||
* @param args 0..n command line arguments
|
||||
* @return process exit code
|
||||
*/
|
||||
* Execute a command in current folder, and wait for process to end
|
||||
*
|
||||
* @param command command ("c:/some/folder/script.bat" or "some/folder/script.sh")
|
||||
* @param args 0..n command line arguments
|
||||
* @return process exit code
|
||||
*/
|
||||
public int execute(String command, String... args) throws IOException {
|
||||
return execute(command, null, true, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a command.
|
||||
*
|
||||
* @param command command ("c:/some/folder/script.bat" or "some/folder/script.sh")
|
||||
* @param workdir working directory or NULL to use command folder
|
||||
* @param wait wait for process to end
|
||||
* @param args 0..n command line arguments
|
||||
* @return process exit code
|
||||
*/
|
||||
* Execute a command.
|
||||
*
|
||||
* @param command command ("c:/some/folder/script.bat" or "some/folder/script.sh")
|
||||
* @param workdir working directory or NULL to use command folder
|
||||
* @param wait wait for process to end
|
||||
* @param args 0..n command line arguments
|
||||
* @return process exit code
|
||||
*/
|
||||
public int execute(String command, String workdir, boolean wait, String... args)
|
||||
throws IOException {
|
||||
String[] cmdArr;
|
||||
@@ -153,10 +153,10 @@ public class ShellExec {
|
||||
// ********************************************
|
||||
|
||||
/**
|
||||
* StreamGobbler reads inputstream to "gobble" it. This is used by Executor class when running a
|
||||
* commandline applications. Gobblers must read/purge INSTR and ERRSTR process streams.
|
||||
* http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=4
|
||||
*/
|
||||
* StreamGobbler reads inputstream to "gobble" it. This is used by Executor class when running a
|
||||
* commandline applications. Gobblers must read/purge INSTR and ERRSTR process streams.
|
||||
* http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=4
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
private static class StreamGobbler extends Thread {
|
||||
private InputStream is;
|
||||
@@ -186,19 +186,19 @@ public class ShellExec {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get inputstream buffer or null if stream was not consumed.
|
||||
*
|
||||
* @return Output stream
|
||||
*/
|
||||
* Get inputstream buffer or null if stream was not consumed.
|
||||
*
|
||||
* @return Output stream
|
||||
*/
|
||||
public String getOutput() {
|
||||
return (output != null ? output.toString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is input stream completed.
|
||||
*
|
||||
* @return if input stream is completed
|
||||
*/
|
||||
* Is input stream completed.
|
||||
*
|
||||
* @return if input stream is completed
|
||||
*/
|
||||
public boolean isCompleted() {
|
||||
return completed;
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ public class MathUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Linearly interpolates between two values.
|
||||
*
|
||||
* @param startValue The start value.
|
||||
* @param endValue The end value.
|
||||
* @param t The fraction for interpolation.
|
||||
* @return The interpolated value.
|
||||
*/
|
||||
* Linearly interpolates between two values.
|
||||
*
|
||||
* @param startValue The start value.
|
||||
* @param endValue The end value.
|
||||
* @param t The fraction for interpolation.
|
||||
* @return The interpolated value.
|
||||
*/
|
||||
@SuppressWarnings("ParameterName")
|
||||
public static double lerp(double startValue, double endValue, double t) {
|
||||
return startValue + (endValue - startValue) * t;
|
||||
|
||||
@@ -25,9 +25,9 @@ import java.util.StringJoiner;
|
||||
@SuppressWarnings("unused")
|
||||
public class NumberListUtils {
|
||||
/**
|
||||
* @param collection an ArrayList of Comparable objects
|
||||
* @return the median of collection
|
||||
*/
|
||||
* @param collection an ArrayList of Comparable objects
|
||||
* @return the median of collection
|
||||
*/
|
||||
public static <T extends Number> double median(List<T> collection, Comparator<T> comp) {
|
||||
double result;
|
||||
int n = collection.size() / 2;
|
||||
@@ -57,9 +57,9 @@ public class NumberListUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param collection an ArrayList of Numbers
|
||||
* @return the mean of collection
|
||||
*/
|
||||
* @param collection an ArrayList of Numbers
|
||||
* @return the mean of collection
|
||||
*/
|
||||
public static double mean(final List<? extends Number> collection) {
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
for (final Number number : collection) {
|
||||
@@ -69,11 +69,11 @@ public class NumberListUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param collection a collection of Comparable objects
|
||||
* @param n the position of the desired object, using the ordering defined on the collection
|
||||
* elements
|
||||
* @return the nth smallest object
|
||||
*/
|
||||
* @param collection a collection of Comparable objects
|
||||
* @param n the position of the desired object, using the ordering defined on the collection
|
||||
* elements
|
||||
* @return the nth smallest object
|
||||
*/
|
||||
public static <T> T nthSmallest(List<T> collection, int n, Comparator<T> comp) {
|
||||
T result, pivot;
|
||||
ArrayList<T> underPivot = new ArrayList<>(),
|
||||
|
||||
@@ -116,18 +116,18 @@ public class PicamJNI {
|
||||
// Everything here is static because multiple picams are unsupported at the hardware level
|
||||
|
||||
/**
|
||||
* Called once for each video mode change. Starts a native thread running MMAL that stays alive
|
||||
* until destroyCamera is called.
|
||||
*
|
||||
* @return true on error.
|
||||
*/
|
||||
* Called once for each video mode change. Starts a native thread running MMAL that stays alive
|
||||
* until destroyCamera is called.
|
||||
*
|
||||
* @return true on error.
|
||||
*/
|
||||
public static native boolean createCamera(int width, int height, int fps);
|
||||
|
||||
/**
|
||||
* Destroys MMAL and EGL contexts. Called once for each video mode change *before* createCamera.
|
||||
*
|
||||
* @return true on error.
|
||||
*/
|
||||
* Destroys MMAL and EGL contexts. Called once for each video mode change *before* createCamera.
|
||||
*
|
||||
* @return true on error.
|
||||
*/
|
||||
public static native boolean destroyCamera();
|
||||
|
||||
public static native void setThresholds(
|
||||
|
||||
@@ -42,24 +42,24 @@ public class QuirkyCamera {
|
||||
public final HashMap<CameraQuirk, Boolean> quirks;
|
||||
|
||||
/**
|
||||
* Creates a QuirkyCamera that matches by USB VID/PID
|
||||
*
|
||||
* @param usbVid USB VID of camera
|
||||
* @param usbPid USB PID of camera
|
||||
* @param quirks Camera quirks
|
||||
*/
|
||||
* Creates a QuirkyCamera that matches by USB VID/PID
|
||||
*
|
||||
* @param usbVid USB VID of camera
|
||||
* @param usbPid USB PID of camera
|
||||
* @param quirks Camera quirks
|
||||
*/
|
||||
private QuirkyCamera(int usbVid, int usbPid, CameraQuirk... quirks) {
|
||||
this(usbVid, usbPid, "", quirks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a QuirkyCamera that matches by USB VID/PID and name
|
||||
*
|
||||
* @param usbVid USB VID of camera
|
||||
* @param usbPid USB PID of camera
|
||||
* @param baseName CSCore name of camera
|
||||
* @param quirks Camera quirks
|
||||
*/
|
||||
* Creates a QuirkyCamera that matches by USB VID/PID and name
|
||||
*
|
||||
* @param usbVid USB VID of camera
|
||||
* @param usbPid USB PID of camera
|
||||
* @param baseName CSCore name of camera
|
||||
* @param quirks Camera quirks
|
||||
*/
|
||||
private QuirkyCamera(int usbVid, int usbPid, String baseName, CameraQuirk... quirks) {
|
||||
this.usbVid = usbVid;
|
||||
this.usbPid = usbPid;
|
||||
|
||||
@@ -56,13 +56,13 @@ public class ZeroCopyPicamSource extends VisionSource {
|
||||
}
|
||||
|
||||
/**
|
||||
* On the OV5649 the actual FPS we want to request from the GPU can be higher than the FPS that we
|
||||
* can do after processing. On the IMX219 these FPSes match pretty closely, except for the
|
||||
* 1280x720 mode. We use this to present a rated FPS to the user that's lower than the actual FPS
|
||||
* we request from the GPU. This is important for setting user expectations, and is also used by
|
||||
* the frontend to detect and explain FPS drops. This class should ONLY be used by Picam video
|
||||
* modes! This is to make sure it shows up nice in the frontend
|
||||
*/
|
||||
* On the OV5649 the actual FPS we want to request from the GPU can be higher than the FPS that we
|
||||
* can do after processing. On the IMX219 these FPSes match pretty closely, except for the
|
||||
* 1280x720 mode. We use this to present a rated FPS to the user that's lower than the actual FPS
|
||||
* we request from the GPU. This is important for setting user expectations, and is also used by
|
||||
* the frontend to detect and explain FPS drops. This class should ONLY be used by Picam video
|
||||
* modes! This is to make sure it shows up nice in the frontend
|
||||
*/
|
||||
public static class FPSRatedVideoMode extends VideoMode {
|
||||
public final int fpsActual;
|
||||
public final double fovMultiplier;
|
||||
|
||||
@@ -37,23 +37,23 @@ public class FrameStaticProperties {
|
||||
public CameraCalibrationCoefficients cameraCalibration;
|
||||
|
||||
/**
|
||||
* Instantiates a new Frame static properties.
|
||||
*
|
||||
* @param mode The Video Mode of the camera.
|
||||
* @param fov The fov of the image.
|
||||
*/
|
||||
* Instantiates a new Frame static properties.
|
||||
*
|
||||
* @param mode The Video Mode of the camera.
|
||||
* @param fov The fov of the image.
|
||||
*/
|
||||
public FrameStaticProperties(
|
||||
VideoMode mode, double fov, Rotation2d cameraPitch, CameraCalibrationCoefficients cal) {
|
||||
this(mode != null ? mode.width : 1, mode != null ? mode.height : 1, fov, cameraPitch, cal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Frame static properties.
|
||||
*
|
||||
* @param imageWidth The width of the image.
|
||||
* @param imageHeight The width of the image.
|
||||
* @param fov The fov of the image.
|
||||
*/
|
||||
* Instantiates a new Frame static properties.
|
||||
*
|
||||
* @param imageWidth The width of the image.
|
||||
* @param imageHeight The width of the image.
|
||||
* @param fov The fov of the image.
|
||||
*/
|
||||
public FrameStaticProperties(
|
||||
int imageWidth,
|
||||
int imageHeight,
|
||||
|
||||
@@ -29,9 +29,9 @@ import org.photonvision.vision.frame.FrameStaticProperties;
|
||||
import org.photonvision.vision.opencv.CVMat;
|
||||
|
||||
/**
|
||||
* A {@link FrameProvider} that will read and provide an image from a {@link java.nio.file.Path
|
||||
* path}.
|
||||
*/
|
||||
* A {@link FrameProvider} that will read and provide an image from a {@link java.nio.file.Path
|
||||
* path}.
|
||||
*/
|
||||
public class FileFrameProvider implements FrameProvider {
|
||||
public static final int MAX_FPS = 120;
|
||||
private static int count = 0;
|
||||
@@ -46,12 +46,12 @@ public class FileFrameProvider implements FrameProvider {
|
||||
private long lastGetMillis = System.currentTimeMillis();
|
||||
|
||||
/**
|
||||
* Instantiates a new FileFrameProvider.
|
||||
*
|
||||
* @param path The path of the image to read from.
|
||||
* @param fov The fov of the image.
|
||||
* @param maxFPS The max framerate to provide the image at.
|
||||
*/
|
||||
* Instantiates a new FileFrameProvider.
|
||||
*
|
||||
* @param path The path of the image to read from.
|
||||
* @param fov The fov of the image.
|
||||
* @param maxFPS The max framerate to provide the image at.
|
||||
*/
|
||||
public FileFrameProvider(Path path, double fov, int maxFPS) {
|
||||
this(path, fov, maxFPS, null, null);
|
||||
}
|
||||
@@ -83,21 +83,21 @@ public class FileFrameProvider implements FrameProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new File frame provider.
|
||||
*
|
||||
* @param pathAsString The path of the image to read from as a string.
|
||||
* @param fov The fov of the image.
|
||||
*/
|
||||
* Instantiates a new File frame provider.
|
||||
*
|
||||
* @param pathAsString The path of the image to read from as a string.
|
||||
* @param fov The fov of the image.
|
||||
*/
|
||||
public FileFrameProvider(String pathAsString, double fov) {
|
||||
this(Paths.get(pathAsString), fov, MAX_FPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new File frame provider.
|
||||
*
|
||||
* @param path The path of the image to read from.
|
||||
* @param fov The fov of the image.
|
||||
*/
|
||||
* Instantiates a new File frame provider.
|
||||
*
|
||||
* @param path The path of the image to read from.
|
||||
* @param fov The fov of the image.
|
||||
*/
|
||||
public FileFrameProvider(Path path, double fov) {
|
||||
this(path, fov, MAX_FPS);
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
package org.photonvision.vision.pipe;
|
||||
|
||||
/**
|
||||
* Defines a pipe. A pipe is a single step in a pipeline. This class is to be extended, never used
|
||||
* on its own.
|
||||
*
|
||||
* @param <I> Input type for the pipe
|
||||
* @param <O> Output type for the pipe
|
||||
* @param <P> Parameters type for the pipe
|
||||
*/
|
||||
* Defines a pipe. A pipe is a single step in a pipeline. This class is to be extended, never used
|
||||
* on its own.
|
||||
*
|
||||
* @param <I> Input type for the pipe
|
||||
* @param <O> Output type for the pipe
|
||||
* @param <P> Parameters type for the pipe
|
||||
*/
|
||||
public abstract class CVPipe<I, O, P> {
|
||||
protected CVPipeResult<O> result = new CVPipeResult<>();
|
||||
protected P params;
|
||||
@@ -33,17 +33,17 @@ public abstract class CVPipe<I, O, P> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the process for the pipe.
|
||||
*
|
||||
* @param in Input for pipe processing.
|
||||
* @return Result of processing.
|
||||
*/
|
||||
* Runs the process for the pipe.
|
||||
*
|
||||
* @param in Input for pipe processing.
|
||||
* @return Result of processing.
|
||||
*/
|
||||
protected abstract O process(I in);
|
||||
|
||||
/**
|
||||
* @param in Input for pipe processing.
|
||||
* @return Result of processing.
|
||||
*/
|
||||
* @param in Input for pipe processing.
|
||||
* @return Result of processing.
|
||||
*/
|
||||
public CVPipeResult<O> run(I in) {
|
||||
long pipeStartNanos = System.nanoTime();
|
||||
result.output = process(in);
|
||||
|
||||
@@ -24,11 +24,11 @@ import org.photonvision.vision.pipe.MutatingPipe;
|
||||
/** Represents a pipeline that blurs the image. */
|
||||
public class BlurPipe extends MutatingPipe<Mat, BlurPipe.BlurParams> {
|
||||
/**
|
||||
* Processes this pipe.
|
||||
*
|
||||
* @param in Input for pipe processing.
|
||||
* @return The processed frame.
|
||||
*/
|
||||
* Processes this pipe.
|
||||
*
|
||||
* @param in Input for pipe processing.
|
||||
* @return The processed frame.
|
||||
*/
|
||||
@Override
|
||||
protected Void process(Mat in) {
|
||||
Imgproc.blur(in, in, params.getBlurSize());
|
||||
@@ -43,19 +43,19 @@ public class BlurPipe extends MutatingPipe<Mat, BlurPipe.BlurParams> {
|
||||
private final int m_blurSize;
|
||||
|
||||
/**
|
||||
* Constructs a new BlurImageParams.
|
||||
*
|
||||
* @param blurSize The blur size.
|
||||
*/
|
||||
* Constructs a new BlurImageParams.
|
||||
*
|
||||
* @param blurSize The blur size.
|
||||
*/
|
||||
public BlurParams(int blurSize) {
|
||||
m_blurSize = blurSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the blur size.
|
||||
*
|
||||
* @return The blur size.
|
||||
*/
|
||||
* Returns the blur size.
|
||||
*
|
||||
* @return The blur size.
|
||||
*/
|
||||
public Size getBlurSize() {
|
||||
return new Size(m_blurSize, m_blurSize);
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ public class Calibrate3dPipe
|
||||
private double calibrationAccuracy;
|
||||
|
||||
/**
|
||||
* Runs the process for the pipe.
|
||||
*
|
||||
* @param in Input for pipe processing. In the format (Input image, object points, image points)
|
||||
* @return Result of processing.
|
||||
*/
|
||||
* Runs the process for the pipe.
|
||||
*
|
||||
* @param in Input for pipe processing. In the format (Input image, object points, image points)
|
||||
* @return Result of processing.
|
||||
*/
|
||||
@Override
|
||||
protected CameraCalibrationCoefficients process(List<Triple<Size, Mat, Mat>> in) {
|
||||
in =
|
||||
|
||||
@@ -29,11 +29,11 @@ public class Collect2dTargetsPipe
|
||||
extends CVPipe<
|
||||
List<PotentialTarget>, List<TrackedTarget>, Collect2dTargetsPipe.Collect2dTargetsParams> {
|
||||
/**
|
||||
* Processes this pipeline.
|
||||
*
|
||||
* @param in Input for pipe processing.
|
||||
* @return A list of tracked targets.
|
||||
*/
|
||||
* Processes this pipeline.
|
||||
*
|
||||
* @param in Input for pipe processing.
|
||||
* @return A list of tracked targets.
|
||||
*/
|
||||
@Override
|
||||
protected List<TrackedTarget> process(List<PotentialTarget> in) {
|
||||
List<TrackedTarget> targets = new ArrayList<>();
|
||||
|
||||
@@ -59,9 +59,9 @@ public class CornerDetectionPipe
|
||||
}
|
||||
|
||||
/**
|
||||
* @param target the target to find the corners of.
|
||||
* @return the corners. left top, left bottom, right bottom, right top
|
||||
*/
|
||||
* @param target the target to find the corners of.
|
||||
* @return the corners. left top, left bottom, right bottom, right top
|
||||
*/
|
||||
private List<Point> findBoundingBoxCorners(TrackedTarget target) {
|
||||
// extract the corners
|
||||
var points = new Point[4];
|
||||
@@ -88,30 +88,30 @@ public class CornerDetectionPipe
|
||||
}
|
||||
|
||||
/**
|
||||
* @param a First point.
|
||||
* @param b Second point.
|
||||
* @return The straight line distance between them.
|
||||
*/
|
||||
* @param a First point.
|
||||
* @param b Second point.
|
||||
* @return The straight line distance between them.
|
||||
*/
|
||||
private static double distanceBetween(Point a, Point b) {
|
||||
return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param a First point.
|
||||
* @param b Second point.
|
||||
* @return The straight line distance between them.
|
||||
*/
|
||||
* @param a First point.
|
||||
* @param b Second point.
|
||||
* @return The straight line distance between them.
|
||||
*/
|
||||
private static double distanceBetween(Translation2d a, Translation2d b) {
|
||||
return Math.sqrt(Math.pow(a.getX() - b.getX(), 2) + Math.pow(a.getY() - b.getY(), 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the 4 most extreme corners,
|
||||
*
|
||||
* @param target the target to track.
|
||||
* @param convexHull weather to use the convex hull of the target.
|
||||
* @return the 4 extreme corners of the contour.
|
||||
*/
|
||||
* Find the 4 most extreme corners,
|
||||
*
|
||||
* @param target the target to track.
|
||||
* @param convexHull weather to use the convex hull of the target.
|
||||
* @return the 4 extreme corners of the contour.
|
||||
*/
|
||||
private List<Point> detectExtremeCornersByApproxPolyDp(TrackedTarget target, boolean convexHull) {
|
||||
var centroid = target.getMinAreaRect().center;
|
||||
Comparator<Point> distanceProvider =
|
||||
|
||||
@@ -28,11 +28,11 @@ public class FilterShapesPipe
|
||||
List<CVShape> outputList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Runs the process for the pipe.
|
||||
*
|
||||
* @param in Input for pipe processing.
|
||||
* @return Result of processing.
|
||||
*/
|
||||
* Runs the process for the pipe.
|
||||
*
|
||||
* @param in Input for pipe processing.
|
||||
* @return Result of processing.
|
||||
*/
|
||||
@Override
|
||||
protected List<CVShape> process(List<CVShape> in) {
|
||||
outputList.forEach(CVShape::release);
|
||||
|
||||
@@ -109,11 +109,11 @@ public class FindBoardCornersPipe
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the corners in a given image and returns them
|
||||
*
|
||||
* @param in Input for pipe processing. Pair of input and output mat
|
||||
* @return All valid Mats for camera calibration
|
||||
*/
|
||||
* Finds the corners in a given image and returns them
|
||||
*
|
||||
* @param in Input for pipe processing. Pair of input and output mat
|
||||
* @return All valid Mats for camera calibration
|
||||
*/
|
||||
@Override
|
||||
protected Triple<Size, Mat, Mat> process(Pair<Mat, Mat> in) {
|
||||
// Create the object points
|
||||
@@ -123,12 +123,12 @@ public class FindBoardCornersPipe
|
||||
}
|
||||
|
||||
/**
|
||||
* Figures out how much a frame or point cloud must be scaled down by to match the desired size at
|
||||
* which to run FindCorners
|
||||
*
|
||||
* @param inFrame
|
||||
* @return
|
||||
*/
|
||||
* Figures out how much a frame or point cloud must be scaled down by to match the desired size at
|
||||
* which to run FindCorners
|
||||
*
|
||||
* @param inFrame
|
||||
* @return
|
||||
*/
|
||||
private double getFindCornersScaleFactor(Mat inFrame) {
|
||||
if (inFrame.width() > FIND_CORNERS_WIDTH_PX) {
|
||||
return ((double) FIND_CORNERS_WIDTH_PX) / inFrame.width();
|
||||
@@ -138,21 +138,21 @@ public class FindBoardCornersPipe
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the minimum spacing between a set of x/y points Currently only considers points whose
|
||||
* index is next to each other Which, currently, means it traverses one dimension. This is a rough
|
||||
* heuristic approach which could be refined in the future.
|
||||
*
|
||||
* <p>Note that the current implementation can be fooled under the following conditions: (1) The
|
||||
* width of the image is an odd number, and the smallest distance was actually on the between the
|
||||
* last two points in a given row and (2) The smallest distance was actually in the direction
|
||||
* orthogonal to that which was getting traversed by iterating through the MatOfPoint2f in order.
|
||||
*
|
||||
* <p>I've chosen not to handle these for speed's sake, and because, really, you don't need the
|
||||
* exact answer for "min distance". you just need something fairly reasonable.
|
||||
*
|
||||
* @param inPoints point set to analyze. Must be a "tall" matrix.
|
||||
* @return min spacing between neighbors
|
||||
*/
|
||||
* Finds the minimum spacing between a set of x/y points Currently only considers points whose
|
||||
* index is next to each other Which, currently, means it traverses one dimension. This is a rough
|
||||
* heuristic approach which could be refined in the future.
|
||||
*
|
||||
* <p>Note that the current implementation can be fooled under the following conditions: (1) The
|
||||
* width of the image is an odd number, and the smallest distance was actually on the between the
|
||||
* last two points in a given row and (2) The smallest distance was actually in the direction
|
||||
* orthogonal to that which was getting traversed by iterating through the MatOfPoint2f in order.
|
||||
*
|
||||
* <p>I've chosen not to handle these for speed's sake, and because, really, you don't need the
|
||||
* exact answer for "min distance". you just need something fairly reasonable.
|
||||
*
|
||||
* @param inPoints point set to analyze. Must be a "tall" matrix.
|
||||
* @return min spacing between neighbors
|
||||
*/
|
||||
private double getApproxMinSpacing(MatOfPoint2f inPoints) {
|
||||
double minSpacing = Double.MAX_VALUE;
|
||||
for (int pointIdx = 0; pointIdx < inPoints.height() - 1; pointIdx += 2) {
|
||||
@@ -169,24 +169,24 @@ public class FindBoardCornersPipe
|
||||
}
|
||||
|
||||
/**
|
||||
* @param inFrame Full-size mat that is going to get scaled down before passing to
|
||||
* findBoardCorners
|
||||
* @return the size to scale the input mat to
|
||||
*/
|
||||
* @param inFrame Full-size mat that is going to get scaled down before passing to
|
||||
* findBoardCorners
|
||||
* @return the size to scale the input mat to
|
||||
*/
|
||||
private Size getFindCornersImgSize(Mat inFrame) {
|
||||
var findcorners_height = Math.round(inFrame.height() * getFindCornersScaleFactor(inFrame));
|
||||
return new Size(FIND_CORNERS_WIDTH_PX, findcorners_height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an input frame and a set of points from the "smaller" findChessboardCorner analysis,
|
||||
* re-scale the points back to where they would have been in the input frame
|
||||
*
|
||||
* @param inPoints set of points derived from a call to findChessboardCorner on a shrunken mat.
|
||||
* Must be a "tall" matrix.
|
||||
* @param origFrame Original frame we're rescaling points back to
|
||||
* @param outPoints mat into which the output rescaled points get placed
|
||||
*/
|
||||
* Given an input frame and a set of points from the "smaller" findChessboardCorner analysis,
|
||||
* re-scale the points back to where they would have been in the input frame
|
||||
*
|
||||
* @param inPoints set of points derived from a call to findChessboardCorner on a shrunken mat.
|
||||
* Must be a "tall" matrix.
|
||||
* @param origFrame Original frame we're rescaling points back to
|
||||
* @param outPoints mat into which the output rescaled points get placed
|
||||
*/
|
||||
private void rescalePointsToOrigFrame(
|
||||
MatOfPoint2f inPoints, Mat origFrame, MatOfPoint2f outPoints) {
|
||||
// Rescale boardCorners back up to the inproc image size
|
||||
@@ -202,12 +202,12 @@ public class FindBoardCornersPipe
|
||||
}
|
||||
|
||||
/**
|
||||
* Picks a window size for doing subpixel optimization based on the board type and spacing
|
||||
* observed between the corners or points in the image
|
||||
*
|
||||
* @param inPoints
|
||||
* @return
|
||||
*/
|
||||
* Picks a window size for doing subpixel optimization based on the board type and spacing
|
||||
* observed between the corners or points in the image
|
||||
*
|
||||
* @param inPoints
|
||||
* @return
|
||||
*/
|
||||
private Size getWindowSize(MatOfPoint2f inPoints) {
|
||||
double windowHalfWidth = 11; // Dot board uses fixed-size window half-width
|
||||
if (params.type == UICalibrationData.BoardType.CHESSBOARD) {
|
||||
@@ -219,10 +219,10 @@ public class FindBoardCornersPipe
|
||||
}
|
||||
|
||||
/**
|
||||
* Find chessboard corners given a input mat and output mat to draw on
|
||||
*
|
||||
* @return Frame resolution, object points, board corners
|
||||
*/
|
||||
* Find chessboard corners given a input mat and output mat to draw on
|
||||
*
|
||||
* @return Frame resolution, object points, board corners
|
||||
*/
|
||||
private Triple<Size, Mat, Mat> findBoardCorners(Pair<Mat, Mat> in) {
|
||||
createObjectPoints();
|
||||
|
||||
|
||||
@@ -33,15 +33,15 @@ public class FindCirclesPipe
|
||||
// (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
|
||||
* is a circle. Only issue with such approximation is that the user would no longer be able to
|
||||
* track shapes with 10-20+ sides. And hence, in order to overcome this edge case, we can use
|
||||
* HoughCircles which is more flexible and accurate for finding circles.
|
||||
*
|
||||
* @param in Input for pipe processing. 8-bit, single-channel, grayscale input image.
|
||||
* @return Result of processing.
|
||||
*/
|
||||
* 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
|
||||
* is a circle. Only issue with such approximation is that the user would no longer be able to
|
||||
* track shapes with 10-20+ sides. And hence, in order to overcome this edge case, we can use
|
||||
* HoughCircles which is more flexible and accurate for finding circles.
|
||||
*
|
||||
* @param in Input for pipe processing. 8-bit, single-channel, grayscale input image.
|
||||
* @return Result of processing.
|
||||
*/
|
||||
@Override
|
||||
protected List<CVShape> process(Pair<Mat, List<Contour>> in) {
|
||||
circles.release();
|
||||
@@ -115,16 +115,16 @@ public class FindCirclesPipe
|
||||
private final double diagonalLengthPx;
|
||||
|
||||
/*
|
||||
* @params minDist - Minimum distance between the centers of the detected circles.
|
||||
* If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
|
||||
*
|
||||
* @param maxCannyThresh -First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT, it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller).
|
||||
* Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value shough normally be higher, such as 300 or normally exposed and contrasty images.
|
||||
*
|
||||
*
|
||||
* @param allowableThreshold - When finding the corresponding contour, this is used to see how close a center should be to a contour for it to be considered THAT contour.
|
||||
* Should be increased with lower resolutions and decreased with higher resolution
|
||||
* */
|
||||
* @params minDist - Minimum distance between the centers of the detected circles.
|
||||
* If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
|
||||
*
|
||||
* @param maxCannyThresh -First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT, it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller).
|
||||
* Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value shough normally be higher, such as 300 or normally exposed and contrasty images.
|
||||
*
|
||||
*
|
||||
* @param allowableThreshold - When finding the corresponding contour, this is used to see how close a center should be to a contour for it to be considered THAT contour.
|
||||
* Should be increased with lower resolutions and decreased with higher resolution
|
||||
* */
|
||||
public FindCirclePipeParams(
|
||||
int allowableThreshold,
|
||||
int minRadius,
|
||||
|
||||
@@ -30,11 +30,11 @@ public class FindPolygonPipe
|
||||
List<CVShape> shapeList = new ArrayList<>();
|
||||
|
||||
/*
|
||||
* Runs the process for the pipe.
|
||||
*
|
||||
* @param in Input for pipe processing.
|
||||
* @return Result of processing.
|
||||
*/
|
||||
* Runs the process for the pipe.
|
||||
*
|
||||
* @param in Input for pipe processing.
|
||||
* @return Result of processing.
|
||||
*/
|
||||
@Override
|
||||
protected List<CVShape> process(List<Contour> in) {
|
||||
shapeList.forEach(CVShape::release);
|
||||
|
||||
@@ -25,10 +25,10 @@ import org.photonvision.vision.pipe.MutatingPipe;
|
||||
/** Pipe that resizes an image to a given resolution */
|
||||
public class ResizeImagePipe extends MutatingPipe<Mat, ResizeImagePipe.ResizeImageParams> {
|
||||
/**
|
||||
* Process this pipe
|
||||
*
|
||||
* @param in {@link Mat} to be resized
|
||||
*/
|
||||
* Process this pipe
|
||||
*
|
||||
* @param in {@link Mat} to be resized
|
||||
*/
|
||||
@Override
|
||||
protected Void process(Mat in) {
|
||||
int width = in.cols() / params.getDivisor().value;
|
||||
|
||||
@@ -32,11 +32,11 @@ public class RotateImagePipe extends MutatingPipe<Mat, RotateImagePipe.RotateIma
|
||||
}
|
||||
|
||||
/**
|
||||
* Process this pipe
|
||||
*
|
||||
* @param in {@link Mat} to be rotated
|
||||
* @return Rotated {@link Mat}
|
||||
*/
|
||||
* Process this pipe
|
||||
*
|
||||
* @param in {@link Mat} to be rotated
|
||||
* @return Rotated {@link Mat}
|
||||
*/
|
||||
@Override
|
||||
protected Void process(Mat in) {
|
||||
Core.rotate(in, in, params.rotation.value);
|
||||
|
||||
@@ -139,12 +139,12 @@ public class SolvePNPPipe
|
||||
}
|
||||
|
||||
/**
|
||||
* Element-wise scale a matrix by a given factor
|
||||
*
|
||||
* @param src the source matrix
|
||||
* @param factor by how much to scale each element
|
||||
* @return the scaled matrix
|
||||
*/
|
||||
* Element-wise scale a matrix by a given factor
|
||||
*
|
||||
* @param src the source matrix
|
||||
* @param factor by how much to scale each element
|
||||
* @return the scaled matrix
|
||||
*/
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static Mat matScale(Mat src, double factor) {
|
||||
Mat dst = new Mat(src.rows(), src.cols(), src.type());
|
||||
|
||||
@@ -28,9 +28,9 @@ import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
import org.photonvision.vision.target.TrackedTarget;
|
||||
|
||||
/**
|
||||
* This is a "fake" pipeline that is just used to move identical pipe sets out of real pipelines. It
|
||||
* shall not get its settings saved, nor shall it be managed by PipelineManager
|
||||
*/
|
||||
* This is a "fake" pipeline that is just used to move identical pipe sets out of real pipelines. It
|
||||
* shall not get its settings saved, nor shall it be managed by PipelineManager
|
||||
*/
|
||||
public class OutputStreamPipeline {
|
||||
private final OutputMatPipe outputMatPipe = new OutputMatPipe();
|
||||
private final Draw2dCrosshairPipe draw2dCrosshairPipe = new Draw2dCrosshairPipe();
|
||||
|
||||
@@ -29,13 +29,13 @@ public class PipelineProfiler {
|
||||
new Logger(ColoredShapePipeline.class, LogGroup.VisionModule);
|
||||
|
||||
/**
|
||||
* Indices for Reflective profiling 0 - rotateImagePipe 1 - inputCopy (not a pipe) 2 - hsvPipe 3 -
|
||||
* findContoursPipe 4 - speckleRejectPipe 5 - filterContoursPipe 6 - groupContoursPipe 7 -
|
||||
* sortContoursPipe 8 - collect2dTargetsPipe 9 - cornerDetectionPipe 10 - solvePNPPipe (OPTIONAL)
|
||||
* 11 - outputMatPipe (OPTIONAL) 12 - draw2dCrosshairPipe (on input) 13 - draw2dCrosshairPipe (on
|
||||
* output) 14 - draw2dTargetsPipe (on input) 15 - draw2dTargetsPipe (on output) 16 -
|
||||
* draw3dTargetsPipe (OPTIONAL, on input) 17 - draw3dTargetsPipe (OPTIONAL, on output)
|
||||
*/
|
||||
* Indices for Reflective profiling 0 - rotateImagePipe 1 - inputCopy (not a pipe) 2 - hsvPipe 3 -
|
||||
* findContoursPipe 4 - speckleRejectPipe 5 - filterContoursPipe 6 - groupContoursPipe 7 -
|
||||
* sortContoursPipe 8 - collect2dTargetsPipe 9 - cornerDetectionPipe 10 - solvePNPPipe (OPTIONAL)
|
||||
* 11 - outputMatPipe (OPTIONAL) 12 - draw2dCrosshairPipe (on input) 13 - draw2dCrosshairPipe (on
|
||||
* output) 14 - draw2dTargetsPipe (on input) 15 - draw2dTargetsPipe (on output) 16 -
|
||||
* draw3dTargetsPipe (OPTIONAL, on input) 17 - draw3dTargetsPipe (OPTIONAL, on output)
|
||||
*/
|
||||
private static final String[] ReflectivePipeNames =
|
||||
new String[] {
|
||||
"RotateImage",
|
||||
|
||||
@@ -63,10 +63,10 @@ public class CVPipelineResult implements Releasable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latency between now (wpi::Now) and the time at which the image was captured. FOOTGUN:
|
||||
* the latency is relative to the time at which this method is called. Waiting to call this method
|
||||
* will change the latency this method returns.
|
||||
*/
|
||||
* Get the latency between now (wpi::Now) and the time at which the image was captured. FOOTGUN:
|
||||
* the latency is relative to the time at which this method is called. Waiting to call this method
|
||||
* will change the latency this method returns.
|
||||
*/
|
||||
public double getLatencyMillis() {
|
||||
var now = MathUtils.wpiNanoTime();
|
||||
return MathUtils.nanosToMillis(now - imageCaptureTimestampNanos);
|
||||
|
||||
@@ -43,18 +43,18 @@ public class PipelineManager {
|
||||
private CVPipeline currentUserPipeline = driverModePipeline;
|
||||
|
||||
/**
|
||||
* Index of the last active user-created pipeline. <br>
|
||||
* <br>
|
||||
* Used only when switching from any of the built-in pipelines back to a user-created pipeline.
|
||||
*/
|
||||
* Index of the last active user-created pipeline. <br>
|
||||
* <br>
|
||||
* Used only when switching from any of the built-in pipelines back to a user-created pipeline.
|
||||
*/
|
||||
private int lastPipelineIndex;
|
||||
|
||||
/**
|
||||
* Creates a PipelineManager with a DriverModePipeline, a Calibration3dPipeline, and all provided
|
||||
* pipelines.
|
||||
*
|
||||
* @param userPipelines Pipelines to add to the manager.
|
||||
*/
|
||||
* Creates a PipelineManager with a DriverModePipeline, a Calibration3dPipeline, and all provided
|
||||
* pipelines.
|
||||
*
|
||||
* @param userPipelines Pipelines to add to the manager.
|
||||
*/
|
||||
public PipelineManager(
|
||||
DriverModePipelineSettings driverSettings, List<CVPipelineSettings> userPipelines) {
|
||||
this.userPipelineSettings = new ArrayList<>(userPipelines);
|
||||
@@ -70,11 +70,11 @@ public class PipelineManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings for a pipeline by index.
|
||||
*
|
||||
* @param index Index of pipeline whose settings need getting.
|
||||
* @return The gotten settings of the pipeline whose index was provided.
|
||||
*/
|
||||
* Get the settings for a pipeline by index.
|
||||
*
|
||||
* @param index Index of pipeline whose settings need getting.
|
||||
* @return The gotten settings of the pipeline whose index was provided.
|
||||
*/
|
||||
public CVPipelineSettings getPipelineSettings(int index) {
|
||||
if (index < 0) {
|
||||
switch (index) {
|
||||
@@ -92,10 +92,10 @@ public class PipelineManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of nicknames for all user pipelines
|
||||
*
|
||||
* @return The list of nicknames for all user pipelines
|
||||
*/
|
||||
* Gets a list of nicknames for all user pipelines
|
||||
*
|
||||
* @return The list of nicknames for all user pipelines
|
||||
*/
|
||||
public List<String> getPipelineNicknames() {
|
||||
List<String> ret = new ArrayList<>();
|
||||
for (var p : userPipelineSettings) {
|
||||
@@ -105,19 +105,19 @@ public class PipelineManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of the currently active pipeline
|
||||
*
|
||||
* @return The index of the currently active pipeline
|
||||
*/
|
||||
* Gets the index of the currently active pipeline
|
||||
*
|
||||
* @return The index of the currently active pipeline
|
||||
*/
|
||||
public int getCurrentPipelineIndex() {
|
||||
return currentPipelineIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently active pipeline.
|
||||
*
|
||||
* @return The currently active pipeline.
|
||||
*/
|
||||
* Get the currently active pipeline.
|
||||
*
|
||||
* @return The currently active pipeline.
|
||||
*/
|
||||
public CVPipeline getCurrentUserPipeline() {
|
||||
if (currentPipelineIndex < 0) {
|
||||
switch (currentPipelineIndex) {
|
||||
@@ -149,22 +149,22 @@ public class PipelineManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently active pipelines settings
|
||||
*
|
||||
* @return The currently active pipelines settings
|
||||
*/
|
||||
* Get the currently active pipelines settings
|
||||
*
|
||||
* @return The currently active pipelines settings
|
||||
*/
|
||||
public CVPipelineSettings getCurrentPipelineSettings() {
|
||||
return getPipelineSettings(currentPipelineIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method for setting the active pipeline. <br>
|
||||
* <br>
|
||||
* All externally accessible methods that intend to change the active pipeline MUST go through
|
||||
* here to ensure all proper steps are taken.
|
||||
*
|
||||
* @param index Index of pipeline to be active
|
||||
*/
|
||||
* Internal method for setting the active pipeline. <br>
|
||||
* <br>
|
||||
* All externally accessible methods that intend to change the active pipeline MUST go through
|
||||
* here to ensure all proper steps are taken.
|
||||
*
|
||||
* @param index Index of pipeline to be active
|
||||
*/
|
||||
private void setPipelineInternal(int index) {
|
||||
if (index < 0) {
|
||||
lastPipelineIndex = currentPipelineIndex;
|
||||
@@ -192,33 +192,33 @@ public class PipelineManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enters or exits calibration mode based on the parameter. <br>
|
||||
* <br>
|
||||
* Exiting returns to the last used user pipeline.
|
||||
*
|
||||
* @param wantsCalibration True to enter calibration mode, false to exit calibration mode.
|
||||
*/
|
||||
* Enters or exits calibration mode based on the parameter. <br>
|
||||
* <br>
|
||||
* Exiting returns to the last used user pipeline.
|
||||
*
|
||||
* @param wantsCalibration True to enter calibration mode, false to exit calibration mode.
|
||||
*/
|
||||
public void setCalibrationMode(boolean wantsCalibration) {
|
||||
if (!wantsCalibration) calibration3dPipeline.finishCalibration();
|
||||
setPipelineInternal(wantsCalibration ? CAL_3D_INDEX : lastPipelineIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enters or exits driver mode based on the parameter. <br>
|
||||
* <br>
|
||||
* Exiting returns to the last used user pipeline.
|
||||
*
|
||||
* @param state True to enter driver mode, false to exit driver mode.
|
||||
*/
|
||||
* Enters or exits driver mode based on the parameter. <br>
|
||||
* <br>
|
||||
* Exiting returns to the last used user pipeline.
|
||||
*
|
||||
* @param state True to enter driver mode, false to exit driver mode.
|
||||
*/
|
||||
public void setDriverMode(boolean state) {
|
||||
setPipelineInternal(state ? DRIVERMODE_INDEX : lastPipelineIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not driver mode is active.
|
||||
*
|
||||
* @return Whether or not driver mode is active.
|
||||
*/
|
||||
* Returns whether or not driver mode is active.
|
||||
*
|
||||
* @return Whether or not driver mode is active.
|
||||
*/
|
||||
public boolean getDriverMode() {
|
||||
return currentPipelineIndex == DRIVERMODE_INDEX;
|
||||
}
|
||||
@@ -227,10 +227,10 @@ public class PipelineManager {
|
||||
Comparator.comparingInt(o -> o.pipelineIndex);
|
||||
|
||||
/**
|
||||
* Sorts the pipeline list by index, and reassigns their indexes to match the new order. <br>
|
||||
* <br>
|
||||
* I don't like this but I have no other ideas, and it works so ¯\_(ツ)_/¯
|
||||
*/
|
||||
* Sorts the pipeline list by index, and reassigns their indexes to match the new order. <br>
|
||||
* <br>
|
||||
* I don't like this but I have no other ideas, and it works so ¯\_(ツ)_/¯
|
||||
*/
|
||||
private void reassignIndexes() {
|
||||
userPipelineSettings.sort(PipelineSettingsIndexComparator);
|
||||
for (int i = 0; i < userPipelineSettings.size(); i++) {
|
||||
@@ -283,10 +283,10 @@ public class PipelineManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a pipeline settings at the given index and return the new current index
|
||||
*
|
||||
* @param index The idx to remove
|
||||
*/
|
||||
* Remove a pipeline settings at the given index and return the new current index
|
||||
*
|
||||
* @param index The idx to remove
|
||||
*/
|
||||
private int removePipelineInternal(int index) {
|
||||
userPipelineSettings.remove(index);
|
||||
currentPipelineIndex = Math.min(index, userPipelineSettings.size() - 1);
|
||||
@@ -311,11 +311,11 @@ public class PipelineManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate a pipeline at a given index
|
||||
*
|
||||
* @param index the index of the target pipeline
|
||||
* @return The new index
|
||||
*/
|
||||
* Duplicate a pipeline at a given index
|
||||
*
|
||||
* @param index the index of the target pipeline
|
||||
* @return The new index
|
||||
*/
|
||||
public int duplicatePipeline(int index) {
|
||||
var settings = userPipelineSettings.get(index);
|
||||
var newSettings = settings.clone();
|
||||
|
||||
@@ -50,11 +50,11 @@ import org.photonvision.vision.target.TargetModel;
|
||||
import org.photonvision.vision.target.TrackedTarget;
|
||||
|
||||
/**
|
||||
* This is the God Class
|
||||
*
|
||||
* <p>VisionModule has a pipeline manager, vision runner, and data providers. The data providers
|
||||
* provide info on settings changes. VisionModuleManager holds a list of all current vision modules.
|
||||
*/
|
||||
* This is the God Class
|
||||
*
|
||||
* <p>VisionModule has a pipeline manager, vision runner, and data providers. The data providers
|
||||
* provide info on settings changes. VisionModuleManager holds a list of all current vision modules.
|
||||
*/
|
||||
public class VisionModule {
|
||||
private static final int streamFPSCap = 30;
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ public class VisionRunner {
|
||||
private long loopCount;
|
||||
|
||||
/**
|
||||
* VisionRunner contains a thread to run a pipeline, given a frame, and will give the result to
|
||||
* the consumer.
|
||||
*
|
||||
* @param frameSupplier The supplier of the latest frame.
|
||||
* @param pipelineSupplier The supplier of the current pipeline.
|
||||
* @param pipelineResultConsumer The consumer of the latest result.
|
||||
*/
|
||||
* VisionRunner contains a thread to run a pipeline, given a frame, and will give the result to
|
||||
* the consumer.
|
||||
*
|
||||
* @param frameSupplier The supplier of the latest frame.
|
||||
* @param pipelineSupplier The supplier of the current pipeline.
|
||||
* @param pipelineResultConsumer The consumer of the latest result.
|
||||
*/
|
||||
public VisionRunner(
|
||||
FrameProvider frameSupplier,
|
||||
Supplier<CVPipeline> pipelineSupplier,
|
||||
|
||||
@@ -61,11 +61,11 @@ public class VisionSourceManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register new camera configs loaded from disk. This will add them to the list of configs to try
|
||||
* to match, and also automatically spawn new vision processes as necessary.
|
||||
*
|
||||
* @param configs The loaded camera configs.
|
||||
*/
|
||||
* Register new camera configs loaded from disk. This will add them to the list of configs to try
|
||||
* to match, and also automatically spawn new vision processes as necessary.
|
||||
*
|
||||
* @param configs The loaded camera configs.
|
||||
*/
|
||||
public void registerLoadedConfigs(Collection<CameraConfiguration> configs) {
|
||||
unmatchedLoadedConfigs.addAll(configs);
|
||||
}
|
||||
@@ -182,13 +182,13 @@ public class VisionSourceManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create {@link CameraConfiguration}s based on a list of detected USB cameras and the configs on
|
||||
* disk.
|
||||
*
|
||||
* @param detectedCamInfos Information about currently connected USB cameras.
|
||||
* @param loadedUsbCamConfigs The USB {@link CameraConfiguration}s loaded from disk.
|
||||
* @return the matched configurations.
|
||||
*/
|
||||
* Create {@link CameraConfiguration}s based on a list of detected USB cameras and the configs on
|
||||
* disk.
|
||||
*
|
||||
* @param detectedCamInfos Information about currently connected USB cameras.
|
||||
* @param loadedUsbCamConfigs The USB {@link CameraConfiguration}s loaded from disk.
|
||||
* @return the matched configurations.
|
||||
*/
|
||||
private List<CameraConfiguration> matchUSBCameras(
|
||||
List<UsbCameraInfo> detectedCamInfos, List<CameraConfiguration> loadedUsbCamConfigs) {
|
||||
var detectedCameraList = new ArrayList<>(detectedCamInfos);
|
||||
@@ -319,12 +319,12 @@ public class VisionSourceManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given config list contains the given unique name.
|
||||
*
|
||||
* @param configList A list of camera configs.
|
||||
* @param uniqueName The unique name.
|
||||
* @return If the list of configs contains the unique name.
|
||||
*/
|
||||
* Check if a given config list contains the given unique name.
|
||||
*
|
||||
* @param configList A list of camera configs.
|
||||
* @param uniqueName The unique name.
|
||||
* @return If the list of configs contains the unique name.
|
||||
*/
|
||||
private boolean containsName(
|
||||
final List<CameraConfiguration> configList, final String uniqueName) {
|
||||
return configList.stream()
|
||||
|
||||
@@ -57,10 +57,10 @@ public class TrackedTarget implements Releasable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the approximate bouding polygon.
|
||||
*
|
||||
* @param boundingPolygon List of points to copy. Not modified.
|
||||
*/
|
||||
* Set the approximate bouding polygon.
|
||||
*
|
||||
* @param boundingPolygon List of points to copy. Not modified.
|
||||
*/
|
||||
public void setApproximateBoundingPolygon(MatOfPoint2f boundingPolygon) {
|
||||
if (m_approximateBoundingPolygon == null) m_approximateBoundingPolygon = new MatOfPoint2f();
|
||||
boundingPolygon.copyTo(m_approximateBoundingPolygon);
|
||||
|
||||
@@ -16,21 +16,21 @@
|
||||
*/
|
||||
package org.photonvision.common;
|
||||
/*
|
||||
* Copyright (C) 2020 Photon Vision.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
* Copyright (C) 2020 Photon Vision.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -314,15 +314,15 @@ public class Calibrate3dPipeTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses a given camera coefficents matrix set to "undistort" every image file found in a given
|
||||
* directory and display them. Provides an easy way to visually debug the results of the
|
||||
* calibration routine. Seems to play havoc with CI and takes a chunk of time, so shouldn't
|
||||
* usually be left active in tests.
|
||||
*
|
||||
* @param directoryListing
|
||||
* @param imgRes
|
||||
* @param cal
|
||||
*/
|
||||
* Uses a given camera coefficents matrix set to "undistort" every image file found in a given
|
||||
* directory and display them. Provides an easy way to visually debug the results of the
|
||||
* calibration routine. Seems to play havoc with CI and takes a chunk of time, so shouldn't
|
||||
* usually be left active in tests.
|
||||
*
|
||||
* @param directoryListing
|
||||
* @param imgRes
|
||||
* @param cal
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void visuallyDebugDistortion(
|
||||
File[] directoryListing, Size imgRes, CameraCalibrationCoefficients cal) {
|
||||
|
||||
Reference in New Issue
Block a user