Extract color map from a video ?
4 views (last 30 days)
Show older comments
Hi,
I try to follow this steps that I see in Matlab conference: https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/company/events/conferences/matlab-conference-australia/2017/proceedings/detecting-moving-objects-in-aerial-imagery-captured-from-unmanned-aerial-vehicles.pdf
And there I try to extract some points from a video using "detectSURFFeatures", for this case I use rgb2gray. But after all process, I get a modified image, named with '481x641xsingle' proprieties, but to use "foreground = step(foregroundDetector, videoFrame);" I need to transform it in '480x640x3xsingle', but I can't extract the color map from the video. How can I do that?
there is my code:
v = vision.VideoFileReader('C:\Users\rafae\Desktop\DRONE desafio street car.mp4');
%%Create Video Player
videoPlayer = vision.VideoPlayer;
fgPlayer = vision.VideoPlayer;
%%Create Foreground Detector (Background Subtraction)
foregroundDetector = vision.ForegroundDetector('NumGaussians', 3,'NumTrainingFrames', 50);
for i = 1:30
vidFrame = step(v);
I2 = rgb2gray(vidFrame);
point2 = detectSURFFeatures(I2);
[features2,valid_points2] = extractFeatures(I2,point2);
if(rem(i,2)==0)
if(rem(i,2)==0)
vidFrame = step(v);
I1=rgb2gray(vidFrame);
point1=detectSURFFeatures(I1);
[features1,valid_points1] = extractFeatures(I1,point1);
% imshow(I1); hold on;
% plot(point1.selectStrongest(10));
else
vidFrame = step(v);
I2=rgb2gray(vidFrame);
point2=detectSURFFeatures(I2);
[features2,valid_points2] = extractFeatures(I2,point2);
% imshow(I2); hold on;
% plot(point2.selectStrongest(10));
end
indexPairs = matchFeatures(features1,features2);
matchedPoints1 = valid_points1(indexPairs(:,1),:);
matchedPoints2 = valid_points2(indexPairs(:,2),:);
%figure; showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2);
pointTracker = vision.PointTracker;
movingPoints = matchedPoints2.Location;
fixedPoints = matchedPoints1.Location;
tform = fitgeotrans(movingPoints,fixedPoints,'projective');
B = imwarp(I2,tform);
%frameDifferences = diff(framesWithWhiteBlobs);
ind2gray
videoFrame = step(B); %here is my error
else
videoFrame = step(v);
end
foreground = step(foregroundDetector,videoFrame);
end
0 Comments
Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!