资源简介

利用Matlab进行车辆检测与车型识别,包含详细的代码,

资源截图

代码片段和文件信息

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  2018-07-10 15:28  车辆检测识别\
     目录           0  2018-07-10 15:27  车辆检测识别\车辆检测与识别\
     文件        3201  2017-03-31 09:12  车辆检测识别\车辆检测与识别\CarProphet.m
     目录           0  2018-07-10 15:27  车辆检测识别\车辆检测与识别\core_func\
     文件         391  2017-03-31 09:12  车辆检测识别\车辆检测与识别\core_func\draw.m
     文件         358  2017-03-31 09:12  车辆检测识别\车辆检测与识别\core_func\draw_roi_class.m
     文件         277  2017-03-31 09:12  车辆检测识别\车辆检测与识别\core_func\get_highscore_proposals.m
     目录           0  2018-07-10 15:27  车辆检测识别\车辆检测与识别\GUI\
     文件       70136  2017-03-31 09:12  车辆检测识别\车辆检测与识别\GUI\MainWindow.fig
     文件        8785  2017-03-31 09:12  车辆检测识别\车辆检测与识别\GUI\MainWindow.m
     目录           0  2018-07-10 15:27  车辆检测识别\车辆检测与识别\Model\
     文件         250  2017-03-31 09:12  车辆检测识别\车辆检测与识别\Model\Download.txt
     目录           0  2018-07-10 15:27  车辆检测识别\车辆检测与识别\Old\
     文件         765  2017-03-31 09:12  车辆检测识别\车辆检测与识别\Old\Pic_Detect_Recognition.m
     文件         302  2017-03-31 09:12  车辆检测识别\车辆检测与识别\Old\Start.m
     文件         960  2017-03-31 09:12  车辆检测识别\车辆检测与识别\Old\Video_Detect_Recognition.m
     文件        3156  2017-03-31 09:12  车辆检测识别\车辆检测与识别\README.md
     文件         187  2017-03-31 09:12  车辆检测识别\车辆检测与识别\start.m

评论

共有 条评论