Effacer les filtres
Effacer les filtres

Vibration frequency measurement by video

4 vues (au cours des 30 derniers jours)
大空
大空 le 28 Juin 2023
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

Réponses (0)

Catégories

En savoir plus sur 振動解析 dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!