使用(傅里叶特征描述子)和(Hu不变矩)作为特征 通过训练手势识别数据集 建立基于matlab手势识别检测gui 识别图片及视频的手势判断
文章目录
Matlab 手势识别 GUI 可以识别图片和视频中的手势

建立流程及实现目标:
- 图片或者实时视频
- 图像分割,进行手势区域的分割,得到分割结果的二值图
(基于kmeans分割 + 基于肤色分割) - 图像去噪,形态学处理,去除小对象
- 边缘检测,轮廓检测,凸包提取
sobel ,prewitt,roberts,log,canny - 进行图像特征的计算,与模板库中的图像特征进行对比,得到分类结果。
使用 傅里叶特征描述子 及 Hu不变矩 作为特征,具有旋转平移不变性
构建一个基于 MATLAB 的手势识别 GUI 系统,可以按照以下步骤进行。这个系统将处理图片和实时视频中的手势,并使用傅里叶特征描述子和 Hu 不变矩作为图像特征进行分类。
完善图像去噪的实现,并将其整合到整个手势识别系统中。以下是详细的 MATLAB 代码示例,包括图像去噪、边缘检测等步骤。
3.3 核心算法——图像去噪
函数定义:denoise.m
function [pic_cut] = denoise(pic)
% 图像去噪
% 使用形态学处理去除小区域
IM = bwareaopen(pic, round(1/20 * numel(pic))); % 去除包含像素点少的白色区域
% 定义结构元素(圆形)
se = strel('disk', round(numel(IM) / 15000));
% 开操作(腐蚀后膨胀)
IM = imopen(IM, se);
% 再次使用 bwareaopen 去除小区域
IM = bwareaopen(IM, round(1/20 * numel(IM)));
% 平滑滤波
fspecial_filter = fspecial('average', [5, 5]);
pic_cut = imfilter(IM, fspecial_filter);
end
4. 边缘检测与轮廓提取
函数定义:detectEdges.m
function edges = detectEdges(pic_cut, edgeType)
% 边缘检测
switch edgeType
case 'Sobel'
edges = edge(pic_cut, 'sobel');
case 'Prewitt'
edges = edge(pic_cut, 'prewitt');
case 'Roberts'
edges = edge(pic_cut, 'roberts');
case 'LoG'
edges = edge(pic_cut, 'log');
case 'Canny'
edges = edge(pic_cut, 'canny');
otherwise
error('Invalid edge detection type');
end
% 提取轮廓和凸包
contours = bwboundaries(edges);
convexHull = poly2mask(contours{
1}(:, 2), contours{
1}(:, 1), size(edges, 1), size(edges, 2));
% 显示结果
figure;
subplot(1, 2, 1);
imshow(edges);
title('Edge Image');
subplot(1, 2, 2);
imshow(convexHull);
title('Convex Hull');
end
5. 整合到 GUI 系统
GUI 主程序:main_gui.m
function main_gui()
% 创建 GUI 界面
fig = uifigure('Name', 'Gesture Recognition System');
axRealTimeImage = uiaxes(fig, 'Position', [50, 50, 200, 200]);
axDenoisedImage = uiaxes(fig, 'Position', [300, 50, 200, 200]);
axEdgeImage = uiaxes(fig, 'Position', [550, 50, 200, 200]);
% 按钮
btnDenoise = uibutton(fig, 'push', 'Text', '去噪处理', 'Position', [50, 300, 100, 30], 'ButtonPushedFcn', @(btn,event) denoiseCallback(axRealTimeImage, axDenoisedImage))