Skip to content

Commit

Permalink
Revert example changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Dec 24, 2024
1 parent 7d7a1b6 commit 5605894
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class VisionRunner<P extends VisionPipeline> {
private final CvSink m_cvSink = new CvSink("VisionRunner CvSink");
private final P m_pipeline;
private final Mat m_image = new Mat();
private long m_lastFrameTime = 0;
private final Listener<? super P> m_listener;
private volatile boolean m_enabled = true;

Expand Down Expand Up @@ -82,7 +81,7 @@ public void runOnce() {
}

private void runOnceInternal() {
long frameTime = m_cvSink.grabFrame(m_image, m_lastFrameTime);
long frameTime = m_cvSink.grabFrame(m_image);
if (frameTime == 0) {
// There was an error, report it
String error = m_cvSink.getError();
Expand All @@ -91,8 +90,6 @@ private void runOnceInternal() {
// No errors, process the image
m_pipeline.process(m_image);
m_listener.copyPipelineOutputs(m_pipeline);

m_lastFrameTime = frameTime;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,18 @@ class Robot : public frc::TimedRobot {
nt::NetworkTableInstance::GetDefault().GetTable("apriltags");
auto pubTags = tagsTable->GetIntegerArrayTopic("tags").Publish();

// Keep track of the timestamp of the last frame we processed. This lets us
// ask CSCore for the next image we haven't yet seen
uint64_t lastFrameTime{0};

while (true) {
// Tell the CvSink to grab a frame from the camera and
// put it in the source mat. If there is an error notify the
// output.
auto frameTime = cvSink.GrabFrame(mat, lastFrameTime = lastFrameTime);
auto frameTime = cvSink.GrabFrame(mat);
if (frameTime == 0) {
// Send the output the error.
outputStream.NotifyError(cvSink.GetError());
// skip the rest of the current iteration
continue;
}

// Write the frame time down for next loop
lastFrameTime = frameTime;

cv::cvtColor(mat, grayMat, cv::COLOR_BGR2GRAY);

cv::Size g_size = grayMat.size();
Expand Down

0 comments on commit 5605894

Please sign in to comment.