我如何使用 OpenImaj 只收听屏幕的两个特定区域

问题描述

我正在使用 OpenImaj 库开发一个项目,用于统计进出商场的人数: 每次从上方到蓝线的一些运动都计算一个数字。 每次有运动从下方移动到红线时,只需休息一个数字。

一点点画画更好地解释

enter image description here

我的项目中的台词非常好,但我无法设置一个可以听动作的区域。

我怎样才能让两个区域识别出一些运动是从上到下发生的,反之亦然。

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,RGBColour.RED);
                }

                public void afterUpdate(Videodisplay<MBFImage> display) {
                }
            });
    }

}

线条很好,但现在没用。

enter image description here

首先我需要先解决这个问题,然后才能继续,因为我卡住了。

此时是否有任何参数或东西来设置区域以拍摄事件 => 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--; };

只是伪代码

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)