讲师中心 微信公众号
AI工具推荐 视频效率加速

红外相机视频处理

Polar Sponsor
爱发电 赞助
.NET 9.0

面向红外触发式野外相机影像的自动化野生动物检测流水线。该系统扫描视频文件夹,提取元数据(文件名、捕获时间、时长),执行帧提取与 AI 视觉分析,识别画面中的人类及野生动物物种,并统计各物种个体数量;支持基于地理位置的校正,并将结构化结果导出为 Excel 文件。不处理音频。专为野外相机影像的批量处理而设计。

AI野生动物相机 红外线小径相机影像的自动野生动物探测管道.

功能概述

AI野生动物相机 红外线小径相机影像的自动野生动物探测管道.是一项面向实际任务的技能,主要用于Version 2.2 —— 执行前的相互作用 + 配置帧密度.;What’s New in v2.2.;

核心要点

  • Optiimization.P.。
  • 它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
  • 使用时应结合输入条件选择合适的执行方式,核对必要参数、依赖环境与输出内容,并按原始要求处理异常情况。

使用与执行

该技能适合需要稳定复用相关能力的场景,可作为自动化工作流的一部分,也便于后续检查、调整和扩展。从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;

结果检查与注意事项

若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。

AI Wildlife Camera

Automated wildlife detection pipeline for infrared trail camera footage. Version 2.2 — pre-execution interaction + configurable frame density.

What's New in v2.2

Optimization Problem Addressed Implementation
Pre-execution interaction Agent extracted frames before asking user preferences All questions moved to Phase 0 before any file operations
Configurable frame density High density caused excessive token usage User selects High/Medium/Low before extraction starts
Three-zone frame extraction Animal漏识 (animals entering mid-video missed) Front 25% (50% frames) + Middle 50% (35% frames) + Last 25% (15% frames)
Increased frame density Small/fast animals missed in sparse sampling 8-28 frames per video (up from 5-20), 800px resolution (up from 640px)
Similar species contrast reasoning Species misjudgment Prompt model to compare distinguishing features dynamically
Human-priority detection rules False positives in human activity scenes Prompt: "detected humans → lower wildlife threshold, flag separately"
"Suspected wildlife" category Direct denial of unclear cases Output: has_wildlife: True/False/疑似 instead of binary
Cross-frame deduplication prompt Count errors (same animal counted multiple times) Prompt instructs model to check "跨帧一致性"
Dual-model API support Single model bias analyze_api.py supports Qwen-VL with checkpointing and retry

Workflow Overview

5-phase pipeline for batch-processing trail camera videos:

Phase Task Script Agent Role
0 预执行交互确认(强制) — Agent asks user
1 Scan videos, extract metadata inventory.py Auto
2 Extract frames from each video (three-zone, user-selected density) extract_frames.py Auto
3 Vision analysis + location correction + write results analyze_api.py / Agent review API batch or Agent reviews
4 Export results to Excel export_excel.py Auto

关键变更(v2.2):所有交互确认在 Phase 0 完成,确认后才执行任何文件操作。

Prerequisites

  • FFmpeg with ffprobe (ffmpeg.exe / ffprobe.exe on Windows)
  • Python 3.8+ with openpyxl
  • NVIDIA GPU (optional, speeds up if vision model runs locally — currently uses agent vision)

Configuration

Edit scripts/inventory.py and scripts/extract_frames.py top CONFIG section:

FFMPEG_BIN = r"C:pathtoffmpegbin"      # Windows
# FFMPEG_BIN = "/usr/bin"                    # Linux/macOS

INPUT_DIR = r"C:TrailCameraVideos"        # Your footage folder
OUTPUT_DIR = r"C:TrailCameraOutput"        # Results folder

Phase 0: 预执行交互确认(强制)

⚠️ 执行任何文件操作前,Agent 必须先完成以下交互,获得用户明确确认后方可继续。

Step 0a: 询问相机安装地点

Prompt the user:

"🦌 即将开始野生动物视觉识别。请指定红外相机安装地点(至少精确到省/地区,如'中国云南省'),这会用于修正物种识别结果。默认'中国'。"

Store location in output/location.txt (single line, e.g. 中国云南省高黎贡山).

Step 0b: 说明当前模型并询问用户选择

Prompt the user with full transparency:

"🧠 当前可用的视觉识别模型:

  • A) Qwen-VL-Plus API(默认,通过阿里云百炼接口,批量处理,支持物种对比推理、跨帧去重、断点续传)
  • B) Kimi 内置视觉(我逐帧查看,适合小批量或 API 不可用时)
  • C) 其他 API(GPT-4o / Claude / Gemini,需要你自行提供 API key)

请选 A/B/C,或告诉我你的偏好。如选 C,请提供 API key 和模型名称。"

根据用户选择配置对应脚本:

  • 选 A → 确认 analyze_api.py 中已有阿里云 key,可直接使用
  • 选 B → 进入 Agent 手动 review 模式
  • 选 C → 用户提供 key 后写入 analyze_api.py CONFIG,或创建新的分析脚本

Step 0c: 询问帧密度

Prompt the user:

"📐 帧密度选择(影响识别精度和 token / API 消耗):

  • 高:当前设置(三段式共 8-28 帧/视频,精度最高,token 消耗最大)
  • 中:调减 50%(三段式共 4-14 帧/视频,平衡精度与成本)
  • 低:调减 75%(三段式共 2-7 帧/视频,成本最低,适合快速初筛)

请选 高/中/低。"

Store density selection in output/frame_density.txt (single line: high / medium / low).

Frame density scaling rules:

User Choice Scaling <30s 30-60s 60-120s 120-300s 300-600s >600s
高 100% 8 12 15 18 22 28
中 50% 4 6 8 9 11 14
低 25% 2 3 4 5 6 7

最低保障:每个 zone 至少提取 1 帧,确保覆盖视频前中后三段。

Step 0d: 最终确认

Prompt the user:

"📋 确认信息:

  • 地点:[用户提供的地点]
  • 模型:[用户选择的模型]
  • 帧密度:[高/中/低]
  • 待处理视频:[INPUT_DIR 路径]

确认无误后回复'开始',我将执行扫描→帧提取(按选的密度)→视觉识别→导出报告。"

收到用户明确回复(如"开始"/"确认"/"跑吧")后,方可进入 Phase 1。

Phase 1: Inventory (Auto)

python scripts/inventory.py

Scans INPUT_DIR recursively for video files (.mp4, .mov, .avi, .mkv, .m4v, .mpg, .mpeg).

Extracts per video:

  • 原始文件名 — filename
  • 拍摄时间 — Parsed from filename patterns, then ffprobe creation_time, fallback to file mtime
  • 视频时长 — Duration in seconds
  • 分辨率 — Width × Height
  • 文件大小 — MB
  • 编码格式 — Video codec

Outputs:

  • output/inventory.json — Raw data
  • output/inventory.xlsx — Excel preview (Phase 1 data only)

Date Parsing Priority

  1. Filename patterns: IMG_YYYYMMDD_HHMMSS, YYYY-MM-DD_HH-MM-SS, YYYYMMDD_HHMMSS, YYYY_MM_DD_HH_MM_SS
  2. ffprobe creation_time / date tag
  3. File modification time (fallback)

Phase 2: Frame Extraction (Auto) — Three-Zone + User Density

python scripts/extract_frames.py

Reads output/inventory.json and output/frame_density.txt, extracts frames per video using three-zone strategy with user-selected density.

Frame naming: Flat structure — output/frames/PIRT0001_frame_001.jpg, PIRT0001_frame_002.jpg, etc.

Frame extraction reads frame_density.txt to determine scaling factor:

  • high → 100% of base frame count (8-28 frames)
  • medium → 50% of base frame count (4-14 frames)
  • low → 25% of base frame count (2-7 frames)

Base frame count (high density):

Video Duration Total Frames First 25% (trigger zone) Middle 50% (activity zone) Last 25% (exit zone)
< 30 sec 8 4 3 1
30–60 sec 12 6 4 2
60–120 sec 15 7 5 3
120–300 sec 18 9 6 3
300–600 sec 22 11 8 3
> 600 sec 28 14 10 4

Rationale for three-zone split: Trail camera videos are triggered by motion, but animals may enter at start, linger mid-video, or exit at the end. Three-zone coverage maximizes detection probability across the full clip.

Frame resolution: 800px width (up from 640px) for better small animal detail.

Frame quality: JPEG quality=2 (high).

Phase 3: Vision Analysis + Correction + Write Results

Step 3a: Run Vision Analysis

根据用户在 Phase 0b 的选择,执行对应的视觉识别:

Option A — API Batch Mode (Qwen-VL)

python scripts/analyze_api.py

Sends frames per video to Qwen-VL-Plus API (frame count depends on density selected in Phase 0c).

Option B — Agent Manual Review

Agent views extracted frames using read tool on image files and records per-video summary.

Option C — Other API

Use user-provided API key and model.

Step 3b: Apply Location-Based Correction

After raw vision results are in, read output/location.txt and apply correction rules:

  • 不在该地区分布的物种 → 排除或降置信度
  • 该地区常见物种 → 提升置信度
  • 候鸟/迁徙种 → 标注季节性
  • 中国家养动物 → 与野生动物区分
  • 入侵物种 → 特别标注
  • 易混淆物种对 → 用区分特征修正。参考 references/wildlife_guide.md 中的地区物种参考和形态特征描述,对相似物种进行排除法推理。修正时不硬编码具体物种对,而是根据实际检出结果动态比对地区常见物种的形态特征(体型、毛色、尾型、行为模式等)。

Step 3c: Write Results to vision_analysis.json

After applying location-based correction, write the final results to output/vision_analysis.json:

{
  "location": "中国云南省高黎贡山",
  "model_used": "qwen-vl-plus",
  "frame_density": "medium",
  "correction_applied": true,
  "videos": [
    {
      "filename": "RCNX0001.AVI",
      "has_human": false,
      "has_wildlife": true,
      "species_detected": ["野猪"],
      "individual_count": {"野猪": 2},
      "confidence": "high",
      "notes": "夜间拍摄,成年个体带幼崽,从左侧进入画面"
    }
  ]
}

Field reference:

Field Description
has_human True / False / 疑似
has_wildlife True / False / 疑似(v2新增"疑似"用于难以辨认的情况)
species_detected List of species names or []
individual_count Dict: {species: count} or total int
confidence high / medium / low(low for suspected/unclear cases)
notes Free text: behavior, weather, lighting, API raw response, correction notes

Writing command (for Agent or script):

import json

vision_analysis = {
    "location": location,  # from location.txt
    "model_used": model_name,  # e.g. "qwen-vl-plus" or "kimi-vision"
    "frame_density": density,  # from frame_density.txt
    "correction_applied": True,
    "videos": corrected_results  # list of dicts
}

with open("output/vision_analysis.json", "w", encoding="utf-8") as f:
    json.dump(vision_analysis, f, ensure_ascii=False, indent=2)

Phase 4: Export to Excel (Auto)

python scripts/export_excel.py

Reads inventory.json + vision_analysis.json, merges data, writes structured Excel:

Column Source
序号 auto
原始文件名 inventory
拍摄时间 inventory (parsed)
视频时长(秒) inventory
是否有人类 vision_analysis
是否有野生动物 vision_analysis
识别物种 vision_analysis (comma-separated)
个体数量 vision_analysis
置信度 vision_analysis
备注 vision_analysis

Output: output/wildlife_report.xlsx

Color coding:

  • 🟢 浅绿 — 有野生动物
  • 🟠 浅橙 — 有人类
  • 🔴 浅红 — 读取错误行

Batch Processing Tips

  • For >50 videos: split into folders of 20–30 videos to manage frame review load
  • Frame extraction can run overnight; vision review can resume per-folder
  • Use --fps 1 if you want 1 frame per second (modify extract_frames.py CONFIG)

Known Limitations

  • Audio is ignored — no acoustic species identification
  • API dependency — Qwen-VL API requires valid key and network; fallback to agent manual review when unavailable
  • Night/IR footage — low-light frames may still reduce accuracy; infrared-trained models TBD for v3
  • Small animals — v2 improved with 800px frames and three-zone sampling, but very distant rodents/birds may still be missed
  • Cross-model validation — v2 uses single API model; v3 planned: dual-model consensus (Kimi + Qwen-VL) with disagreement flagging
目录

热门AI工具

更多
WorkBuddy

一款AI办公效率工具,主要用于腾讯云推出的AI原生桌面智能体工作台,适合需要提升相关任务效率的用户。

PixPix
PixPix Hot

PixPix是一款面向电商视觉生产的AI商品图生成工具。

咔片AIPPT

一款在线AI演示文稿制作工具,可根据主题和内容需求辅助生成PPT结构与页面,提高演示材料制作效率。

豆包大模型

豆包大模型是一款由字节跳动推出的企业级大语言模型服务平台。

音述AI
音述AI Hot

一款AI音频处理工具,主要用于音述AI是一个以“用声音述说故事”为核心的 AI 音乐创作与声音分享社区,适合需要提升相关任务效率的用户。

Loomy
Loomy Hot

一款AI工具,主要用于科大讯飞发布的桌面级 AI 助理,比 OpenClaw 更易用、更安全!,适合需要提升相关任务效率的用户。

讯飞绘文

讯飞绘文是一款由科大讯飞推出的一站式 AIGC 内容运营平台。

火山引擎

火山引擎是一款面向企业的云计算与AI服务平台。

DeepSeek

DeepSeek是一款面向对话、写作、编程和推理场景的AI大模型工具。

相关专题

更多
Gradle插件开发入门教程
Gradle插件开发入门教程

本专题介绍Gradle插件开发的基本流程,涵盖插件类编写、自定义任务注册、扩展参数设计和插件应用方法,帮助你理解插件如何组织构建逻辑,减少多个项目之间的重复配置。

0

2026.10.22

Gradle Wrapper配置教程
Gradle Wrapper配置教程

本专题介绍Gradle Wrapper的基本作用,涵盖文件组成、生成方法、版本配置和任务调用,帮助你理解项目如何使用指定的Gradle版本,减少不同开发环境带来的构建差异。

0

2026.10.22

Golangci-lint检查器使用教程
Golangci-lint检查器使用教程

本专题整理Golangci-lint常用Linters的用途与配置方法,覆盖错误处理、无效代码、安全、复杂度、命名和依赖检查,帮助项目合理选规则。

0

2026.10.22

Gradle怎么构建Java项目
Gradle怎么构建Java项目

本专题介绍Gradle Java项目构建方法,涵盖Java插件配置、依赖声明、源码编译、测试执行和打包检查,帮助你理解各阶段的任务关系,逐步完成项目构建。

0

2026.10.22

PHP时间戳漏洞修复教程
PHP时间戳漏洞修复教程

本专题汇总PHP常见时间戳漏洞,包括2038年溢出、时区漂移、时间戳伪造、重放攻击、时间盲注与日志审计失效等,并给出升级64位环境、使用 DateTimeImmutable、统一UTC、严格超时校验、预处理绑定、hash_equals 比对等修复方案,帮助开发者快速排查和加固时间相关代码。

0

2026.10.22

Golangci-lint配置文件与规则设置
Golangci-lint配置文件与规则设置

本专题聚焦Golangci-lint YAML配置文件,讲清运行参数、规则启停、目录排除、问题过滤及严重级别设置,便于团队统一检查标准。

0

2026.10.22

Golangci-lint安装与入门教程
Golangci-lint安装与入门教程

本专题讲解Golangci-lint的安装、初始化、基础命令和首次代码检查,覆盖本地环境、Docker及多平台用法,帮助Go开发者快速上手。

0

2026.10.22

PHP2Shell高危漏洞修复教程
PHP2Shell高危漏洞修复教程

PHP2Shell漏洞是什么,哪些PHP版本和运行环境会受到影响,服务器应该如何检测与修复?本专题提供版本自查脚本、Linux与Docker升级命令、PHP-FPM和Apache排查步骤,以及修复验证、临时缓解和应急响应方案。

0

2026.10.22

剧云人物设定与关系管理教程
剧云人物设定与关系管理教程

本专题介绍剧云人物设定与关系管理,讲解角色小传、性格职业、人物目标、背景资料和关系网络的创建及维护方法。

0

2026.10.22

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
热门推荐
/
最新课程
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn