بایگانی برچسب برای: vs ;n vhd’hk

کد برنامه تشخیص و شمارش خودروهای در حال حرکت در زبان Matlab

در این پروژه سعی داریم با استفاده از روش «رهگیری اهداف چندگانه» اقدام به شناسایی اشیاء در حال حرکت نموده و آنها را شمارش نمائیم. این برنامه می تواند جهت شمارش تعداد خودروهای عبوری، تعداد افراد در حال تردد و… مورد استفاده قرار بگیرد. این الگوریتم توسط شرکت mathwork پیاده سازی گردیده و جهت استفاده علاقه مندان ادامه ارائه می گردد.

باتوجه به توضیحات کامل این پروژه از ذکر توضیحات اضافه اجتناب میکنیم و فقط شرحی مختصر از عماکرد برنامه ارائه می نماییم. ابتدا با استفاده از چند فریم به عنوان نمونه، زمینه(background) را شناسایی می کنیم و سپس به اقدام به تشخیص آبجکت های(foreground) می نماییم. سپس با استفاده از روش کالمن (Kalman) اقدام به رهگیری آبجکت هایی که از مقداری مشخص (اصلاحا blob) بزرگتر هستند می نمائیم.  در ادامه آبجکت ها را رهگیری می کنیم تا هنگامی که از صفحه خارج شوند. نکته جالب توجه این هست که اگر آبجکتی موقتا ناپیدا شود(مثلا زیر پل یا درخت قرار بگیرد) به عنوان «Predicted» برچسب خورده و پس از پیدا شدن مجددا به عنوان همان آبجکت قبلی شناسایی می شود.

 

تشخیص و شمارش خودروهای در حال حرکت

سورس کد برنامه تشخیص و شمارش خودرو:

 

%% Multiple Object Tracking Tutorial
% This example shows how to perform automatic detection and motion-based
% tracking of moving objects in a video. It simplifies the example
% <matlab:helpview(fullfile(docroot,'toolbox','vision','vision.map'),'MotionBasedMultiObjectTrackingExample')
% Motion-Based Multiple Object Tracking> and uses the |multiObjectTracker|
% available in Automated Driving System Toolbox.
%
% Copyright 2016 The MathWorks, Inc.
 
%%
% Detection of moving objects and motion-based tracking are important 
% components of many computer vision applications, including activity
% recognition, traffic monitoring, and automotive safety. The problem of
% motion-based object tracking can be divided into two parts:
%
% # Detecting moving objects in each frame 
% # Tracking the moving objects from frame to frame 
%
% The detection of moving objects uses a background subtraction algorithm
% based on Gaussian mixture models. Morphological operations are applied to
% the resulting foreground mask to eliminate noise. Finally, blob analysis
% detects groups of connected pixels, which are likely to correspond to
% moving objects. 
%
% The tracking of moving objects from frame to frame is done by the
% |multiObjectTracker| object that is responsible for the following:
%
% # Assigning detections to tracks. 
% # Initializing new tracks based on unassigned detections. All tracks are
% initialized as |'Tentative'|, accounting for the possibility that they
% resulted from a false detection.
% # Confirming tracks if they have more than _M_ assigned detections in _N_
% frames.
% # Updating existing tracks based on assigned detections.
% # Coasting (predicting) existing unassigned tracks.
% # Deleting tracks if they have remained unassigned (coasted) for too long.
%
% The assignment of detections to the same object is based solely on
% motion. The motion of each track is estimated by a Kalman filter. The
% filter predicts the track's location in each frame, and determines the
% likelihood of each detection being assigned to each track. To initialize
% the filter that you design, use the |FilterInitializationFcn| property of
% the |multiObjectTracker|.
%
% For more information, see
% <matlab:helpview(fullfile(docroot,'toolbox','vision','vision.map'),'multipleObjectTracking') Multiple Object Tracking>.
%
% This example is a function, with the main body at the top and helper 
% routines in the form of 
% <matlab:helpview(fullfile(docroot,'toolbox','matlab','matlab_prog','matlab_prog.map'),'nested_functions') nested functions> 
% below.
 
function p12_on_video_using_tracking_matlab_sample()
% Create objects used for reading video and displaying the results.
videoObjects = setupVideoObjects('6.mp4');
 
% Create objects used for detecting objects in the foreground of the video.
minBlobArea = 10000; % Minimum blob size, in pixels, to be considered as a detection
detectorObjects = setupDetectorObjects(minBlobArea);
 
%% Create the Multi-Object Tracker
% When creating a |multiObjectTracker|, consider the following: 
%
% # |FilterInitializationFcn|: The likely motion and measurement models. 
% In this case, the objects are expected to have a constant speed motion.
% The |initDemoFilter| function configures a linear Kalman filter to 
% track the motion. See the 'Define a Kalman filter' section for details.
% # |AssignmentThreshold|: How far detections may fall from tracks. 
% The default value for this parameter is 30. If there are detections
% that are not assigned to tracks, but should be, increase this value. If
% there are detections that get assigned to tracks that are too far,
% decrease this value.
% # |NumCoastingUpdates|: How long a track is maintained before deletion.
% In this case, since the video has 30 frames per second, a reasonable
% value is about 0.75 seconds (22 frames).
% # |ConfirmationParameters|: The parameters controlling track confirmation.
% A track is initialized with every unassigned detection. Some of these
% detections might be false, so initially, all tracks are |'Tentative'|. 
% To confirm a track, it has to be detected at least _M_ out of _N_
% frames. The choice of _M_ and _N_ depends on the visibility of the
% objects. This example assumes a visibility of 6 out of 10 frames.
tracker = multiObjectTracker(...
 'FilterInitializationFcn', @initDemoFilter, ...
 'AssignmentThreshold', 30, ...
 'NumCoastingUpdates', 22, ...
 'ConfirmationParameters', [6 10] ...
 );
 
%% Define a Kalman Filter
% When defining a tracking filter for the motion, complete the following
% steps:
%
% *Step 1: Define the motion model and state*
%
% In this example, use a constant velocity model in a 2-D rectangular
% frame.
%
% # The state is |[x;vx;y;vy]|.
% # The state transition model matrix is |A = [1 dt 0 0; 0 1 0 0; 0 0 1 dt; 0 0 0 1]|.
% # Assume that |dt = 1|.
%
% *Step 2: Define the process noise*
%
% The process noise represents the parts of the process that are not taken
% into account in the model. For example, in a constant velocity model, the
% acceleration is neglected.
%
% *Step 3: Define the measurement model*
%
% In this example, only the position (|[x;y]|) is measured. So, the
% measurement model is |H = [1 0 0 0; 0 0 1 0]|.
%
% Note: To preconfigure these parameters, define the |'MotionModel'|
% property as |'2D Constant Velocity'|.
%
% *Step 4: Initialize the state vector based on the sensor measurement*
%
% In this example, because the measurement is |[x;y]| and the state is
% |[x;vx;y;vy]|, initializing the state vector is straightforward. Because
% there is no measurement of the velocity, initialize the |vx| and |vy|
% components to 0.
%
% *Step 5: Define an initial state covariance*
%
% In this example, the measurements are quite noisy, so define the initial 
% state covariance to be quite large: |stateCov = diag([50, 50, 50, 50])|
%
% *Step 6: Create the correct filter*
% 
% In this example, all the models are linear, so use |trackingKF| as the
% tracking filter.
 function filter = initDemoFilter(detection)
 % Initialize a Kalman filter for this example.
 
 % Define the initial state.
 state = [detection.Measurement(1); 0; detection.Measurement(2); 0];
 
 % Define the initial state covariance.
 stateCov = diag([50, 50, 50, 50]);
 
 % Create the tracking filter.
 filter = trackingKF('MotionModel', '2D Constant Velocity', ... 
 'State', state, ...
 'StateCovariance', stateCov, ... 
 'MeasurementNoise', detection.MeasurementNoise(1:2,1:2) ... 
 );
 end
 
%%% 
% The following loop runs the video clip, detects moving objects in the
% video, and tracks them across video frames. 
 
% Count frames to create a sense of time.
frameCount = 0;
while hasFrame(videoObjects.reader)
 % Read a video frame and detect objects in it.
 frameCount = frameCount + 1; % Promote frame count
 frame = readFrame(videoObjects.reader); % Read frame 
 [detections, mask] = detectObjects(detectorObjects, frame); % Detect objects in video frame 
 
 % Run the tracker on the preprocessed detections.
 confirmedTracks = updateTracks(tracker, detections, frameCount);
 
 % Display the tracking results on the video.
 displayTrackingResults(videoObjects, confirmedTracks, frame, mask);
end
%% Create Video Objects
% Create objects used for reading and displaying the video frames.
 
 function videoObjects = setupVideoObjects(filename)
 % Initialize video I/O
 % Create objects for reading a video from a file, drawing the tracked
 % objects in each frame, and playing the video.
 
 % Create a video file reader.
 videoObjects.reader = VideoReader(filename);
 
 % Create two video players: one to display the video,
 % and one to display the foreground mask. 
 videoObjects.maskPlayer = vision.VideoPlayer('Position', [20, 400, 700, 400]);
 videoObjects.videoPlayer = vision.VideoPlayer('Position', [740, 400, 700, 400]);
 end
 
%% Create Detector Objects
% Create objects used for detecting foreground objects.
% Use |minBlobArea| to define the size of the blob, in pixels, that is
% considered to be a detection. 
%
% * Increase |minBlobArea| to avoid detecting small blobs, which are more
% likely to be false detections, or if several detections are created for 
% the same object due to partial occlusion.
% * Decrease |minBlobArea| if objects are detected too late or not at all.
 
 function detectorObjects = setupDetectorObjects(minBlobArea)
 % Create System objects for foreground detection and blob analysis
 
 % The foreground detector segments moving objects from the
 % background. It outputs a binary mask, where the pixel value of 1
 % corresponds to the foreground and the value of 0 corresponds to
 % the background.
 
 detectorObjects.detector = vision.ForegroundDetector('NumGaussians', 3, ...
 'NumTrainingFrames', 40, 'MinimumBackgroundRatio', 0.7);
 
 % Connected groups of foreground pixels are likely to correspond to
 % moving objects. The blob analysis System object finds such
 % groups (called 'blobs' or 'connected components') and computes
 % their characteristics, such as their areas, centroids, and the
 % bounding boxes.
 
 detectorObjects.blobAnalyzer = vision.BlobAnalysis('BoundingBoxOutputPort', true, ...
 'AreaOutputPort', true, 'CentroidOutputPort', true, ...
 'MinimumBlobArea', minBlobArea);
 end
 
%% Detect Objects
% The |detectObjects| function returns the centroids and the bounding boxes
% of the detected objects as a list of |objectDetection| objects. You can
% supply this list as an input to the |multiObjectTracker|. The
% |detectObjects| function also returns the binary mask, which has the same
% size as the input frame. Pixels with a value of 1 correspond to the
% foreground. Pixels with a value of 0 correspond to the background.
%
% The function performs motion segmentation using the foreground detector. 
% It then performs morphological operations on the resulting binary mask to
% remove noisy pixels and to fill the holes in the remaining blobs.
%
% When creating the |objectDetection| list, the |frameCount| serves as the
% time input, and the centroids of the detected blobs serve as the
% measurement. The list also has two optional name-value pairs:
%
% * |MeasurementNoise| - Blob detection is noisy, and this example defines 
% a large measurement noise value.
% * |ObjectAttributes| - The detected bounding boxes that get passed to the
% track display are added to this argument.
 
 function [detections, mask] = detectObjects(detectorObjects, frame)
 % Expected uncertainty (noise) for the blob centroid.
 measurementNoise = 100*eye(2); 
 % Detect foreground.
 mask = detectorObjects.detector.step(frame);
 
 % Apply morphological operations to remove noise and fill in holes.
 mask = imopen(mask, strel('rectangle', [9, 9]));
 mask = imclose(mask, strel('rectangle', [10, 10])); 
 mask=bwareaopen(mask,1500);
 mask = imfill(mask, 'holes');
 
 % Perform blob analysis to find connected components.
 [~, centroids, bboxes] = detectorObjects.blobAnalyzer.step(mask);
 
 % Formulate the detections as a list of objectDetection objects.
 numDetections = size(centroids, 1);
 detections = cell(numDetections, 1);
 for i = 1:numDetections
 detections{i} = objectDetection(frameCount, centroids(i,:), ...
 'MeasurementNoise', measurementNoise, ...
 'ObjectAttributes', {bboxes(i,:)});
 end
 end
 
%% Display Tracking Results
% The |displayTrackingResults| function draws a bounding box and label ID
% for each track on the video frame and foreground mask. It then displays
% the frame and the mask in their respective video players.
 
 function displayTrackingResults(videoObjects, confirmedTracks, frame, mask)
 % Convert the frame and the mask to uint8 RGB.
 frame = im2uint8(frame);
 mask = uint8(repmat(mask, [1, 1, 3])) .* 255;
 
 if ~isempty(confirmedTracks) 
 % Display the objects. If an object has not been detected
 % in this frame, display its predicted bounding box.
 numRelTr = numel(confirmedTracks);
 boxes = zeros(numRelTr, 4);
 ids = zeros(numRelTr, 1, 'int32');
 predictedTrackInds = zeros(numRelTr, 1);
 for tr = 1:numRelTr
 % Get bounding boxes.
 boxes(tr, : ) = confirmedTracks(tr).ObjectAttributes{1}{1};
 
 % Get IDs.
 ids(tr) = confirmedTracks(tr).TrackID;
 
 if confirmedTracks(tr).IsCoasted
 predictedTrackInds(tr) = tr;
 end
 end
 
 predictedTrackInds = predictedTrackInds(predictedTrackInds > 0);
 
 % Create labels for objects that display the predicted rather 
 % than the actual location.
 labels = cellstr(int2str(ids));
 
 isPredicted = cell(size(labels));
 isPredicted(predictedTrackInds) = {' predicted'};
 labels = strcat(labels, isPredicted);
 
 % Draw the objects on the frame.
 frame = insertObjectAnnotation(frame, 'rectangle', boxes, labels);
 
 % Draw the objects on the mask.
 mask = insertObjectAnnotation(mask, 'rectangle', boxes, labels);
 end
 
 % Display the mask and the frame.
 videoObjects.maskPlayer.step(mask); 
 videoObjects.videoPlayer.step(frame);
 end
displayEndOfDemoMessage(mfilename)
end
%% Summary
% In this example, you created a motion-based system for detecting and
% tracking multiple moving objects. Try using a different video to see if
% you can detect and track objects. Try modifying the parameters of the
% |multiObjectTracker|.
%
% The tracking in this example was based solely on motion, with the
% assumption that all objects move in a straight line with constant speed.
% When the motion of an object significantly deviates from this model, the
% example can produce tracking errors. Notice the mistake in tracking the
% person occluded by the tree.
%
% You can reduce the likelihood of tracking errors by using a more complex
% motion model, such as constant acceleration or constant turn. To do that,
% try defining a different tracking filter, such as |trackingEKF| or
% |trackingUKF|. 

تشخیص و شمارش خودروهای در حال حرکت

 

منبع:

https://www.mathworks.com/

 

جهت دانلود بر روی لینک زیر کلیک نمایید.

تشخیص و شمارش خودروهای درحال حرکت

ویدئوی پیوست برنامه تشخیص و شمارش خودورهای در حال حرکت

رمز فایل : behsanandish.com

 

شناسایی حروف توسط شبکه های عصبی

تو این مطلب می خواهیم بصورت عملی از شبکه های عصبی استفاده کنیم! واقعا خیلی جالبه می خوایم به کامپیوتر سه تا حرف الفبای انگلیسی رو یاد بدیم.
نکته ی جالب تر این هست که حتی به کامپیوتر نمی گیم هر کدوم از حرف ها چی هستن! فقط بهش می گیم که این ها سه حرف مختلف هستند! و کامپیوتر خودش تشخیص می ده هر کدوم متعلق به کدوم گروه هست! به این نوع طبقه بندی اصطلاحا Unsupervised میگویند.

سوال : به نظر میرسه باید توی مثال هامون به کامپیوتر بگیم مثلا این A هست و این B هست!
جواب : اون هم نوعی یادگیری هست که بهش اصطلاحا Supervised می گن. اما توی این مثال حالت جالب تر یعنی Unsupervised رو می خوایم بررسی کنیم. به این صورت که فقط به کامپیوتر می گیم ۳ دسته وجود داره و براش چندین مثال می زنیم و خودش مثال ها رو توی ۳ دسته قرار می ده! در نهایت ما مثلا می تونیم بگیم همه ی مثال هایی که در دسته ی دوم قرار گرفتن A هستند.
شاید جالب باشه بدونید گوگل هم برای دسته بندی اطلاعات از همچین روشی استفاده می کنه! البته کمی پیشرفته تر. مثلا ۱۰۰ متن اقتصادی و ۱۰۰ متن ورزشی به کامپیوتر میده و از کامپیوتر می خواد اونها رو به ۲ بخش تقسیم بندی بکنه! ورودی لغت های اون متن ها هستند. “

ابزار مورد نیاز
برای این که شروع کنیم به چند مورد نیاز داریم:

  1. در مورد هوش مصنوعی و شبکه های عصبی یکم اطلاعات داشته باشید.
  2. برنامه ای برای تولید الگو که ورودی شبکه ی عصبی ما خواهد بود. این برنامه رو میتونید از اینجا تهیه کنید.
  3. نرم افزار JOONE Editor. عبارت JOONE مخفف Java Object Oriented Neural Engine هست. که یک ابزار قدرت مند برای بوجود آوردن و آموزش انواع شبکه های عصبی در Java هست. توی این آموزش ما از ویرایشگر این ابزار استفاده می کنیم که محیطی گرافیکی برای تولید شبکه های عصبی داره و کار با اون بسیار ساده هست. این ابزار از اینجا قابل دریافت هست. بدیهیه که برای نصب این ابزار ابتدا باید جاوا روی کامپیوتر شما نصب باشه.
  4. کمی پشتکار و حوصله.

لینک جایگزین برای دانلود JOONE Editor:
https://sourceforge.net/projects/joone/files/

حالا می خوایم یک سری الگو تولید کنیم. الگو همون مثال هایی هست که گفتیم برای کامپیوتر می زنیم تا بتونه یاد بگیره.
برای این کار از برنامه ای که در شماره ی ۲ ابزارها معرفی کردم استفاده می کنیم. این برنامه خیلی ساده کار می کنه و فقط الگو ها رو از حالت تصویری به ۰ و ۱ تبدیل می کنه.
روش کار به این صورت هست که اول تصویر رو به یک ماتریس ۸ در ۸ تقسیم می کنه. یعنی ۶۴ قسمت. وقتی دکمه ی سمت چپ ماوس پایینه در صورتی که ماوس از هر کدوم از اون ۶۴ بخش رد بشه اون بخش رو داخل ماتریس علامت گذاری می کنه (مقدار اون قسمت رو True می کنه). وقتی دکمه ی Learn زده می شه برنامه مقدار تمام قسمت ها رو از بالا به پایین داخل یک فایل ذخیره می کنه. مقدار هر قسمت می تونه ۰ یا False و ۱ یا True باشه. ”
در صورتی که سورس این برنامرو خواستید کافیه توی بخش نظرات بگید تا براتون میل کنم.
کار با این برنامه خیلی آسون هست همونطور که توی شکل مشخصه.

کافیه الگویی که دوست دارید رو داخل فضای سفید بکشید و دکمه ی Learn رو بزنید. Textbox پایینی برای تغییر دادن آدرس فایلی هست که اطلاعات توی اون ذخیره میشه. و Textbox بالایی برای اینه که بگید این الگو چه حرفی هست که توی این مطلب نیازی به پر کردن اون نیست چون ما بحثمون یادگیری Unsupervised هست. توی مطالب بعدی برای یادگیری Supervised به این فیلد نیاز خواهیم داشت.
خوب من برای اینکه مثال پیچیده نشه ۳ حرف رو می خوام به کامپیوتر یاد بدم. A و C و Z!
برای این کار برای هر کدوم از حروف چهار مثال وارد می کنم و دکمه ی Learn رو می زنم. توی شکل زیر می تونید هر ۱۲ الگو رو ببینید.

فایل خروجی مربوط به این الگوهای مثال از اینجا قابل دریافت هست.همونطور که می بینید هر ردیف به نظر من و شما عین هم هستند. اما اگر کمی بیشتر دقت کنیم می بینیم جای مربع های مشکی با هم فرق دارن. به نظر شما کامپیوتر هم خواهد فهمید هر ردیف نشاندهنده ی یک حرف مجزا هست؟
تشکیل شبکه ی عصبیخوب! حالا می خواهیم ساختار شبکه ی عصبی رو طراحی کنیم. برای این کار از JOONE Editor کمک می گیریم.
صفحه ی اول این نرم افزار به این شکل هست:

توی این مثال ما از یک لایه ی ورودی خطی ۶۴ نورونی استفاده می کنیم که هر نورون یک قسمت از ماتریسی که در بخش قبل گفتیم رو به عنوان ورودی می گیره. به عنوان خروجی هم از یک لایه ی ۳ نورونی WinnerTakeAll استفاده می کنیم. در این نوع خروجی یکی از نورون ها ۱ و بقیه ۰ خواهند بود که برای تقسیم بندی بسیار مناسب هست.

برای شروع ابتدا یک لایه ی FileInput ایجاد می کنیم. توسط این ابزار می تونیم یک فایل رو به عنوان ورودی به شبکه بدیم.
روی FileInput کلیک راست کرده و در Properties اون فایل درست شده در مرحله ی قبلی رو به عنوان fileName انتخاب می کنیم و به عنوان Advanced Column Selector مقدار 1-64 رو وارد می کنیم تا برنامه متوجه بشه باید از ستون های ۱ تا ۶۴ به عنوان ورودی استفاده کنه.

ایجاد یک لایه ی خطی:

مرحله ی بعدی ایجاد یک Linear Layer یا لایه ی خطی هست. بعد از ایجاد این لایه Properties اون باید به شکل زیر باشه:

همونطور که می بینید تعداد ردیف ها ۶۴ مقداردهی شده که دلیلش این هست که ۶۴ ورودی داریم.
حالا با انتخاب FileInput و کشیدن نقطه ی آبی رنگ سمت راست اون روی Linear Layer خروجی FileInput یعنی اطلاعات فایل رو به عنوان ورودی Linear Layer انتخاب می کنیم.
تا این لحظه ما یک لایه ی ۶۴ نورونه داریم که ورودی اون مقادیر مثال های تولید شده در مرحله ی قبل هست.

ایجاد لایه ی WinnerTakeAll :

خوب توی این مرحله لایه ی خروجی که یک لایه ی WinnerTakeAll هست رو تولید می کنیم. Properties این لایه باید به شکل زیر تغییر پیدا کنه تا اطمینان پیدا کنیم الگوها به سه دسته تقسیم میشن:

حالا باید بین لایه ی خطی و لایه ی WinnerTakeAll ارتباط برقرار کنیم. برای این کار باید از Kohonen Synapse استفاده کنیم و Full Synapse جواب نخواهد داد. پس روی دکمه ی Kohonen Synapse کلیک کرده و بین لایه ی خطی و لایه ی WinnerTakeAll ارتباط ایجاد می کنیم.
در آموزش های بعدی فرق انواع سیناپس ها رو بررسی خواهیم کرد.آموزش شبکه

تا این لحظه شبکه باید به این شکل باشه. حالا می تونیم آموزش شبکرو شروع کنیم. برای این کار در منوی Tools بخش Control Panel رو انتخاب می کنیم. و در صفحه ی جدید learningRating و epochs و training pattern و learning رو به شکل زیر تغییر می دیم.

epochs تعداد دفعاتی که مرحله ی آموزش تکرار میشرو تعیین می کنه.
learningRate ضریبی هست که در یادگیری از اون استفاده می شه. بزرگ بودن اون باعث میشه میزان تغییر وزن نورون ها در هر مرحله بیشتر بشه و سرعت رسیدن به حالت مطلوب رو زیاد می کنه اما اگر مقدار اون خیلی زیاد شه شبکه واگرا خواهد شد.
training patterns هم تعداد الگو هایی که برای آموزش استفاده می شن رو نشون می ده که در این مثال ۱۲ عدد بود.
بعد از اینکه تمام تغییرات رو ایجاد کردیم دکمه ی Run رو می زنیم و منتظر می شیم تا ۱۰۰۰۰ بار عملیات یادگیری انجام بشه.

تبریک می گم! شما الان به کامپیوتر سه حرف A و C و Z رو یاد دادید!
اما خوب حالا باید ببینید کامپیوتر واقعا یاد گرفته یا نه.
برای این کار از یک لایه ی FileOutput استفاده می کنیم تا خروجی شبکرو داخل یک فایل ذخیره کنیم.
Properties لایه ی FileOutput باید بصورت زیر باشه:

همونطور که می بینید به عنوان fileName مقدار c:\output.txt رو دادیم. یعنی خروجی شبکه در این فایل ذخیره میشه.
حالا کافیه لایه ی WinnerTakeAll رو به لایه ی FileOutput متصل کنیم.
بعد از متصل کردن این دو لایه شکل کلی باید بصورت زیر باشه:

برای اینکه فایل خروجی ساخته بشه باید یک بار این شبکرو اجرا کنیم. برای این کار مجددا در منوی Tools بخش Control Panel رو انتخاب می کنیم و در اون learning رو False و epochs رو ۱ می کنیم تا شبکه فقط یک بار اجرا شه. پس از تغییرات این صفحه باید به شکل زیر باشه:

حالا با توجه به اینکه من اول چهار مثال A رو وارد کردم و بعد به ترتیب چهار مثال C و چهار مثال Z رو ببینیم خروجی این شبکه به چه شکل شده.
باور کردنی نیست! خروجی به این شکل در اومده:

1.0;0.0;0.0
1.0;0.0;0.0
1.0;0.0;0.0
1.0;0.0;0.0
0.0;1.0;0.0
0.0;1.0;0.0
0.0;1.0;0.0
0.0;1.0;0.0
0.0;0.0;1.0
0.0;0.0;1.0
0.0;0.0;1.0
0.0;0.0;1.0

همونطور که می بینید ۴ خط اول که مربوط به A هستن ستون اولشون ۱ هست و در چهار خط دوم ستون دوم و در چهار خط سوم ستون سوم!
این یعنی کامپیوتر بدون اینکه کسی به اون بگه کدوم مثال ها کدوم حرف هست خودش فهمیده و اون ها رو دسته بندی کرده.
سوال :  ممکنه چون پشت هم دادید مثال هر حرف رو اینطوری نشده؟
جواب : نه! کامپیوتر که نمی دونسته من می خوام مثال های هر حرف رو پشت سر هم بدم! من برای راحتی خودم این کار رو کردم. شما می تونی ورودی هاتو غیر مرتب بدی!
سوال : دلیل خاصی داره که در A ستون اول ۱ هست و …
جواب : نه! ممکن بود برای A ستون دوم ۱ بشه و یا هر حالت دیگه. شما اگر امتحان کنید ممکنه تفاوت پیدا کنه. اما مهم اینه در تمام A ها یک ستون خاص مقدارش ۱ و بقیه ی ستون ها مقدارشون صفر می شه. پس یعنی کامپیوتر تونسته به خوبی تقسیم بندی کنه.

حالا می خوایم شبکرو با سه مثال جدید تست کنیم که در مثال های آموزشی نبوده! برای این کار من با استفاده از برنامه ی تولید الگو ۳ مثال جدید درست می کنم و به عنوان فایل ورودی در شبکه فایل جدید رو انتخاب می کنم.
توی شکل زیر سه مثال جدید رو می تونید ببینید:

برای جذابیت علاوه بر این سه مثال ۲ مثال دیگه هم که حروف خاصی نیستند گذاشتم!

فایل خروجی این مثال ها از اینجا قابل دریافت هست.

خوب حالا بگذارید ببینیم کامپیوتر چه جوابی می ده. با توجه به اینکه اول مثال C بعد مثال Z و بعد مثال A رو وارد کردم. دو مثال بعدی هم به ترتیب مثال بد خط سمت چپ و مثال بد خط سمت راست هستند. و اما جواب:

0.0;1.0;0.0
0.0;0.0;1.0
1.0;0.0;0.0
0.0;0.0;1.0
0.0;1.0;0.0

کامپیوتر سه مورد اول رو به خوبی C و Z و A تشخیص داده. و دو مورد بد خط هم به ترتیب از چپ به راست Z و C تشخیص داده!
حتی برای انسان هم سخته فهمیدن اینکه مورد های چهارم و پنجم چی هستند اما اگر خوب دقت کنید می بینید به مواردی که کامپیوتر خروجی داده نزدیک تر هستند.
کامپیوتر شعور نداره! اما ما سعی کردیم طریقه ی عملکرد مغز رو به صورت خیلی ابتدایی و به ساده ترین نحو توش شبیه سازی کنیم! ”
تو  این مطلب دیدیم که کامپیوتر تونست بدون اینکه ما براش مثال هایی بزنیم و بگیم هر کدوم چه حرفی هستند و فقط با دادن تعداد دسته ها، مثال ها رو به سه دسته همونطوری که انسان ها تقسیم می کنند تقسیم کنه. همونطور که گفتیم به این نوع دسته بندی، دسته بندی Unsupervised میگن.
منبع

خوانش پلاک خودرو از تصاویر جاده‌ای

(پیاده سازی شده برای پلاک های ایرانی)

این الگوریتم (تشخیص پلاک خودرو) با نرم افزار MATLAB 2011 نوشته شده است برای خواندن پلاک که بدون نویز و خرابی هستند خوب جواب میدهد…البته دیتا بیس کاراکترها رو خودتون به راحتی میتوانید بیشتر کنید تا پاسخ دهی قویتر شود …فعلا فقط یک تصویر به عنوان آزمایش جهت تست برنامه قرار داده شده .

همچنین به علت ضیق وقت قسمت شناسای کاراکترها و تبدیل آنها به عدد و حروف فارسی رو قوی نکردم…شما میتونید این قسمت را برای جوابدهی بهتر دستکاری کنید… در ضمن اگر خواستین از نحوه فرمولبندی و کارکرد برنامه سر دربیارید حدود 20 صفحه هم گزارش تهیه شده ، فایل پاور پوینتی که برای ارائه پروژه تشخیص پلاک خودرو آماده شده نیز آپلود گردیده است.

فقط قبل از اجرای برنامه این مراحل رو طی کنید:
1- مسیر عکس خودرو(glx.jpg) رو وارد کنید
2-دیتا بیس (فایل زیپ) رو دانلود کنید
3-مسیر دیتا-بیس کاراکترها رو درست وارد کنید.
4-برنامه رو اجرا کنید-نتایج رو صفحه کامند matlab نمایش داده میشود.
5-هر جا خواستید از پشت دستور imshow و figure علامت % رو حذف کنید تا کارهای که روی تصویر انجام میشود رو مرحله به مرحله ببینید.
6-برنامه را اجرا کنید و نتایج را در صفحه متلب ببیند.

 

موضوع: آموزش تشخیص پلاک خودرو های ایرانی توسط نرم افزار متلب

تعداد صفحات پی دی اف : 18

تعداد صفحات پاور پوینت : 18

سورس کد : نرم افزار متلب Matlab

قیمت : رایگان

کلمه عبور فایل : behsanandish.com

 

دانلود

 

 

 

نکته : شرکت بهسان اندیش تولید کننده سامانه های هوشمند مفتخر به تولید یکی از دقیقترین و سریعترین سامانه های جامع کنترل تردد خودرو می باشد که می توانید جهت آشنایی با این محصول به لینک :سامانه جامع کنترل تردد خودرو بهسان(پلاک خوان) مراجعه فرمایید.

سورس برنامه در نرم افزار متلب:


clear all
close all
clc

p0=imread('E:\NIT\DIP\dip data proj\car\glx.jpg');
p=rgb2gray(p0);
p=im2double(p);

f=fspecial('gaussian');
pf=imfilter(p,f,'replicate');
%imshow(pf)
%figure
Pm=mean2(pf); %Average or mean of matrix elements
Pv=((std2(pf))^2); %the variance of an M-by-N matrix is the square of the standard deviation
T=Pm+Pv;

% taerife astane............................................
[m n]=size(pf);
for j=1:n
 for i=1:m
 if pf(i,j)&amp;amp;gt;T;
 pf(i,j)=1;
 else
 pf(i,j)=0;
 end
 end
end

ps=edge(pf,'sobel');
%imshow(ps)
%figure
pd=imdilate(ps,strel('diamond',1));
pe=imerode(pd,strel('diamond',1));
pl=imfill(pe,'holes');
[m n]=size(pl);

%barchasb gozary..............................................
pll=bwlabel(pl);
stat =regionprops(pll,'Area','Extent','BoundingBox','Image','Orientation','Centroid');
index = (find([stat.Area] == max([stat.Area]))); %meghdare barchasb dakhele bozorgtarin masahat ra mikhanad
ppout=stat(index).Image;
%imshow(ppout);
%figure

% biron keshidane mokhtasate pelak.............................
x1 = floor(stat(index).BoundingBox(1)); %shomare stone awalin pixel (B = floor(A) rounds the elements of A to the nearest integers less than or equal to A)
x2 = ceil(stat(index).BoundingBox(3)); %pahnaye abject dar sathe ofoghi(B = ceil(A) rounds the elements of A to the nearest integers greater than or equal to A)
y1 = ceil(stat(index).BoundingBox(2)); %shomare satre avalin pixel(B = ceil(A) rounds the elements of A to the nearest integers greater than or equal to A)
y2 = ceil(stat(index).BoundingBox(4)); %pahnaye abject dar sathe amodi(B = ceil(A) rounds the elements of A to the nearest integers greater than or equal to A)
bx=[y1 x1 y2 x2];
ppc=imcrop(p0(:,:,:),[x1,y1,x2,y2]);
%imshow(ppc)
%figure
ppg=imcrop(p(:,:),[x1,y1,x2,y2]);
%imshow(ppg)
%figure

%plate enhancment..............................................
ppcg=rgb2gray(ppc);
ppcg=imadjust(ppcg, stretchlim(ppcg), [0 1]); % specify lower and upper limits that can be used for contrast stretching image(J = imadjust(I,[low_in; high_in],[low_out; high_out]))
ppg=im2double(ppcg);
pb=im2bw(ppg);%im2bw(I, level) converts the grayscale image I to a binary image
%imshow(pb)
%figure

%rotate correction..............................................
if abs(stat(index).Orientation) &amp;amp;gt;=1; %The orientation is the angle between the horizontal line and the major axis of ellipse=angle
 ppouto=imrotate(ppout,-stat(index).Orientation); %B = imrotate(A,angle) rotates image A by angle degrees in a counterclockwise direction around its center point. To rotate the image clockwise, specify a negative value for angle.
 pbo=imrotate(pb,-stat(index).Orientation);
 angle = stat(index).Orientation;
else
 pbo=pb;
end;
%imshow(pbo)

pbod=imdilate(pbo,strel('line',1,0));
pbodl=imfill(pbod,'holes');
px = xor(pbodl , pbod);

pz= imresize(px, [44 250]); % 4*(57*11)=(chahar barabar size plake khodroye irani)

%barchasb zanye plak..........................................
stat1 = regionprops(bwlabel(pz,4),'Area','Image');
index1 = (find([stat1.Area] == max([stat1.Area])));
maxarea =[stat1(index1).Area];%braye hazfe neweshteye iran va khatahaye ehtemali
pzc=bwareaopen(pz,maxarea-200); %maxarea(1,1) meghdare structur ra adres dehi mikonad,va migoyad object haye ka mte z an ra hazf konad
%histogram plak......
%v=sum(pzc);
%plot(v);

%biron keshidan karakterha......................................
stat2=regionprops(pzc,'Area','BoundingBox','Image','Orientation','Centroid');
cx=cell(1,8);
for i=1:8
 x=stat2(i).Image;
 rx=imresize(x, [60 30]);
 %imshow(rx)
 %figure
 cx{1,i}=rx;
 %fx=mat2gray(cx{1,1});
 %imshow(cx{1,2})
 
 imwrite(rx,['E:\NIT\DIP\dip data proj\char\car\glx\' num2str(i) '.jpg']);
end

%khandane karakterha.........mini database1...................

for i=1:1
 for j=1:8
 temp=imread(['E:\NIT\DIP\dip data proj\char\car\glx\' num2str(j) '.jpg']);
 temp=im2bw(temp);
 nf1=temp.*cx{1,i};
 nf2=sum(sum(nf1));
 nf(j)=nf2/(sum(sum(temp)));
 mx=max(nf(j));
 
 
 if nf(1,1)== mx
 disp(1);
 else
 if nf(1,2)== mx
 disp(5);
 else
 if nf(1,3)== mx
 disp('j');
 else
 if nf(1,4)== mx
 disp(6);
 else
 if nf(1,5)== mx
 disp(3);
 else
 if nf(1,6)== mx
 disp(1);
 else
 if nf(1,7)== mx
 disp(7);
 else
 if nf(1,8)== mx
 disp(2);
 
 
 end
 end
 end
 end
 end
 end
 
 end
 
 end
 
 
 end
 
end