资源简介

一个完整的matlab带gui的demo,可以识别很多车型(具体到汽车品牌和型号),并且会在图片中标明车型

资源截图

代码片段和文件信息

classdef  CarProphet
    properties(Access = ‘public‘)
       % object for recognize 
       Mat;
       Video;
       %%
       STATE=-1;% Attention: STATE is the program‘s status. 0 represents image 1 represents video.
       %%
       END=false;% Attention: END is an instruction to play or stop the video
       %%
       RealRegion; % [x y width height] or a matrix of it.
       %%
       Threshold=0.5; % judge the bbox by this value. (is car or not??)
    end
    
    %%
    % our model :RCNNModel ClassifyModel. “class_array“ is the index of car type. 
    properties(Access = ‘private‘)
       RCNNModel;
       ClassifyModel;
       class_array;
    end
    %%
    methods(Access = ‘public‘)
        % Constructor of the class
        function Predictor = CarProphet(RCNNModelRoadClassifyModelRoadClassNameRoad)
                Predictor.RCNNModel=load(RCNNModelRoad);
                Predictor.ClassifyModel=load(ClassifyModelRoad);
                Predictor.class_array=load(ClassNameRoad);
        end
        % Function of load model
        function LoadRCNN(PredictorRCNNModelRoad)
            Predictor.RCNNModel=load(RCNNModelRoad);
        end
        
        function LoadClassifyModel(PredictorClassifyModelRoad)
            Predictor.ClassifyModel=load(ClassifyModelRoad);
        end
        %%
        % 4 steps:load pic->selective_search(proposal)-> rcnn_forward -> classify
        % Attention: selective_search and rcnn_forward are not directly
        % linked here because a large number of proposals but you can find
        % a way to link it in draw.m 
        
        function [ProposalScores]=selective_search(Predictor)
            [ProposalScores]=Predictor.RCNNModel.cifar10NetRCNN.RegionProposalFcn(Predictor.Mat);
        end
        
        
        function RealRegion=rcnn_forward(Predictor)
           [bboxes scores ~]= Predictor.RCNNModel.cifar10NetRCNN.detect(Predictor.Mat);
           CarScores=scores(:1);
           HighProbROI_Index=find(CarScores>Predictor.Threshold);
           RealRegion=bboxes(HighProbROI_Index:);
        end
        
        
        function [roisclasses]=classify(Predictor)
            size_=size(Predictor.RealRegion);
            length_=size_(1);
            img_batch4d=zeros(2272273length_);
            for i=1:length_
              crop_roi=Predictor.RealRegion(i:);
              img_single=imcrop(Predictor.Matcrop_roi);
              img_single=imresize(img_single[227 227]);
              img_batch4d(:::i)=img_single; % Constructing 4d-array images
            end
              if(~isempty(img_batch4d))
                  label_nums=Predictor.ClassifyModel.AlexNet_New.classify(img_batch4d);
                  %draw labels in picture
                  classes=Predictor.class_array.class_names(label_nums);
                  rois=Predictor.RealRegion;
              end
        end
        
        
     

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-03-31 01:12  Vehicle_Detection_Recognition-master\
     文件        3201  2017-03-31 01:12  Vehicle_Detection_Recognition-master\CarProphet.m
     目录           0  2017-03-31 01:12  Vehicle_Detection_Recognition-master\GUI\
     文件       70136  2017-03-31 01:12  Vehicle_Detection_Recognition-master\GUI\MainWindow.fig
     文件        8785  2017-03-31 01:12  Vehicle_Detection_Recognition-master\GUI\MainWindow.m
     目录           0  2017-03-31 01:12  Vehicle_Detection_Recognition-master\Model\
     文件         250  2017-03-31 01:12  Vehicle_Detection_Recognition-master\Model\Download.txt
     目录           0  2017-03-31 01:12  Vehicle_Detection_Recognition-master\Old\
     文件         765  2017-03-31 01:12  Vehicle_Detection_Recognition-master\Old\Pic_Detect_Recognition.m
     文件         302  2017-03-31 01:12  Vehicle_Detection_Recognition-master\Old\Start.m
     文件         960  2017-03-31 01:12  Vehicle_Detection_Recognition-master\Old\Video_Detect_Recognition.m
     文件        3156  2017-03-31 01:12  Vehicle_Detection_Recognition-master\README.md
     目录           0  2017-03-31 01:12  Vehicle_Detection_Recognition-master\core_func\
     文件         391  2017-03-31 01:12  Vehicle_Detection_Recognition-master\core_func\draw.m
     文件         358  2017-03-31 01:12  Vehicle_Detection_Recognition-master\core_func\draw_roi_class.m
     文件         277  2017-03-31 01:12  Vehicle_Detection_Recognition-master\core_func\get_highscore_proposals.m
     文件         187  2017-03-31 01:12  Vehicle_Detection_Recognition-master\start.m

评论

共有 条评论