mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11:40 +00:00
Move Java backend to properly named folder
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.chameleonvision.vision.image;
|
||||
|
||||
import com.chameleonvision.vision.camera.CaptureStaticProperties;
|
||||
import edu.wpi.cscore.VideoMode;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
public class CaptureProperties {
|
||||
|
||||
protected CaptureStaticProperties staticProperties;
|
||||
|
||||
protected CaptureProperties() {
|
||||
}
|
||||
|
||||
public CaptureProperties(Mat staticImage, double fov) {
|
||||
staticProperties = new CaptureStaticProperties(new VideoMode(0, staticImage.cols(), staticImage.rows(), 99999), staticImage.cols(), staticImage.rows(), fov);
|
||||
}
|
||||
|
||||
public CaptureStaticProperties getStaticProperties() {
|
||||
return staticProperties;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.chameleonvision.vision.image;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
public interface ImageCapture {
|
||||
/**
|
||||
* Get the next camera frame
|
||||
* @return a Pair of the captured image and the Linux epoch of when the frame was grabbed (in uS)
|
||||
*/
|
||||
Pair<Mat, Long> getFrame();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.chameleonvision.vision.image;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class StaticImageCapture implements ImageCapture {
|
||||
|
||||
private final Mat image = new Mat();
|
||||
|
||||
public StaticImageCapture(Path imagePath) {
|
||||
if (!Files.exists(imagePath)) throw new RuntimeException("Invalid path for image!");
|
||||
|
||||
Mat tempMat = new Mat();
|
||||
|
||||
try {
|
||||
tempMat = Imgcodecs.imread(imagePath.toString());
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to read image!");
|
||||
} finally {
|
||||
tempMat.copyTo(image);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Mat, Long> getFrame() {
|
||||
return Pair.of(image, System.nanoTime());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user