"Dot indexing is not supported for variables of this type." error in reading VideoReader Object by its index?

10 vues (au cours des 30 derniers jours)
I am working in video shot boundary detection, for that I need to read a specific video frame by its index, But in such cases when the video is read by its index in the main file, it runs perfectly but when it is ran in a seperate function, It gives an error "Dot indexing is not supported for variables of this type. in matlab", I am providing the code for which it is givning the error.
if class1(1)>2
A=final(class1,V); % class1 is a frame transition numbers
class1 = class1(2:length(class1));
function A2 = final(C,V)
count = 1; th1 = 0.2; th2 =1;th3= 1;
for i = 1:length(C)
St = StdDifference(V,C(i));
if (St(2) > th1 && St(3)< th1 && St(1) < th1)
A2(count) = C(i);
count = count + 1;
function d = StdDifference(V,i)
count = 1;
for j=i-2:i+1
I = read(V,j);% This line the code gives error of "Dot indexing is not supported for variables of this type" I cannot understand why?
J = read(V,j+1);
Ir_std = std2(I(:,:,1));
Ig_std = std2(I(:,:,2));
Ib_std = std2(I(:,:,3));
Jr_std = std2(J(:,:,1));
Jg_std = std2(J(:,:,2));
Jb_std = std2(J(:,:,3));
d(count) = sqrt((Ir_std-Jr_std)^2+(Ig_std-Jg_std)^2+(Ib_std-Jb_std)^2);
count = count + 1;
  5 commentaires
Jan le 5 Mai 2022
Modifié(e) : Jan le 6 Mai 2022
@INDRANATH ROY: I've tried to format the code properly.
"Dot indexing is not supported for variables of this type" I cannot understand why?" - I cannot understand this also, because this line does not contain any dot. So please post the complete error message, which should tell also, in which line the error occurs.
Walter Roberson
Walter Roberson le 5 Mai 2022
If the VideoReader call failed then that read() might be the first place affected.
Also I wonder if there is additional code beyond what was posted, with that additional code happening to have a "clear all"

Connectez-vous pour commenter.

Réponses (1)

yanqi liu
yanqi liu le 7 Mai 2022
yes,sir,may be use VideoReader to make video to frame image file list,and then use the images to analysis,such as
function nFrames = GetVideoImgList(videoFilePath)
xyloObj = VideoReader(videoFilePath);
nFrames = xyloObj.NumberOfFrames;
vidHeight = xyloObj.Height;
vidWidth = xyloObj.Width;
[pathstr, name, ext] = fileparts(videoFilePath);
video_imagesPath = fullfile(pwd, sprintf('%s_images', name));
if ~exist(video_imagesPath, 'dir')
files = dir(fullfile(video_imagesPath, '*.jpg'));
if length(files) == nFrames
h = waitbar(0, '', 'Name', 'process...');
steps = nFrames;
for step = 1 : nFrames
temp = read(xyloObj, step);
temp_str = sprintf('%s\\%04d.jpg', video_imagesPath, step);
imwrite(temp, temp_str);
waitbar(step/steps, h, sprintf('%d%%', round(step/nFrames*100)));


En savoir plus sur Read, Write, and Modify Image dans Help Center et File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by