public void startThread() {
if (thread == null) {
// Create a new thread that will constantly evaluate new camera frames
thread = new Thread(() -> {
Mat image = new Mat(CAMERA_HEIGHT, CAMERA_WIDTH, 6);
while (!Thread.interrupted()) {
// Check whether it's time to evaluate a new rame
currentFrameTime = sink.grabFrameNoTimeout(image);
if (currentFrameTime == 0 || currentFrameTime == prevFrameTime) {
continue;
}
prevFrameTime = currentFrameTime;
// Process image using generated pipeline
pipeline.process(image);
// Get pipeline objects
ArrayList<MatOfPoint> mops = pipeline.filterContoursOutput();
// Evaluate objects
for (MatOfPoint mop : mops) {
Rect bRect = Imgproc.boundingRect(mop);
Imgproc.rectangle(image, bRect.tl(), bRect.br(), new Scalar(255, 0, 255));
// TODO: Evaluate objects
}
// Send the evaluated image to the output stream
output.putFrame(image);
}
});
thread.start();
}
}
Vision.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:frc-robot
作者:
评论列表
文章目录