java - 我如何使用 OpenImaj 只听屏幕的两个特定区域
问题描述
我正在使用 OpenImaj 库来开发一个项目,该项目计算进出商场的人数:每次从上行到蓝线的一些动作都会计数一个数字。每次一些动作从下行传递到红线时,只需休息一个数字。
一点点画来更好地解释
我的项目中的线条非常好,但我无法设置聆听动作的区域。
我怎么能得到两个区域来识别从上到下正在发生一些运动,反之亦然。
package com.molokotech;
import org.openimaj.image.MBFImage;
import org.openimaj.image.colour.RGBColour;
import org.openimaj.math.geometry.point.Point2d;
import org.openimaj.math.geometry.point.Point2dImpl;
import org.openimaj.video.VideoDisplay;
import org.openimaj.video.VideoDisplayListener;
import org.openimaj.video.capture.VideoCapture;
import org.openimaj.video.capture.VideoCaptureException;
public class CounterInOut {
public static void main(String[] args) throws VideoCaptureException {
getVideoDisplayListener();
}
private static void getVideoDisplayListener() throws VideoCaptureException {
VideoCapture vc = new VideoCapture(320, 240);
VideoDisplay<MBFImage> vd = VideoDisplay.createVideoDisplay(vc);
vd.addVideoListener(
new VideoDisplayListener<MBFImage>() {
public void beforeUpdate(MBFImage frame) {
// frame.processInplace(new CannyEdgeDetector());
float separator = (frame.getWidth() * 0.05f);
// Line 1
Point2d p1 = new Point2dImpl((frame.getWidth() / 2 - separator), frame.getHeight() / 2);
Point2d p2 = new Point2dImpl(separator, frame.getHeight() / 2);
frame.drawLine(p1, p2, 3, RGBColour.BLUE);
// Line 2
Point2d p3 = new Point2dImpl((frame.getWidth() / 2 + separator), frame.getHeight() / 2);
Point2d p4 = new Point2dImpl(frame.getWidth() - separator, frame.getHeight() / 2);
frame.drawLine(p3, p4, 3, RGBColour.RED);
}
public void afterUpdate(VideoDisplay<MBFImage> display) {
}
});
}
}
线条非常好,但现在没用。
首先我需要解决这个问题才能继续,因为我被卡住了。
是否有任何参数或东西来设置该区域以在此时拍摄事件 => vd.addVideoListener( ) { doSomething( ); };
像这样的东西:
vd.addVideoListener(coordinatesX, coordinatesY) { doSomething( ); };
库中不存在此代码,但我认为应该存在类似的代码。
所以我可以在两个方面调用它两次:
int actualCapacity = 0;
vd.addVideoListener(0.0, 120.0) { actualCapacity++; };
vd.addVideoListener(160.0, 120.0) { actualCapacity--; };
只是伪代码。
解决方案
推荐阅读
- mysql - 编辑另一个表时如何更新一个表的列
- python - 为什么 Asyncio 在 socket.send(data) 中花费时间
- assembly - 为什么我的手臂汇编代码没有在 LLDB 中设置断点
- yii2 - 表的别名
- python - Python 3:在列表中查找项目并据此回答
- css - 如何仅在 3 个面上应用 box-shadow?
- go - mgo 是否具有从查询结果中对每个文档的特定 Slice 字段进行排序的功能?
- javascript - 如何使用 ts-loader 将混淆器加载器应用于 ts 文件
- android - Appium 测试不在 AWS Device Farm 上运行,但在本地运行良好
- java - 扩展实现 ToolBar 的 Base Activity 时,Activity 中不显示工具栏