フィルターのクリア

transform Points Forward with cell

1 回表示 (過去 30 日間)
antonio
antonio 2014 年 6 月 18 日
コメント済み: Dima Lisin 2014 年 7 月 14 日
Hi, I need a help to apply a transformation to a cell array that contains the bboxPolygon values..here's the code:
%% Loop through video while ~isDone(videoReader) % get the next frame videoFrame = step(videoReader);
% Use pointTracker to track feature points
for i = 1:N
[punti{i},validity] = step(tracker{i},videoFrame);
% Keep only the valid points and discard the rest
visiblePoints{i} = punti{i}(validity,:);
oldInliers{i} = oldPoints{i}(validity,:);
[xform, oldInliers{i}, visiblePoints{i}] = estimateGeometricTransform(...
oldInliers{i}, visiblePoints{i}, 'similarity', 'MaxDistance', 4);
end
% Apply the transformation to the bounding box
for i = 1:P
[bbcell{i}(1:2:end),bbcell{i}(2:2:end)]=transformPointsForward(xform, bbcell{i}(1:2:end)...
,bbcell{i}(2:2:end));
end
for i = 1:N
videoFrame = insertShape(videoFrame, 'Polygon',bbcell{i});
videoFrame = insertMarker(videoFrame, visiblePoints{i}, '+', ...
'Color', 'white');
% % Save the new state of the point tracker
% oldPoints{i} = visiblePoints{i};
% setPoints(tracker{i}, oldPoints{i});
% Display output
step(videoPlayer, videoFrame);
end
end
______________________________________
but when I start this code the shapes run away from the video clip or move themselves in wrong direction! Thanks a lot for helping me!

回答 (4 件)

Dima Lisin
Dima Lisin 2014 年 6 月 30 日
編集済み: Dima Lisin 2014 年 6 月 30 日
I would try capturing the output of transformPointsForward() into a temporary variable, and then assigning that to bbcell{i}.
On a different note, it looks like you are trying to track multiple objects. A better way to do that is to use a single vision.PointTracker, rather than multiple ones. The reason is that each of your point tracker objects will pre-process the frame exactly the same way. Using one point tracker will only pre-prosses the frame once, eliminating this wasted computation. However, that means you would need to concatenate all your points into a single Mx2 matrix, and you would need to maintain an Mx1 array of indices to keep track of which point belongs to which object.

antonio
antonio 2014 年 7 月 1 日
Yes but I'm not able to do this with the code in matlab...can you help me? And I don't understand what you mean about to use a single vision.PointTracke. Thanks a lot for the helps!
  1 件のコメント
Dima Lisin
Dima Lisin 2014 年 7 月 1 日
Can you try this:
[x, y] = transformPointsForward(xform, bbcell{i}(1:2:end),...
bbcell{i}(2:2:end));
bbcell{i}(1:2:end) = x;
bbcell{i}(2:2:end) = y;
As to your second question, you seem to have a cell array of point trackers, one for each object, correct? Instead, you should only use one point tracker for tracking all the points from all the objects.

サインインしてコメントする。


antonio
antonio 2014 年 7 月 2 日
I tried to use this solution but the rotation of bounding box is casual...I'm going crazy!! ahahah

antonio
antonio 2014 年 7 月 2 日
I'm sending you my full code so you can find some errors...when I'm using one pointTracker, I get this:
"Index exceeds matrix dimensions.
Error in demo (line 77) oldInliers{i} = oldPoints{i}(isFound, :);" ......
  1 件のコメント
Dima Lisin
Dima Lisin 2014 年 7 月 14 日
Check out this example.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTracking and Motion Estimation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by