【发布时间】:2016-09-26 06:45:20
【问题描述】:
这是一帧:
它是黑白剪影形式。 (Man-White,Rest-Black)。这个人从第一帧走到最后一帧,从右到左。我希望他始终处于中心位置,但他应该看起来在移动。这样看起来他正在跑步机上行走。
我做了裁剪部分。我不知道如何在某一点修复质心,这样人就不会出现振动。这是到目前为止的代码
clc;
close all;
clear all;
video_read = VideoReader('D:\PROJECT M.Tech\Databases\Videos\DATA SET B\009\bg-01\090\090.avi');
numframes = video_read.NumberOfFrames;
for j= 1:numframes
frame=read(video_read,j);
im=rgb2gray(frame);
im = bwareaopen(im,50);
siz=size(im); % image dimensions
% Label the disconnected foreground regions (using 8 conned neighbourhood)
L=bwlabel(im,8);
% Get the bounding box around each object
bb=regionprops(L,'BoundingBox');
% Crop the individual objects and store them in a cell
n=max(L(:)); % number of objects
ObjCell=cell(n,1);
for i=1:n
% Get the bb of the i-th object and offest by 2 pixels in all
% directions
bb_i=ceil(bb(i).BoundingBox);
idx_x=[bb_i(1)-2 bb_i(1)+bb_i(3)+2];
idx_y=[bb_i(2)-2 bb_i(2)+bb_i(4)+2];
if idx_x(1)<1, idx_x(1)=1; end
if idx_y(1)<1, idx_y(1)=1; end
if idx_x(2)>siz(2), idx_x(2)=siz(2); end
if idx_y(2)>siz(1), idx_y(2)=siz(1); end
% Crop the object and write to ObjCell
im=L==i;
ObjCell{i}=im(idx_y(1):idx_y(2),idx_x(1):idx_x(2));
end
% Visualize the individual objects
figure
for i=1:n
subplot(1,n,i)
imshow(ObjCell{i})
end
%bbox=regionprops(frame_im,'BoundingBox')
F(j)=getframe;
end
【问题讨论】:
-
你已经尝试或想过做什么?
-
给我 5 个工程师和一个月,为它写一个漂亮的算法,并在科学期刊上发表
-
@GameOfThrows 我想到了使用 BoundingBox 和 Centroid。即将这个人包围在一个边界框中,并试图将他的质心保持在每一帧的中间。
-
@Anuragkush 这听起来是一个合理的起点。你为什么不试试看,让我们知道它是怎么回事?
-
@GameOfThrows 检查我的编辑。