首页 理论 架构 工程 文档 白皮书 著作 研究 案例 下载 博客 关于 开始使用 →

第四章 图片感知元素模型 Image Perception Element Model

第四章

图片感知元素模型

Image Perception Element Model


4.1 图片在 WSaiOS 感知体系中的定义

图片是人类视觉系统获取外部环境信息的重要方式。

人通过一张图片,可以感知:

  • 物体;
  • 颜色;
  • 形状;
  • 空间位置;
  • 环境结构;
  • 对象关系。

但是,图片本身只是视觉数据。

它并不是认知对象。


WSaiOS 将图片定义为:

图片是一种静态视觉信息载体,通过视觉感知处理后,可以转换为具有对象、属性、状态和关系描述能力的图片感知元素集合。


转换过程:

图片数据 Image Data

↓

图片解析 Image Processing

↓

图片感知元素 Image Perception Elements

↓

认知元素 Cognitive Elements

↓

理解 Understanding

4.2 图片作为静态认知输入

Image as Static Cognitive Input

图片最大的特点:

静态结构表达

它描述:

某一个时间点上的空间状态。


例如:

一张工厂图片:

原始输入:

Image

1920×1080 Pixels

经过视觉解析:

得到:

设备

人员

生产线

区域

进一步形成:

Factory Scene Element

因此:

图片主要提供:

空间信息

包括:

  • 对象存在;
  • 对象位置;
  • 对象形态;
  • 对象关系。

图片不直接表达:

连续变化。

变化需要:

视频元素。


4.3 图片感知元素组成

Structure of Image Perception Element

WSaiOS 将图片转换为元素对象。

基本结构:

Image Element

{

ID

Type

Object

Attribute

State

Position

Relation

Confidence

Function

}

4.3.1 ID(元素标识)

用于唯一识别图片中的元素。

例如:

person_001

machine_001

table_001

作用:

保证元素可追踪。


4.3.2 Type(元素类型)

表示:

元素属于什么类别。

例如:

Person

Vehicle

Device

Animal

Building

Environment

类型决定:

后续认知方式。


例如:

Person:

关注:

  • 身份;
  • 行为;
  • 状态。

Machine:

关注:

  • 工作状态;
  • 故障状态。

4.3.3 Object(对象)

对象是图片元素核心。

表示:

图片中的实体。


例如:

图片:

办公室

对象:

Person

Desk

Computer

Chair

WSaiOS 认为:

视觉系统不是处理像素。

而是发现对象。


4.3.4 Attribute(属性)

属性描述对象特征。


例如:

人物:

Height

Clothing

Color

Shape

汽车:

Brand

Color

Model

设备:

Size

Structure

Material

属性模型:

Object

↓

Attribute Set

数学表示:

A(e)={a1,a2,a3,…,an}A(e)=\{a_1,a_2,a_3,…,a_n\}

其中:

A(e)

表示元素属性集合。


4.3.5 State(状态)

状态描述对象当前情况。


例如:

设备:

Normal

Running

Stopped

Broken

人员:

Standing

Sitting

Walking

状态:

不是固定属性。

而是动态变化。


4.3.6 Position(空间位置)

图片天然包含空间信息。


位置模型:

Position

{

X

Y

Width

Height

Depth

}

例如:

{
"x":100,

"y":200,

"width":80,

"height":180
}

表示:

对象在图片中的位置。


4.3.7 Relation(对象关系)

人理解图片:

不是只看单个对象。

而是理解关系。


例如:

图片:

Person

Computer

Desk

关系:

Person

↓

Using

↓

Computer


Computer

↓

Located_On

↓

Desk

关系模型:

R(e1,e2)R(e_1,e_2)

表示:

元素之间关系。


4.4 图片对象分解模型

Image Object Decomposition Model

复杂图片:

由多个视觉元素组成。


例如:

一张办公室图片:

整体:

Office Image

分解:

Office Scene

├ Person

├ Desk

├ Computer

├ Chair

└ Lighting

对象分解过程:

Image

↓

Region Analysis

↓

Object Detection

↓

Object Elements

4.5 图片属性提取模型

Image Attribute Extraction Model

对象确定以后:

需要提取属性。


过程:

Object

↓

Feature Extraction

↓

Attribute Generation

例如:

检测汽车:

得到:

Object:

Car


Attribute:

Color=Black

Shape=Sedan

State=Stopped

形成:

汽车图片感知元素。


4.6 图片空间关系模型

Spatial Relation Model

空间关系是视觉认知的重要组成。


人看到:

办公室。

不是:

10个物体。

而是:

一个空间场景。


空间关系包括:


1. 位置关系

例如:

Person

Left_of

Computer

2. 距离关系

例如:

Person

Near

Desk

3. 包含关系

例如:

Computer

Inside

Office

4. 拓扑关系

例如:

Room

Connected_With

Hallway

空间关系模型:

Element A

↓

Relation

↓

Element B

4.7 图片场景生成模型

Image Scene Generation Model

单个元素:

不能表达完整环境。

需要组织。


例如:

元素:

Person

Computer

Desk

组织:

Person Using Computer

Computer On Desk

生成:

Office Working Scene

过程:

Image Elements

↓

Element Organization

↓

Relation Construction

↓

Scene Element

4.8 图片场景理解模型

Image Scene Understanding

场景理解是:

从对象到意义的过程。


例如:

图片:

看到:

Person

Laptop

Desk

简单识别:

有人

有电脑

有桌子

场景理解:

这是办公环境

人员正在工作

WSaiOS:

场景理解:

不是依靠概率标签。

而是:

元素+关系+规则。


模型:

Scene=Element+Relation+RuleScene= Element+ Relation+ Rule


4.9 图片元素生成系统模型

WSaiOS 视觉生成系统:

不仅可以理解图片。

也可以根据元素生成图片场景。


核心思想:

图片由元素组合产生。


例如:

创建办公室图片:

元素:

Person

Desk

Computer

Chair

赋值:

Person:

Position=A


Desk:

Position=B


Computer:

On Desk

组合:

生成:

Office Image Scene

模型:

Element Library

↓

Element Parameters

↓

Scene Composition

↓

Image Generation

4.10 图片元素对象化模型

参考面向对象思想:

图片元素:

不是图片碎片。

而是对象。


例如:

class ImageElement
{

    public $type;

    public $attribute;

    public $position;

    public $state;


    public function compose()
    {

    }

}

工程表达:

{
"type":"Tree",

"attribute":{

"color":"green",

"height":"2m"

},

"position":{

"x":100,

"y":300

}

}

这种结构:

可以支持:

  • 图片理解;
  • 图片生成;
  • 场景编辑;
  • 场景模拟。

4.11 本章总结

图片感知元素模型建立:

图片 → 元素 → 场景 → 理解

体系。


核心观点:

  1. 图片是静态视觉输入;
  2. 图片由多个视觉元素组成;
  3. 元素具有属性、状态、位置、关系;
  4. 对象关系形成场景;
  5. 场景组织形成理解;
  6. 元素参数化可以支持图片生成。

最终模型:

Image Data

↓

Image Element

↓

Object Element

↓

Attribute

↓

Spatial Relation

↓

Scene Element

↓

Cognitive Element

下一章:

第五章

视频感知元素模型

Video Perception Element Model

重点:

  • 视频作为动态认知输入;
  • 视频元素组成;
  • 时间连续模型;
  • 行为元素;
  • 事件元素;
  • 状态变化模型;
  • 视频场景理解。

图片感知元素模型工程实现

Image Perception Element Model and PHP OOP MVC Implementation


第四章建立了:

图片 → 元素 → 场景 → 理解

的理论模型。

但是 WSaiOS 的核心目标是:

将图片感知过程转换为面向对象的软件工程模型。

因此:

图片不是文件。

而是:

ImageElement对象集合。


4.12 图片感知元素 OOP 总体模型

理论:

Image Data

↓

Image Element

↓

Object Element

↓

Attribute

↓

Relation

↓

Scene Element

↓

Cognitive Element

转换为软件对象:

ImageFile

↓

ImageElement

↓

VisualObject

↓

AttributeObject

↓

RelationObject

↓

SceneElement

↓

CognitiveObject

整体 Class:

VisualElement


      |

      |

ImageElement


      |

      |

------------------

VisualObject

Attribute

Position

Relation

Scene

------------------

4.13 ImageElement 类设计

图片感知核心对象

目录:

wsaios

/core

 /visual

    ImageElement.php

代码:

<?php


class ImageElement
{


protected $id;


protected $source;


protected $objects=[];


protected $attributes=[];


protected $relations=[];


protected $confidence;



public function __construct($source)
{

    $this->source=$source;

}



public function addObject($object)
{

    $this->objects[]=$object;

}



public function addRelation($relation)
{

    $this->relations[]=$relation;

}



public function analyze()
{

    return [

        "source"=>$this->source,

        "objects"=>$this->objects,

        "relations"=>$this->relations

    ];

}


}

作用:

保存:

  • 图片来源;
  • 对象集合;
  • 属性集合;
  • 关系集合。

4.14 VisualObject对象模型

图片中的对象:

例如:

Person

Computer

Desk

Car

Machine

不是字符串。

而是对象。


设计:

VisualObject

{

id

type

attribute

position

state

}

PHP:

<?php


class VisualObject
{


protected $id;


protected $type;


protected $attributes=[];


protected $position;


protected $state;



public function __construct($type)
{

$this->type=$type;

}



public function addAttribute(
$key,
$value
)
{

$this->attributes[$key]=$value;

}



public function setPosition($position)
{

$this->position=$position;

}



public function setState($state)
{

$this->state=$state;

}


}

例如:

创建:

$person=new VisualObject("Person");


$person->addAttribute(
"clothing",
"uniform"
);


$person->setState(
"working"
);

形成:

Person Object


Type:

Person


Attribute:

Uniform


State:

Working

4.15 图片属性 Attribute 系统设计

视觉对象:

由属性描述。

例如:

汽车:

Car


Color:

Black


Brand:

BMW


State:

Stopped

建立:

AttributeObject

{

name

value

confidence

}

PHP:

class AttributeObject
{


private $name;


private $value;


private $confidence;



public function __construct(
$name,
$value
)
{

$this->name=$name;

$this->value=$value;

}


public function getValue()
{

return $this->value;

}


}

对象关系:

VisualObject

↓

Attribute Collection

↓

Semantic Description

4.16 Position空间坐标模型

图片元素必须知道:

在哪里。


Position对象:

Position

{

x

y

width

height

depth

}

PHP:

class Position
{


protected $x;


protected $y;


protected $width;


protected $height;



public function __construct(
$x,
$y,
$w,
$h
)
{

$this->x=$x;

$this->y=$y;

$this->width=$w;

$this->height=$h;

}


}

例如:

图片:

1920×1080

检测:

人物:

x=300

y=200

width=100

height=300

生成:

Person Position Object

4.17 Relation关系模型

视觉理解核心:

对象之间关系。


例如:

Person

Using

Computer

建立:

VisualRelation

{

source

relation

target

}

PHP:

class VisualRelation
{


protected $source;


protected $relation;


protected $target;



public function __construct(
$source,
$relation,
$target
)
{

$this->source=$source;

$this->relation=$relation;

$this->target=$target;

}


}

使用:

$relation=new VisualRelation(

"Person",

"Using",

"Computer"

);

形成:

视觉知识图:

Person

↓

Using

↓

Computer

4.18 SceneElement场景对象设计

单个对象:

无法形成理解。

需要:

Scene。


例如:

对象:

Person

Desk

Computer

Chair

关系:

Person Using Computer

Computer On Desk

形成:

Office Scene

Class:

class SceneElement
{


protected $name;


protected $objects=[];


protected $relations=[];



public function addObject($object)
{

$this->objects[]=$object;

}



public function addRelation($relation)
{

$this->relations[]=$relation;

}



public function understand()
{


return [

"scene"=>$this->name,

"objects"=>$this->objects

];


}


}

4.19 图片分析 Service层

MVC中:

Model不负责业务。

增加:

Service。

目录:

app

/Services

    ImageAnalysisService.php

代码:

class ImageAnalysisService
{


public function analyze(
ImageElement $image
)
{


$result=
$image->analyze();



return $result;


}


}

流程:

Controller

↓

Service

↓

ImageElement

↓

Object Model

4.20 ImageController设计

目录:

app

/Controllers

ImageController.php

代码:

class ImageController
{


public function upload()
{


$file=$_FILES['image'];



$image=
new ImageElement(
$file['name']
);



$service=
new ImageAnalysisService();



$result=
$service->analyze($image);



return $result;


}


}

完整 MVC:

用户上传图片


↓

Controller


↓

Service


↓

ImageElement


↓

VisualObject


↓

Database


↓

Smarty

4.21 Smarty视觉结果展示

模板:

views

/templates

image.tpl

Smarty:

<h2>
图片分析结果
</h2>


图片:

{$image}


对象:

{$objects}


场景:

{$scene}

显示:

图片:

factory.jpg


识别对象:

Machine

Worker


场景:

Factory Environment

4.22 图片感知数据库设计

图片元素需要长期记忆。

数据库:

image_elements

结构:

字段 说明
id 编号
image_source 图片地址
objects 对象
attributes 属性
relations 关系
scene 场景
confidence 可信度
created_at 时间

SQL:

CREATE TABLE image_elements
(

id INT AUTO_INCREMENT PRIMARY KEY,

image_source VARCHAR(255),

objects TEXT,

attributes TEXT,

relations TEXT,

scene VARCHAR(100),

confidence FLOAT,

created_at TIMESTAMP

);

4.23 图片元素 Memory Engine连接

视觉记忆:

对应人类:

视觉记忆。

WSaiOS:

ImageElement

↓

VisualMemory

↓

ExperienceMemory

↓

CognitiveMemory

例如:

第一次:

看到:

某型号设备

保存:

Machine Pattern

第二次:

再次看到:

类似设备

调用:

Memory Recall

↓

Similarity Match

↓

Cognitive Understanding

4.24 图片元素 Factory设计

未来扩展:

ProductImage

MedicalImage

IndustrialImage

MapImage

统一:

class VisualElementFactory
{


public static function create($type)
{


switch($type)
{


case "image":

return new ImageElement();



case "scene":

return new SceneElement();



}


}


}

4.25 WSaiOS 图片感知模块最终架构

Image Input


↓

ImageController


↓

ImageAnalysisService


↓

ImageElement


↓

VisualObject


↓

Attribute Model


↓

Relation Model


↓

SceneElement


↓

CognitiveElement


↓

Memory Engine


↓

Reasoning Engine

4.26 本章工程总结

第四章完成:

理论模型

图片

↓

对象

↓

属性

↓

关系

↓

场景

↓

理解

OOP模型

ImageElement

↓

VisualObject

↓

AttributeObject

↓

PositionObject

↓

RelationObject

↓

SceneElement

PHP MVC实现

Controller

↓

Service

↓

Model

↓

Repository

↓

Database

↓

Smarty

因此:

WSaiOS 图片感知元素不是图像文件管理系统,而是一个面向对象的视觉认知对象系统。


下一章:

第五章

视频感知元素模型

Video Perception Element Model

重点进入动态视觉:

  1. 视频帧对象模型
  2. FrameElement设计
  3. 时间序列模型
  4. Motion运动元素
  5. Event事件元素
  6. State变化模型
  7. Video MVC工程实现
  8. 视频记忆与经验学习模型

将研究:

静态视觉 → 动态视觉 → 事件认知 → 行为理解

Leave a Reply

Your email address will not be published. Required fields are marked *