Azzera filtri
Azzera filtri

I am getting Subscripted assignment dimension mismatch in the following code.

1 visualizzazione (ultimi 30 giorni)
fprintf('Extracting features... ');
tic;
n1=145;%set n1 value
dim=120;%set Dimension
temp=0;
for a=1:n1
s = strcat('C:\Users\om\Desktop\abhinav\a (', int2str(a), ').jpg');
%I = imresize(imread(s),[512 NaN]);
I=imread(s);
faceDetector = vision.CascadeObjectDetector();
bbox = step(faceDetector, I);
fprintf('Total %d faces found. Beginning comparison.. \n', size(bbox,1));
for b=1:size(bbox,1);
fprintf('Face %d -> ', b);
X = imcrop(I,bbox(b,:));
temp=temp+1;
I1 = imresize(X,[dim dim]);
J = rgb2gray(I1);
T(temp,:) = hog_feature_vector(J);
fprintf('Yo');
end
end
The error is in "T(temp,:) = hog_feature_vector(J);" I have hog_feature_vecture(IMG) already made and its working perfect. Please help. Edit 1. Attached hog_feature_vector.m . Sorry for not attaching earlier.

Risposte (1)

J. Webster
J. Webster il 22 Apr 2016
Gonna be hard to troubleshoot this without seeing what hog_features_vector() returns, or what the dimensions of T are.
my guess is that you are trying to insert a row where you should be inserting a column, of vice versa.
for example,
x = rand(5,10);
y = rand(10,1);
x(1,:) = y; %No error, all is ok since the second dimension of x matches the length 0f y
x(:,1) = y; %Error, subscripted assignment mismatch... because the 1st dimension of x is ony 5
  3 Commenti
J. Webster
J. Webster il 22 Apr 2016
yep, hog returns a row, it may be as simple as transposing the return value from hog...
T(temp,:) = transpose(hog_feature_vector(J));

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by