mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-21 01:01:41 +00:00
Added Runnables for VisionProcess threads
This commit is contained in:
@@ -8,10 +8,9 @@ public interface CameraProcess {
|
||||
|
||||
/**
|
||||
* Get the next camera frame
|
||||
* @param frame the frame to copy the image into
|
||||
* @return a Pair of the captured image and how long it took to grab the frame (in uS)
|
||||
*/
|
||||
Pair<Mat, Long> getFrame(Mat frame);
|
||||
Pair<Mat, Long> getFrame();
|
||||
|
||||
/**
|
||||
* Set the exposure of the camera
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.chameleonvision.classabstraction.camera;
|
||||
|
||||
import com.chameleonvision.vision.camera.CameraManager;
|
||||
import com.chameleonvision.vision.camera.StreamDivisor;
|
||||
import com.chameleonvision.web.ServerHandler;
|
||||
import edu.wpi.cscore.CvSource;
|
||||
@@ -11,7 +10,6 @@ import org.opencv.core.Size;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
public class CameraStreamer {
|
||||
|
||||
private final CameraProcess cameraProcess;
|
||||
private final String name;
|
||||
private StreamDivisor divisor = StreamDivisor.NONE;
|
||||
@@ -27,7 +25,6 @@ public class CameraStreamer {
|
||||
cameraProcess.getProperties().staticProperties.imageHeight / divisor.value);
|
||||
}
|
||||
|
||||
|
||||
public void setDivisor(StreamDivisor newDivisor) {
|
||||
this.divisor = newDivisor;
|
||||
var camValues = cameraProcess.getProperties();
|
||||
@@ -42,9 +39,7 @@ public class CameraStreamer {
|
||||
ServerHandler.sendFullSettings();
|
||||
}
|
||||
|
||||
public void runStream() {
|
||||
var newFrame = cameraProcess.getFrame(streamBuffer);
|
||||
var image = newFrame.getLeft();
|
||||
public void runStream(Mat image) {
|
||||
if (divisor.value != 1) {
|
||||
var camVal = cameraProcess.getProperties().staticProperties;
|
||||
var newWidth = camVal.imageWidth / divisor.value;
|
||||
|
||||
@@ -28,13 +28,12 @@ public class USBCameraProcess implements CameraProcess {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Mat, Long> getFrame(Mat frame) {
|
||||
public Pair<Mat, Long> getFrame() {
|
||||
Long deltaTime;
|
||||
synchronized (cvSink) {
|
||||
deltaTime = cvSink.grabFrame(imageBuffer) * 1000L;
|
||||
imageBuffer.copyTo(frame);
|
||||
}
|
||||
return Pair.of(frame, deltaTime);
|
||||
return Pair.of(imageBuffer, deltaTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user