mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-04 03:11:40 +00:00
added fps counter
This commit is contained in:
@@ -61,9 +61,11 @@ public class CameraProcess implements Runnable {
|
|||||||
Mat contourBoxPointsMat = new Mat();
|
Mat contourBoxPointsMat = new Mat();
|
||||||
Scalar contourColor = new Scalar(255, 0, 0);
|
Scalar contourColor = new Scalar(255, 0, 0);
|
||||||
long startTime, endTime;
|
long startTime, endTime;
|
||||||
|
startTime = System.nanoTime();
|
||||||
|
int duration = 1;
|
||||||
|
int counter = 0;
|
||||||
|
double fps = 0;
|
||||||
while (!Thread.interrupted()) {
|
while (!Thread.interrupted()) {
|
||||||
startTime = System.nanoTime();
|
|
||||||
|
|
||||||
FoundContours.clear();
|
FoundContours.clear();
|
||||||
FilteredContours.clear();
|
FilteredContours.clear();
|
||||||
@@ -97,14 +99,20 @@ public class CameraProcess implements Runnable {
|
|||||||
a.add(new MatOfPoint(vertices));
|
a.add(new MatOfPoint(vertices));
|
||||||
Imgproc.drawContours(outputMat,a, 0, contourColor, 3);
|
Imgproc.drawContours(outputMat,a, 0, contourColor, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
cv_publish.putFrame(outputMat);
|
cv_publish.putFrame(outputMat);
|
||||||
|
System.out.println("fps: " + fps);
|
||||||
inputMat.release();
|
inputMat.release();
|
||||||
hsvThreshMat.release();
|
hsvThreshMat.release();
|
||||||
for (MatOfPoint oldMat : FoundContours) { oldMat.release(); }
|
for (MatOfPoint oldMat : FoundContours) { oldMat.release(); }
|
||||||
for (MatOfPoint oldMat1 : FilteredContours) { oldMat1.release(); }
|
for (MatOfPoint oldMat1 : FilteredContours) { oldMat1.release(); }
|
||||||
memManager.run();
|
memManager.run();
|
||||||
endTime = System.nanoTime();
|
counter++;
|
||||||
|
if ((System.nanoTime() - startTime)*1e-9 > duration){
|
||||||
|
fps = (counter / ((System.nanoTime() - startTime)*1e-9 ));
|
||||||
|
counter = 0;
|
||||||
|
startTime = System.nanoTime();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user