⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 show2.m

📁 粒子滤波全套源代码
💻 M
📖 第 1 页 / 共 2 页
字号:
% hObject    handle to particleHigh (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 particleHigh as text%        str2double(get(hObject,'String')) returns contents of particleHigh as a doubleglobal particleHigh;particleHigh=str2num(get(hObject,'String'));% --- Executes during object creation, after setting all properties.function particleHigh_CreateFcn(hObject, eventdata, handles)% hObject    handle to particleHigh (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');endfunction mycallback(hObject, eventdata, handles)% r1=int16(rand(1)*500);% %r2=int16(rand(1)*500);% r2=100;% r2=r2+10;% rectangle('Position',[r1,r2,6,6],'FaceColor','r');% global first;% % first=first+1;% name=num2str(first,'%04.4g');% firstname=[name,'.jpg'];% I=imread(firstname);% hh=get(hObject, 'UserData');% axes(hh.axes1);% imshow(I);% --- 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)% global t;% t=timer('TimerFcn',@mycallback,'Period',0.020,'ExecutionMode','fixedSpacing','TasksToExecute',100,'UserData',handles);% start(t);% for i=200:1:250;% pause(0.025);% pause on;% name=num2str(i,'%04.4g');% firstname=[name,'.jpg'];% I=imread(firstname);% % hh=get(hObject, 'UserData');% % axes(hh.axes1);% imshow(I);% drawnow;% end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%global v_count;global matrix;global x;global y;global first;global particleNum;global frameNum;global particleWidth;global particleHigh;global weigthError;global pathname;global bExit;global filenamelength;bExit=0;hx=particleWidth;hy=particleHigh;N=particleNum;n=frameNum;new_sita=weigthError;v_count=512;matrix=1:1:v_count;   %%%%%maybe it should be changed to global variableHx=int16(hx);Hy=int16(hy);vx=0;vy=0;switch filenamelength    case 4         name=num2str(first,'%04.4g');    case 5        name=num2str(first,'%05.4g');endfirstname=[name,'.jpg'];I=imread([pathname firstname]);info = imfinfo([pathname firstname]);image_boundary_x=int16(info.Width);%int16(700); image_boundary_y=int16(info.Height);%int16(550);[Sample_Set,Sample_probability,Estimate,target_histgram]=initial_2(x,y,Hx,Hy,vx,vy,I,N);for loop=2:1:n;    if(bExit>0)        first=loop+first-1;        break;    end    if Estimate(loop-1).prob>=0.05       k=target_histgram;       %target_histgram=0.8*k+0.2*Estimate(loop-1).histgram;       %if(loop<100)         target_histgram=0.90*k+0.10*Estimate(loop-1).histgram;%        elseif(loop<200)%            new_sita=0.25;%          target_histgram=0.99*k+0.01*Estimate(loop-1).histgram;  %        elseif(loop<280)%             new_sita=0.30;%          target_histgram=0.99*k+0.01*Estimate(loop-1).histgram; %        else%             new_sita=0.30;%          target_histgram=0.99*k+0.01*Estimate(loop-1).histgram;       % end    switch filenamelength        case 4           a=num2str(loop+first-1,'%04.4g');        case 5           a=num2str(loop+first-1,'%05.4g');    end    %a=num2str(loop+first-1,'%0.4g');    b=[a,'.jpg'];    I=imread([pathname '\' b]);    %I=imread(b);    set(handles.textCurrentFile,'String',b);       New_Sample_Set=Select(Sample_Set,Sample_probability,loop,I,N);   [Sample_Set,after_prop]=Propagation(New_Sample_Set,Hx,Hy,vx,vy,image_boundary_x,image_boundary_y,I,N);   [Sample_probability,Estimate,vx,vy,TargetPic]=Observe_and_Estimate(Sample_Set,Estimate,Hx,Hy,target_histgram,new_sita,loop,after_prop,I,N);       else         %a=0;        msgbox('目标丢失!');        first=loop+first-1;        return;    end  set(handles.x2,'String',['     X:    ' num2str(int16(Estimate(loop).x))]);  set(handles.y2,'String',['    Y:    ' num2str(int16(Estimate(loop).y))]);  imshow(TargetPic);  drawnow;endmsgbox('跟踪结束!');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% stop(t);% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton4 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)global t bExit;bExit=1;delete(t);% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton5 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%global v_count;global matrix;global x;global y;global first;global particleNum;global frameNum;global particleWidth;global particleHigh;global weigthError;global pathname;global bExit;global filenamelength;global bFirst;global loop;global N n new_sita Hx Hy vx vy  image_boundary_x image_boundary_y Sample_Set Sample_probability Estimate target_histgram;if(bFirst==0)    bExit=0;    bFirst=1    hx=particleWidth;hy=particleHigh;N=particleNum;n=frameNum;new_sita=weigthError;    v_count=512;    matrix=1:1:v_count;   %%%%%maybe it should be changed to global variable    Hx=int16(hx);    Hy=int16(hy);    vx=0;    vy=0;    switch filenamelength        case 4             name=num2str(first,'%04.4g');        case 5            name=num2str(first,'%05.4g');    end    firstname=[name,'.jpg'];    I=imread([pathname '\' firstname]);    info = imfinfo([pathname '\' firstname]);    image_boundary_x=int16(info.Width);%int16(700);     image_boundary_y=int16(info.Height);%int16(550);    [Sample_Set,Sample_probability,Estimate,target_histgram]=initial_2(x,y,Hx,Hy,vx,vy,I,N);    loop=2;end%for loop=2:1:n;loop    if(bExit>0)        first=loop+first-1;        %break;    end    if Estimate(loop-1).prob>=0.2%0.05       k=target_histgram;       %target_histgram=0.8*k+0.2*Estimate(loop-1).histgram;       %if(loop<100)         target_histgram=0.90*k+0.10*Estimate(loop-1).histgram;%        elseif(loop<200)%            new_sita=0.25;%          target_histgram=0.99*k+0.01*Estimate(loop-1).histgram;  %        elseif(loop<280)%             new_sita=0.30;%          target_histgram=0.99*k+0.01*Estimate(loop-1).histgram; %        else%             new_sita=0.30;%          target_histgram=0.99*k+0.01*Estimate(loop-1).histgram;       % end    switch filenamelength        case 4           a=num2str(loop+first-1,'%04.4g');        case 5           a=num2str(loop+first-1,'%05.4g');    end    %a=num2str(loop+first-1,'%0.4g');    b=[a,'.jpg'];    I=imread([pathname '\' b]);    %I=imread(b);    set(handles.textCurrentFile,'String',b);       New_Sample_Set=Select(Sample_Set,Sample_probability,loop,I,N);   [Sample_Set,after_prop]=Propagation(New_Sample_Set,Hx,Hy,vx,vy,image_boundary_x,image_boundary_y,I,N);   [Sample_probability,Estimate,vx,vy,TargetPic]=Observe_and_Estimate(Sample_Set,Estimate,Hx,Hy,target_histgram,new_sita,loop,after_prop,I,N);       else         %a=0;       % msgbox('目标丢失!');       % first=loop+first-1;        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        k=target_histgram;        target_histgram=0.99*k+0.01*Estimate(loop-1).histgram;        switch filenamelength            case 4               a=num2str(loop+first-1,'%04.4g');            case 5               a=num2str(loop+first-1,'%05.4g');        end    %a=num2str(loop+first-1,'%0.4g');    b=[a,'.jpg'];    I=imread([pathname '\' b]);    %I=imread(b);    set(handles.textCurrentFile,'String',b);       New_Sample_Set=Select(Sample_Set,Sample_probability,loop,I,N);   [Sample_Set,after_prop]=Propagation(New_Sample_Set,Hx,Hy,vx,vy,image_boundary_x,image_boundary_y,I,N);   [Sample_probability,Estimate,vx,vy,TargetPic]=Observe_and_Estimate(Sample_Set,Estimate,Hx,Hy,target_histgram,new_sita,loop,after_prop,I,N);        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     %   return;    end  set(handles.x2,'String',['     X:    ' num2str(int16(Estimate(loop).x))]);  set(handles.y2,'String',['    Y:    ' num2str(int16(Estimate(loop).y))]);  imshow(TargetPic);  drawnow;  loop=loop+1;%end%msgbox('跟踪结束!');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -