mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Create timesync JNI for testing client (#1433)
This commit is contained in:
@@ -69,7 +69,7 @@ public class PhotonCameraSim implements AutoCloseable {
|
||||
private final PhotonCamera cam;
|
||||
|
||||
NTTopicSet ts = new NTTopicSet();
|
||||
private long heartbeatCounter = 0;
|
||||
private long heartbeatCounter = 1;
|
||||
|
||||
/** This simulated camera's {@link SimCameraProperties} */
|
||||
public final SimCameraProperties prop;
|
||||
@@ -553,9 +553,10 @@ public class PhotonCameraSim implements AutoCloseable {
|
||||
heartbeatCounter,
|
||||
now - (long) (latencyMillis * 1000),
|
||||
now,
|
||||
// Pretend like we heard a pong recently
|
||||
1000L + (long) ((Math.random() - 0.5) * 50),
|
||||
detectableTgts,
|
||||
multitagResult);
|
||||
ret.setReceiveTimestampMicros(now);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -605,6 +606,8 @@ public class PhotonCameraSim implements AutoCloseable {
|
||||
|
||||
ts.cameraIntrinsicsPublisher.set(prop.getIntrinsics().getData(), receiveTimestamp);
|
||||
ts.cameraDistortionPublisher.set(prop.getDistCoeffs().getData(), receiveTimestamp);
|
||||
ts.heartbeatPublisher.set(heartbeatCounter++, receiveTimestamp);
|
||||
|
||||
ts.heartbeatPublisher.set(heartbeatCounter, receiveTimestamp);
|
||||
heartbeatCounter += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import java.util.Map;
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfByte;
|
||||
import org.opencv.core.MatOfPoint;
|
||||
import org.opencv.core.MatOfPoint2f;
|
||||
import org.opencv.core.Point;
|
||||
@@ -99,11 +100,18 @@ public class VideoSimUtil {
|
||||
*
|
||||
* @param id The fiducial id of the desired tag
|
||||
*/
|
||||
public static Mat get36h11TagImage(int id) {
|
||||
private static Mat get36h11TagImage(int id) {
|
||||
RawFrame frame = AprilTag.generate36h11AprilTagImage(id);
|
||||
Mat result = new Mat(10, 10, CvType.CV_8UC1, frame.getData(), frame.getStride()).clone();
|
||||
frame.close();
|
||||
return result;
|
||||
|
||||
var buf = frame.getData();
|
||||
byte[] arr = new byte[buf.remaining()];
|
||||
buf.get(arr);
|
||||
// frame.close();
|
||||
|
||||
var mat = new MatOfByte(arr).reshape(1, 10).submat(new Rect(0, 0, 10, 10));
|
||||
mat.dump();
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
/** Gets the points representing the marker(black square) corners. */
|
||||
|
||||
Reference in New Issue
Block a user