Изменения

Перейти к: навигация, поиск

Анализ видео

8842 байта добавлено, 20:46, 28 января 2021
Источники информации
{{В разработке}}
 
'''Трекинг''' — определение местоположения объекта (нескольких объектов) во времени.
Задача отслеживания объектов на видео является одной из самых интересных задач в информационных технологиях. На первый взгляд, видеопоток можно рассматривать как последовательность отдельных кадров, поэтому применимы многие алгоритмы, использующиеся для обработки обычных изображений. Сегодня к задаче распознавания объектов также широко применяются методы классификации, а именно, строятся системы, которые определяют к какому классу (изображение содержит объект или изображение не содержит объект) относится изображение.
С другой стороны, видеопоток обладает свойством связности: каждый последующий кадр не сильно отличается от предыдущего, поэтому возможно применение алгоритмов, основанных на этом свойстве. Одной из интересных задач в этой области является трекинг перемещений объектов на видео. В работе <ref>[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.115.2861&rep=rep1&type=pdf [1]A Survey on Visual Surveillance of Object Motion and Behaviors] </ref> алгоритмы отслеживания разделены на четыре основные категории: отслеживание областей, отслеживание по активному контуру, отслеживание по характерным признакам, отслеживание по модели.
## Ищем особенности (Harris corners)
## Если точка не на коже, то удаляем её
 
'''Input''' : Pretrained CNN filters {<tex>w_1</tex>,..., <tex>w_5</tex>}
Initial target state <tex>x_1</tex>
'''Output''': Estimated target states <tex>x^*_t</tex>
1: Randomly initialize the last layer <tex>w_6</tex>.
2: Train a bounding box regression model.
3: Draw positive samples <tex>S^+_1</tex> and negative samples <tex>S^-_1</tex>.
4: Update {<tex>w_4, w_5, w_6</tex>} using <tex>S^+_1</tex> and <tex>S^-_1</tex>;
5: <tex>T_s</tex> <tex>\leftarrow</tex> {1} and <tex>T_l</tex> <tex>\leftarrow</tex> {1}.
6: '''repeat'''
7: Draw target candidate samples <tex>x^i_t</tex>;
8: Find the optimal target state <tex>x^*_t</tex> by Eq. (1).
9: '''if''' <tex>f^+(x^*_t)</tex> > 0.5 '''then'''
10: Draw training samples <tex>S^+_t</tex> and <tex>S^-_t</tex>.
11: <tex>T_s \leftarrow T_s</tex> <tex>\cup</tex> {<tex>t</tex>}, <tex>T_l \leftarrow T_l</tex> <tex>\cup</tex> {<tex>t</tex>}.
12: '''if''' |<tex>T_s</tex>| > <tex>\tau_s</tex> '''then''' <tex>T_s \leftarrow T_s</tex> \ {<tex>min_{\upsilon \in T_s} \upsilon</tex>}.
13: '''if''' |<tex>T_l</tex>| > <tex>\tau_l</tex> '''then''' <tex>T_l \leftarrow T_l</tex> \ {<tex>min_{\upsilon \in T_l} \upsilon</tex>}.
14: Adjust <tex>x^*_t</tex> using bounding box regression.
15: '''if''' <tex>f^+(x^*_t)</tex> < 0.5 '''then'''
16: Update {<tex>w_4, w_5, w_6</tex>} using <tex>S^+_{\upsilon \in T_s}</tex> and <tex>S^-_{\upsilon \in T_s}</tex>.
17: '''else''' '''if''' <tex>t</tex> mod 10 = 0 '''then'''
18: Update {<tex>w_4, w_5, w_6</tex>} using <tex>S^+_{\upsilon \in T_l}</tex> and <tex>S^-_{\upsilon \in T_l}</tex>.
19: '''until''' end of sequence
 
(1): <tex>x^* = \underset{x^i}{\arg\max} f^+(x^i)</tex>.
=== Multiple object tracking ===
### Элемент с максимальной вероятностью
## Восстановление положения на промежуточных кадрах
 
 
 
===== Multiple Object Tracking Tutorial =====
 
function MultipleObjectTrackingExample()
// Create objects used for reading video and displaying the results.
videoObjects = setupVideoObjects('atrium.mp4');
// Create objects used for detecting objects in the foreground of the video.
minBlobArea = 400; % Minimum blob size, in pixels, to be considered as a detection
detectorObjects = setupDetectorObjects(minBlobArea);
 
===== Create the Multi-Object Tracker =====
 
tracker = multiObjectTracker(...
'FilterInitializationFcn', @initDemoFilter, ...
'AssignmentThreshold', 30, ...
'DeletionThreshold', 22, ...
'ConfirmationThreshold', [6 10] ...
);
 
===== Define a Kalman 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
// 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 =====
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 =====
 
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 =====
 
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', [6, 6]));
mask = imclose(mask, strel('rectangle', [50, 50]));
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 =====
 
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
end
 
 
=== Основные трудности ===
== Список литературы См. также==*[[Компьютерное зрение]]*[[Вырезание объекта на изображении]]*[[Сегментация изображений]]== Примечания ==<references/>== Источники информации ==
1. [http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.115.2861&rep=rep1&type=pdf Hu W. M., Tan T. N., Wang L., Maybank S. A survey of visual surveillance of object motion and behaviors // IEEE Transactions on System, Man, and Cybernetics (T-SMC), Part C. – 2004. Vol. 34(3). – P. 334-352.]
3. [https://compscicenter.ru/media/courses/2018-spring/spb-images-and-video-2/slides/images_and_video_2_lecture_080518.pdf Анализ изображений и видео. Часть 2]
 
4. [https://arxiv.org/pdf/1510.07945.pdf Learning Multi-Domain Convolutional Neural Networks for Visual Tracking]
 
5. [https://www.mathworks.com/help/driving/examples/multiple-object-tracking-tutorial.html Multiple object tracking tutorial]
 
{{В разработке}}
174
правки

Навигация