第三章
视觉感知元素理论
Visual Perception Element Theory
3.1 视觉感知元素概念
视觉是人类最主要的感觉方式之一。
人通过眼睛获取:
- 物体外观;
- 空间位置;
- 环境布局;
- 行为变化;
- 状态信息。
经过大脑处理后形成:
对现实对象的认识。
WSaiOS 将人类视觉过程抽象为:
视觉感知元素(Visual Perception Element)
定义:
视觉感知元素是 WSaiOS 通过图像、视频等视觉信息源,对外部对象进行采集、解析、结构化后形成的具有视觉属性、空间属性、状态属性和关系描述能力的信息对象。
视觉感知过程:
视觉信息
↓
图像/视频数据
↓
视觉特征解析
↓
视觉感知元素
↓
认知元素
↓
理解与推理
3.2 人类视觉认知逻辑
人类看到一个场景:
例如:
办公室。
视觉输入:
光线
↓
图像
↓
物体轮廓
↓
对象识别
↓
空间关系
↓
场景理解
人的认知过程:
看到:
桌子
电脑
人员
进一步理解:
这是办公室环境
人员正在工作
电脑处于使用状态
WSaiOS 对应:
视觉数据
↓
视觉元素
↓
对象元素
↓
场景元素
↓
认知元素
3.3 图片感知元素理论
Image Perception Element
图片是视觉感知中的静态信息。
它主要表达:
空间中对象的结构状态。
例如:
一张办公室图片:
包含:
人物
桌子
电脑
椅子
墙壁
图片不是简单像素。
WSaiOS 将其转换为:
图片感知元素集合:
Image={e1,e2,e3,…,en}Image=\{e_1,e_2,e_3,…,e_n\}
例如:
{
"type":"Office Image",
"elements":[
{
"type":"Person"
},
{
"type":"Computer"
},
{
"type":"Desk"
}
]
}
3.4 图片元素结构模型
图片感知元素:
采用对象模型。
结构:
Image Element
{
ID
Type
Object
Attribute
Position
Size
Color
Shape
Relation
Confidence
}
1. Object(对象)
描述:
图片中的实体。
例如:
Person
Car
Tree
Building
2. Attribute(属性)
描述:
对象特征。
例如:
人物:
Height
Clothing
Color
Shape
汽车:
Brand
Model
Color
3. Position(位置)
描述:
空间位置。
例如:
x=100
y=200
4. Relation(关系)
描述:
对象之间关系。
例如:
Person
Near
Computer
3.5 图片场景元素模型
单个对象不能代表完整环境。
人类理解:
依赖场景。
例如:
看到:
桌子
电脑
椅子
人
不是简单对象集合。
而形成:
办公场景
场景模型:
Scene Element
{
Objects
Relations
Layout
Environment
State
}
例如:
智能办公室:
Scene:
Office
Objects:
Person
Computer
Desk
Relation:
Person Using Computer
3.6 视频感知元素理论
Video Perception Element
视频是图片在时间维度上的扩展。
图片:
回答:
有什么?
视频:
回答:
发生了什么?
视频提供:
- 行为;
- 过程;
- 变化。
模型:
Video
=
Frame Sequence
+
Time Relation
例如:
监控视频:
连续帧:
Frame1
Person Outside
Frame2
Person Enter
Frame3
Person Sit
形成:
事件:
Person Enter Room
3.7 视频元素结构模型
Video Element
{
Object
Motion
Action
Event
Time
Change
State
}
Object
视频中的对象。
例如:
Person
Vehicle
Machine
Motion
运动信息。
例如:
Direction
Speed
Path
Event
事件信息。
例如:
Open Door
Start Machine
Fall Object
State Change
状态变化。
例如:
Machine
Normal
↓
Warning
3.8 视觉元素函数模型
参考面向对象思想:
视觉元素不是静态记录。
而具有处理能力。
模型:
Visual Element
{
Attribute
State
Function
}
例如:
摄像头元素:
{
"type":"Camera",
"function":{
"capture",
"detect",
"track",
"update"
}
}
Function 表示:
视觉元素可以执行的行为。
3.9 视觉元素关系模型
视觉理解不是单个对象识别。
而是:
对象之间关系。
例如:
图片:
Person
Chair
Desk
关系:
Person
↓
Sitting_On
↓
Chair
Person
↓
Working_On
↓
Desk
形成:
视觉知识结构。
3.10 动态视觉状态模型
视频中:
对象状态不断变化。
状态:
StS_t
经过时间:
tt
产生:
St+1S_{t+1}
例如:
设备:
Running
↓
Overheat
↓
Failure
视觉系统需要识别:
变化趋势。
3.11 视觉感知元素到认知元素转换
视觉元素:
解决:
“看到了什么”。
认知元素:
解决:
“理解它是什么”。
转换:
Visual Element
↓
Attribute Mapping
↓
Semantic Mapping
↓
Cognitive Element
例如:
视觉:
一个穿制服的人
↓
认知:
员工
视觉:
一台机器停止
↓
认知:
设备故障风险
3.12 WSaiOS视觉感知系统定位
视觉系统在 WSaiOS 中:
不是最终智能。
而是:
人工感觉器官。
完整链路:
视觉输入
↓
视觉感知元素
↓
认知元素
↓
知识组织
↓
理解
↓
推理
↓
决策
3.13 本章总结
本章建立 WSaiOS 视觉感知元素理论。
核心观点:
- 图片是静态视觉元素;
- 视频是动态视觉元素;
- 图片描述空间结构;
- 视频描述时间变化;
- 视觉元素由对象、属性、状态、关系组成;
- 视觉元素通过映射形成认知元素。
最终模型:
Image
↓
Image Element
↓
Scene Element
↓
Cognitive Element
Video
↓
Video Element
↓
Event Element
↓
Cognitive Element
下一章:
第四章
图片感知元素
Image Perception Element Model
重点:
- 图片作为静态认知输入;
- 图片元素组成;
- 对象分解;
- 属性提取;
- 空间关系;
- 图片场景生成与理解。
3.14 视觉感知元素面向对象模型
视觉感知不是一个图片文件。
而是一组对象。
传统方式:
$image = "office.jpg";
analyze($image);
问题:
- 图片与分析逻辑分离;
- 无法扩展;
- 无法形成认知对象。
WSaiOS采用:
Visual Object Model
结构:
VisualElement
{
data
attribute
state
relation
function
}
转换为:
AbstractElement
|
|
VisualElement
|
---------------------
ImageElement
VideoElement
SceneElement
ObjectElement
EventElement
3.15 VisualElement基础类设计
目录:
core
└── element
└── VisualElement.php
代码:
<?php
abstract class VisualElement
{
protected $id;
protected $source;
protected $objects=[];
protected $attributes=[];
protected $relations=[];
protected $confidence;
public function getObjects()
{
return $this->objects;
}
public function getRelations()
{
return $this->relations;
}
public function addObject($object)
{
$this->objects[]=$object;
}
public function addRelation($relation)
{
$this->relations[]=$relation;
}
abstract public function analyze();
}
作用:
定义所有视觉对象共同能力。
3.16 ImageElement图片对象设计
ImageElement Class
目录:
app
/models
/ImageElement.php
对象结构:
ImageElement
|
├ Image Source
├ Objects
├ Position
├ Color
├ Shape
├ Relation
└ Confidence
PHP:
<?php
class ImageElement extends VisualElement
{
protected $width;
protected $height;
protected $format;
public function analyze()
{
return [
"type"=>"image",
"objects"=>$this->objects,
"relations"=>$this->relations
];
}
public function setSize($w,$h)
{
$this->width=$w;
$this->height=$h;
}
}
对应理论:
Image Data
↓
ImageElement
↓
Object Extraction
↓
Scene Understanding
3.17 Visual Object对象模型
图片里面的对象:
不是字符串。
例如:
Person
Car
Computer
应该成为对象。
设计:
VisualObject
{
id
type
attribute
position
state
}
PHP:
class VisualObject
{
protected $id;
protected $type;
protected $attributes=[];
protected $position;
public function setType($type)
{
$this->type=$type;
}
public function addAttribute($key,$value)
{
$this->attributes[$key]=$value;
}
}
例如:
图片:
办公室
生成:
VisualObject
1 Person
2 Computer
3 Desk
3.18 属性模型 Attribute Model
视觉对象:
需要描述特征。
例如:
人:
Height
Clothing
Color
Position
设计:
Attribute
{
name
value
confidence
}
PHP:
class VisualAttribute
{
private $name;
private $value;
private $confidence;
public function __construct(
$name,
$value
)
{
$this->name=$name;
$this->value=$value;
}
}
形成:
Object
↓
Attribute Collection
↓
Semantic Object
3.19 空间关系模型
视觉理解核心:
不是只有对象。
而是:
对象关系。
例如:
Person
↓
Using
↓
Computer
设计:
VisualRelation
{
source
relation
target
}
PHP:
class VisualRelation
{
protected $source;
protected $relation;
protected $target;
public function __construct(
$s,
$r,
$t
)
{
$this->source=$s;
$this->relation=$r;
$this->target=$t;
}
}
例如:
生成:
Person
Working_On
Computer
3.20 SceneElement场景元素
单个对象:
不能代表环境。
因此增加:
Scene Element
结构:
SceneElement
{
objects
relations
environment
state
}
PHP:
class SceneElement
extends VisualElement
{
protected $sceneType;
public function analyze()
{
return [
"scene"=>$this->sceneType,
"objects"=>$this->objects
];
}
}
例如:
输入:
办公室图片。
生成:
SceneElement
type:
Office
objects:
Person
Desk
Computer
relations:
Person Using Computer
3.21 VideoElement工程模型
视频:
= 图片序列 + 时间。
模型:
VideoElement
|
├ Frames
├ Motion
├ Event
├ Time
└ StateChange
PHP:
class VideoElement
extends VisualElement
{
protected $frames=[];
protected $events=[];
protected $timeline;
public function addFrame($frame)
{
$this->frames[]=$frame;
}
public function detectEvent()
{
}
public function analyze()
{
return [
"frames"=>count($this->frames),
"events"=>$this->events
];
}
}
3.22 Event事件元素
视频最终目标:
不是识别图片。
而是理解事件。
例如:
监控:
Person
↓
Walk
↓
Enter Room
形成:
EventElement
{
object
action
time
state
}
PHP:
class EventElement
{
protected $object;
protected $action;
protected $time;
public function create()
{
return [
$this->object,
$this->action
];
}
}
3.23 MVC视觉分析模块设计
WSaiOS视觉模块:
目录:
WSaiOS
app
├ Controllers
│
│ VisualController.php
├ Models
│
│ ImageElement.php
│
│ VideoElement.php
├ Services
│
│ VisualAnalysisService.php
├ Repository
│
│ VisualRepository.php
└ Views
Smarty
3.24 VisualController
控制视觉流程:
class VisualController
{
public function analyze()
{
$image=$_FILES['image'];
$element=
new ImageElement();
$result=
$element->analyze();
return $result;
}
}
流程:
Image Upload
↓
Controller
↓
ImageElement
↓
Analysis Service
↓
Database
↓
Smarty
3.25 Smarty视觉结果展示
模板:
views/templates
visual.tpl
Smarty:
<h2>
视觉分析结果
</h2>
对象:
{$objects}
场景:
{$scene}
状态:
{$state}
显示:
视觉对象:
Person
Computer
场景:
Office
3.26 视觉数据库设计
表:
visual_elements
结构:
| 字段 | 说明 |
|---|---|
| id | 编号 |
| type | 类型 |
| source | 来源 |
| objects | 对象 |
| attributes | 属性 |
| relations | 关系 |
| confidence | 可信度 |
| created_at | 时间 |
SQL:
CREATE TABLE visual_elements
(
id INT AUTO_INCREMENT PRIMARY KEY,
type VARCHAR(50),
source VARCHAR(255),
objects TEXT,
attributes TEXT,
relations TEXT,
confidence FLOAT,
created_at TIMESTAMP
);
3.27 视觉记忆模型
视觉信息进入:
Memory Engine。
流程:
ImageElement
↓
VisualMemory
↓
ExperienceMemory
↓
CognitiveMemory
例如:
系统记忆:
以前看到类似设备
↓
判断当前设备状态
3.28 WSaiOS视觉系统完整架构
最终:
Camera/Image
↓
ImageElement
↓
VisualObject
↓
SceneElement
↓
CognitiveElement
↓
Reasoning Engine
↓
Decision
3.29 本章工程总结
第三章完成:
理论映射
人眼
↓
视觉信息
↓
视觉元素
↓
认知对象
软件映射
Image
↓
ImageElement Class
↓
VisualObject Class
↓
SceneElement Class
↓
CognitiveElement
工程架构
PHP OOP
+
MVC
+
Smarty
+
Repository
+
Memory Engine
因此:
WSaiOS视觉感知系统不是图像处理程序,而是面向对象的视觉认知对象系统。
下一章:
第四章
图片感知元素模型
Image Perception Element Model
重点进入更细工程设计:
- ImageElement详细Class设计
- 图片对象识别模型
- Attribute属性系统
- Position空间坐标系统
- Relation关系图模型
- Scene场景生成算法
- 图片感知数据库设计
- PHP MVC完整实现案例
这一步会进一步连接:
人类视觉皮层 → WSaiOS Visual Engine → PHP OOP工程模块。