mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-23 01:21:40 +00:00
Move Java backend to properly named folder
This commit is contained in:
@@ -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