フィルターのクリア

I am trying to track face in a video using KLT in Matlab R2014b but I don't know how to remove this error "Expected ROI to be an array with number of elements equal to 4". Can any one help?

2 ビュー (過去 30 日間)
clc;
clear all;
faceDetector = vision.CascadeObjectDetector();
videoFileReader = vision.VideoFileReader('labedit.mp4');
videoFrame = step(videoFileReader);
bbox = step(faceDetector, videoFrame);
videoFrame = insertShape(videoFrame, 'Rectangle', bbox);
figure; imshow(videoFrame); title('Detected face');
bboxPoints = bbox2points(bbox(1, :)); disp(bboxPoints(1,1));
points = detectMinEigenFeatures(rgb2gray(videoFrame), 'ROI', bbox);
figure, imshow(videoFrame), hold on, title('Detected features'); plot(points);
pointTracker = vision.PointTracker('MaxBidirectionalError', 2);
points = points.Location; initialize(pointTracker, points, videoFrame);
videoPlayer = vision.VideoPlayer('Position',... [100 100 [size(videoFrame, 2), size(videoFrame, 1)]+30]);
oldPoints = points;
while ~isDone(videoFileReader)
videoFrame = step(videoFileReader);
[points, isFound] = step(pointTracker, videoFrame);
visiblePoints = points(isFound, :);
oldInliers = oldPoints(isFound, :);
if size(visiblePoints, 1) >= 2 % need at least 2 points
[xform, oldInliers, visiblePoints] = estimateGeometricTransform(...
oldInliers, visiblePoints, 'similarity', 'MaxDistance', 4);
bboxPoints = transformPointsForward(xform, bboxPoints);
bboxPolygon = reshape(bboxPoints', 1, []);
videoFrame = insertShape(videoFrame, 'Polygon', bboxPolygon, ...
'LineWidth', 2);
videoFrame = insertMarker(videoFrame, visiblePoints, '+', ...
'Color', 'white');
oldPoints = visiblePoints;
setPoints(pointTracker, oldPoints);
end
step(videoPlayer, videoFrame);
end
% Clean up
release(videoFileReader);
release(videoPlayer);
release(pointTracker);
  1 件のコメント
Adil Mukhtar
Adil Mukhtar 2015 年 2 月 26 日
I got this error when this line executes points = detectMinEigenFeatures(rgb2gray(videoFrame), 'ROI', bbox);

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

採用された回答

Dima Lisin
Dima Lisin 2015 年 2 月 28 日
Hi Adil,
It looks like the face detector did not detect anything. You have to check whether bbox is empty.
  3 件のコメント
Muhammad Irfan
Muhammad Irfan 2017 年 3 月 28 日
編集済み: Muhammad Irfan 2017 年 3 月 28 日
Any positive response from anyone Jean-Sébastien Herbaux? I have faced same error
RENFIX
RENFIX 2018 年 3 月 15 日
You must resize image or video input and then run again

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by