目标跟踪技术

简介: Boofcv研究:动态目标追踪public class RemovalMoving { public static void main(String[] args) { String fileName = UtilIO.

Boofcv研究:动态目标追踪

public class RemovalMoving {
    public static void main(String[] args) {
        String fileName = UtilIO.pathExample("D:\\JavaProject\\Boofcv\\example\\tracking\\chipmunk.mjpeg");
        ImageType imageType = ImageType.single(GrayF32.class);      
        //ImageType imageType = ImageType.il(3, InterleavedF32.class);
        //ImageType imageType = ImageType.il(3, InterleavedU8.class);

        ConfigGeneralDetector confDetector = new ConfigGeneralDetector();
        confDetector.threshold = 10;
        confDetector.maxFeatures = 300;
        confDetector.radius = 6;

        //  KLT tracker
        PointTracker tracker = FactoryPointTracker.klt(new int[]{1, 2, 4, 8}, confDetector, 3,
                GrayF32.class, null);

        // This estimates the 2D image motion
        ImageMotion2D<GrayF32,Homography2D_F64> motion2D =
                FactoryMotion2D.createMotion2D(500, 0.5, 3, 100, 0.6, 0.5, false, tracker, new Homography2D_F64());

        ConfigBackgroundBasic configBasic = new ConfigBackgroundBasic(30, 0.005f);

        // Configuration for Gaussian model.  Note that the threshold changes depending on the number of image bands
        // 12 = gray scale and 40 = color
        ConfigBackgroundGaussian configGaussian = new ConfigBackgroundGaussian(12,0.001f);
        configGaussian.initialVariance = 64;
        configGaussian.minimumDifference = 5;

        // Comment/Uncomment to switch background mode
        BackgroundModelMoving background =
                FactoryBackgroundModel.movingBasic(configBasic, new PointTransformHomography_F32(), imageType);
//              FactoryBackgroundModel.movingGaussian(configGaussian, new PointTransformHomography_F32(), imageType);


        MediaManager media = DefaultMediaManager.INSTANCE;
        SimpleImageSequence video =
                media.openVideo(fileName, background.getImageType());
                media.openCamera(null,640,480,background.getImageType());


        // storage for segmented image.  Background = 0, Foreground = 1
        GrayU8 segmented = new GrayU8(video.getNextWidth(),video.getNextHeight());
        // Grey scale image that's the input for motion estimation
        GrayF32 grey = new GrayF32(segmented.width,segmented.height);

        // coordinate frames
        Homography2D_F32 firstToCurrent32 = new Homography2D_F32();
        Homography2D_F32 homeToWorld = new Homography2D_F32();
        homeToWorld.a13 = grey.width/2;
        homeToWorld.a23 = grey.height/2;

        // Create a background image twice the size of the input image.  Tell it that the home is in the center
        background.initialize(grey.width * 2, grey.height * 2, homeToWorld);

        BufferedImage visualized = new BufferedImage(segmented.width,segmented.height,BufferedImage.TYPE_INT_RGB);
        ImageGridPanel gui = new ImageGridPanel(1,2);
        gui.setImages(visualized, visualized);

        ShowImages.showWindow(gui, "Detections", true);

        double fps = 0;
        double alpha = 0.01; // smoothing factor for FPS

        while( video.hasNext() ) {
            ImageBase input = video.next();

            long before = System.nanoTime();
            GConvertImage.convert(input, grey);

            if( !motion2D.process(grey) ) {
                throw new RuntimeException("Should handle this scenario");
            }

            Homography2D_F64 firstToCurrent64 = motion2D.getFirstToCurrent();
            UtilHomography.convert(firstToCurrent64, firstToCurrent32);

            background.segment(firstToCurrent32, input, segmented);
            background.updateBackground(firstToCurrent32,input);
            long after = System.nanoTime();

            fps = (1.0-alpha)*fps + alpha*(1.0/((after-before)/1e9));

            VisualizeBinaryData.renderBinary(segmented,false,visualized);
            gui.setImage(0, 0, (BufferedImage)video.getGuiImage());
            gui.setImage(0, 1, visualized);
            gui.repaint();

            System.out.println("FPS = "+fps);

            try {Thread.sleep(5);} catch (InterruptedException e) {}
        }
    }
}

这里写图片描述

这里写图片描述

这里写图片描述

目录
相关文章
|
存储 Linux Docker
snapshotter not loaded: overlayfs: invalid argument
snapshotter not loaded: overlayfs: invalid argument
461 0
|
1天前
|
云安全 数据采集 人工智能
古茗联名引爆全网,阿里云三层防护助力对抗黑产
阿里云三层校验+风险识别,为古茗每一杯奶茶保驾护航!
古茗联名引爆全网,阿里云三层防护助力对抗黑产
|
5天前
|
人工智能 中间件 API
AutoGen for .NET - 架构学习指南
《AutoGen for .NET 架构学习指南》系统解析微软多智能体框架,涵盖新旧双架构、核心设计、技术栈与实战路径,助你从入门到精通,构建分布式AI协同系统。
300 142
|
5天前
|
Kubernetes 算法 Go
Kubeflow-Katib-架构学习指南
本指南带你深入 Kubeflow 核心组件 Katib,一个 Kubernetes 原生的自动化机器学习系统。从架构解析、代码结构到技能清单与学习路径,助你由浅入深掌握超参数调优与神经架构搜索,实现从使用到贡献的进阶之旅。
279 139
|
2天前
|
存储 机器学习/深度学习 人工智能
大模型微调技术:LoRA原理与实践
本文深入解析大语言模型微调中的关键技术——低秩自适应(LoRA)。通过分析全参数微调的计算瓶颈,详细阐述LoRA的数学原理、实现机制和优势特点。文章包含完整的PyTorch实现代码、性能对比实验以及实际应用场景,为开发者提供高效微调大模型的实践指南。
297 0
|
2天前
|
传感器 人工智能 算法
数字孪生智慧水务系统,三维立体平台,沃思智能
智慧水务系统融合物联网、数字孪生与AI技术,实现供水全流程智能监测、预测性维护与动态优化。通过实时数据采集与三维建模,提升漏损控制、节能降耗与应急响应能力,推动水务管理从经验驱动迈向数据驱动,助力城市水资源精细化、可持续化管理。
257 142
|
1天前
|
存储 人工智能 Java
AI 超级智能体全栈项目阶段四:学术分析 AI 项目 RAG 落地指南:基于 Spring AI 的本地与阿里云知识库实践
本文介绍RAG(检索增强生成)技术,结合Spring AI与本地及云知识库实现学术分析AI应用,利用阿里云Qwen-Plus模型提升回答准确性与可信度。
174 90
AI 超级智能体全栈项目阶段四:学术分析 AI 项目 RAG 落地指南:基于 Spring AI 的本地与阿里云知识库实践
|
17天前
|
存储 关系型数据库 分布式数据库
PostgreSQL 18 发布,快来 PolarDB 尝鲜!
PostgreSQL 18 发布,PolarDB for PostgreSQL 全面兼容。新版本支持异步I/O、UUIDv7、虚拟生成列、逻辑复制增强及OAuth认证,显著提升性能与安全。PolarDB-PG 18 支持存算分离架构,融合海量弹性存储与极致计算性能,搭配丰富插件生态,为企业提供高效、稳定、灵活的云数据库解决方案,助力企业数字化转型如虎添翼!
|
1天前
|
机器学习/深度学习 人工智能 运维
智能照明稳压节能控制器,路灯节能稳压系统,沃思智能
智能照明调控柜集电力分配、远程控制与能耗管理于一体,支持自动调光、场景切换与云平台运维,广泛应用于市政、商业及工业领域,显著节能降耗,助力智慧城市建设。
178 137