简体   繁体   English

如何使用Matlab检测视频中的某些运动点

[英]How to detect certain moving points in a video using Matlab

I have a video of moving hose in an experiment and I need to detect certain points in that hose and calculate the amplitude of their movements, I am using the code below and I am able to extract the required point using detectSURFFeatures, the function get many unnecessary points so I am using cuba = ref_pts.selectStrongest(5); 我有一个在实验中移动软管的视频,我需要检测该软管中的某些点并计算其运动幅度,我正在使用下面的代码,并且能够使用detectSURFFeatures提取所需的点,该函数获得了很多不必要的积分,所以我使用cuba = ref_pts.selectStrongest(5); to choose only five points, the problem is I can not get a function to put a bounding box about this 5 points and get their pixel values through the video, Kindly advice what functions can be used, thanks :) 只选择五个点,问题是我无法获得一个函数来围绕这五个点放置边框并通过视频获取其像素值,请告知可以使用哪些函数,谢谢:)

clear;
clc;
% Image aquisition from Video and converting into gray scale
vidIn = VideoReader('ItaS.mp4');

%% Load reference image, and compute surf features

ref_img = read(vidIn, 1);
ref_img_gray = rgb2gray(ref_img);
ref_pts = detectSURFFeatures(ref_img_gray);
[ref_features,  ref_validPts] = extractFeatures(ref_img_gray,  ref_pts);

figure; imshow(ref_img);
hold on; plot(ref_pts.selectStrongest(5));
cuba = ref_pts.selectStrongest(5);
stats1 = round(cuba.Location);
  • If you want to find the bounding box which covers all the five points you selected: stats1 now contains (x, y) coordinates of the selected 5 points. 如果要查找覆盖所有选定的五个点的边界框:现在,stats1包含选定的五个点的(x,y)坐标。 Find min and max for x and y coordinates. 查找x和y坐标的最小值和最大值。 min values of x and y gives you the starting point of the rectangle. x和y的最小值指定矩形的起点。 Width and height of the bounding box is now the difference of max and min in y and x directions. 现在,边界框的宽度和高度是y和x方向上的最大值和最小值之差。

  • If you want to extract the part of the original image inside the bounding box: just copy that part to another variable as you want. 如果要在边界框内提取原始图像的一部分:只需将该部分复制到另一个变量即可。 Consider the following example. 考虑以下示例。

    img2 = img1(y:h, x:w, :) img2 = img1(y:h,x:w,:)

Here, x and y are the x and y coordinates of the top left corner of the bounding box. 在此,x和y是边界框左上角的x和y坐标。 w and h are the width and height of the bounding box. w和h是边框的宽度和高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM