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

조회 수: 1 (최근 30일)
Abhinav Rai
Abhinav Rai 2016년 4월 22일
댓글: Abhinav Rai 2016년 4월 22일
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.

답변 (1개)

J. Webster
J. Webster 2016년 4월 22일
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
J. Webster
J. Webster 2016년 4월 22일
yep, hog returns a row, it may be as simple as transposing the return value from hog...
T(temp,:) = transpose(hog_feature_vector(J));

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by