Vibration frequency measurement by video

조회 수: 3 (최근 30일)
大空
大空 2023년 6월 28일
I have a robot that uses a vibration motor to move forward using the force of vibration. I would like to take video of the leg vibrations and measure the vibration frequency. I think there are three steps: reading the video, extracting information from the frame, and calculating the number of vibrations. I would appreciate it if you could tell me how to input information such as color and shape.
videoFile = 'videoFile.mp4';
v = VideoReader(videoFile);
legPositions = [];
while hasFrame(v)
frame = readFrame(v); % フレームを読み込む
gray = rgb2gray(frame); % RGB画像をグレースケール画像に変換
% 白色の脚に相当するグレースケールの範囲を指定
grayThresholdLow = 200; % グレースケールの下限
grayThresholdHigh = 255; % グレースケールの上限
% グレースケールに基づいて脚の位置を二値化
legMask = (gray > grayThresholdLow) & (gray < grayThresholdHigh);
% 連結成分のラベリングを行い、各オブジェクトを識別
labeledImage = bwlabel(legMask);
% 各オブジェクトの位置(重心)を計算
properties = regionprops(labeledImage, 'Centroid');
centroids = cat(1, properties.Centroid);
legPositions = [legPositions; centroids]; % 脚の位置を保存
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB 入門에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!