微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决我如何使用 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 举报,一经查实,本站将立刻删除。