如何在转换为帧的视频中使用 projective2d 和多边形绘制形状
how to draw a shape using projective2d and a polygon in a video converted into frames
您好,我正在尝试从相机中提取帧并在获取的帧中应用 SURF 检测。除了我无法在检测到的对象周围绘制形状或多边形外,该过程运行良好。在估计几何变换中,我能够得到 projective2d tform。但是当我试图在检测到的对象周围绘制一个框多边形时,我看不到任何多边形或形状。有时多边形来了又消失了。有时检测到的对象周围的多边形不准确。
tform和polygon的代码如下:
[tform, ~, ~,status] = ...
estimateGeometricTransform(matchedBoxPoints, matchedScenePoints, 'projective');
%box Polygon
boxPolygon = [1, 1;... % top-left
size(boxImage, 2), 1;... % top-right
size(boxImage, 2), size(boxImage, 1);... % bottom-right
1, size(boxImage, 1);... % bottom-left
1, 1];
newBoxPolygon = transformPointsForward(tform, boxPolygon);
% Display the frame
imshow(data)
hold on;
line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y');
title('Detected Box');
refreshdata;
如果多边形消失或不准确,可能是因为您没有找到足够的匹配项,或者您的匹配项不正确。您可能想看看是否是这种情况,如果是,请尝试调整 matchFeatures
函数的参数。
您也可以使用insertShape
将多边形直接绘制到图像像素中。但同样,这假设您具有良好的特征匹配,并且您已经计算出正确的转换。
您好,我正在尝试从相机中提取帧并在获取的帧中应用 SURF 检测。除了我无法在检测到的对象周围绘制形状或多边形外,该过程运行良好。在估计几何变换中,我能够得到 projective2d tform。但是当我试图在检测到的对象周围绘制一个框多边形时,我看不到任何多边形或形状。有时多边形来了又消失了。有时检测到的对象周围的多边形不准确。
tform和polygon的代码如下:
[tform, ~, ~,status] = ...
estimateGeometricTransform(matchedBoxPoints, matchedScenePoints, 'projective');
%box Polygon
boxPolygon = [1, 1;... % top-left
size(boxImage, 2), 1;... % top-right
size(boxImage, 2), size(boxImage, 1);... % bottom-right
1, size(boxImage, 1);... % bottom-left
1, 1];
newBoxPolygon = transformPointsForward(tform, boxPolygon);
% Display the frame
imshow(data)
hold on;
line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y');
title('Detected Box');
refreshdata;
如果多边形消失或不准确,可能是因为您没有找到足够的匹配项,或者您的匹配项不正确。您可能想看看是否是这种情况,如果是,请尝试调整 matchFeatures
函数的参数。
您也可以使用insertShape
将多边形直接绘制到图像像素中。但同样,这假设您具有良好的特征匹配,并且您已经计算出正确的转换。