一、项目简介

本系统基于MATLAB平台,利用卷积神经网络(CNN)与GUI界面,实现石头、剪刀、布三类手势图像的识别。训练模块采用自定义CNN(含4个卷积层、池化层及全连接层,输出3类),按8:2划分训练集与测试集;GUI模块支持PNG图像选取、模型载入、单张实时识别(结果以弹窗显示)及测试集总体准确率评估,操作简便。

二、部分源码

function pushbutton1_Callback(hObject, eventdata, handles) % 选取图像

% hObject handle to pushbutton1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

[fn,pn,~]=uigetfile('*.png','请选择所要识别的图像');

I = imread([pn fn]);

axes(handles.axes1);

imshow(I,[]);

title('所选图像');

handles.I = I;

guidata(gcbo,handles);

% --- Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles) % 进行识别

% hObject handle to pushbutton2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

load("CNNnet.mat");

y_pred = classify(CNNnet,handles.I);

% disp(y_pred);

set(handles.edit1,'string',y_pred);

result=strcat('手势种类:',string(y_pred),'');

msgbox(result,'识别结果','warn')

function edit1_Callback(hObject, eventdata, handles)

% hObject handle to edit1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text

% str2double(get(hObject,'String')) returns contents of edit1 as a double

% --- Executes during object creation, after setting all properties.

function edit1_CreateFcn(hObject, eventdata, handles)

% hObject handle to edit1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

% --- Executes on button press in pushbutton3.

function pushbutton3_Callback(hObject, eventdata, handles) % 显示整个测试集的结果

% hObject handle to pushbutton3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

%% 加载数据

allImages = imageDatastore('dbx', ...

'IncludeSubfolders' ,true, ...

'LabelSource' , 'foldernames' );% 图像加载为图像数据存储

% imageDatastore函数会根据文件夹名称自动标记图像

% 划分训练集(80%)和测试集(20%)

[imgsTrain,imgsTest] = splitEachLabel(allImages,0.8,'randomized');

load("CNNnet.mat");

y_pred = classify(CNNnet,imgsTest); % 使用训练好的网络测试

accuracy = mean(y_pred == imgsTest.Labels);% 计算准确率

set(handles.text2,'string',['总体准确率: ',num2str(100*accuracy),'%'],'FontSize',12);

三、运行结果

四、总结

测试集总体准确率达88.11%,验证了CNN对手势分类的有效性。系统界面直观,具备实用与教学价值。不足在于网络结构较浅、支持PNG格式,且未展示各类别准确率。后续可通过数据增强、迁移学习及多格式支持提升泛化性能。

五、代码获取

接matlab程序定制和论文设计,方向如下:

图像处理|语音识别|图像识别|目标检测|深度学习|神经网络|强化学习|机器学习|通信系统|信号处理|时频分析|小波降噪|路径规划|优化算法|智能算法|数据处理|数学建模|文献复现|算法复现|模型复现等

程序包运行成功,零基础的可以远程帮你运行,赠送安装包

作为初学者,遇见不会的问题是非常正常的事情,具体代码仿真可通过主页 私信博主。

Logo

脑启社区是一个专注类脑智能领域的开发者社区。欢迎加入社区,共建类脑智能生态。社区为开发者提供了丰富的开源类脑工具软件、类脑算法模型及数据集、类脑知识库、类脑技术培训课程以及类脑应用案例等资源。

更多推荐