error: Reference to non-existent field 'opts'.

1 view (last 30 days)
hello, error occurs when I run demo_im2mcg.m:
Reference to non-existent field 'opts'.
Error in edgesDetect (line 33)
opts=model.opts; opts.nTreesEval=min(opts.nTreesEval,opts.nTrees);
Error in img2ucms>img2ucm (line 91)
[E,~,O] = edgesDetect( I, model );
Error in img2ucms>img2ucm_scale (line 75)
[ucm2, times] = img2ucm(I, model, param.mult_Pb, param.sat_sPb, param.nvec, param.dthresh, param.ic_gamma);
Error in img2ucms (line 56)
[ucms{s}, times] = img2ucm_scale(I, model, param);
Error in im2mcg (line 63)
[ucm2] = img2ucms(image, sf_model, scales);
Error in demo_im2mcg (line 10)
[candidates_scg, ucm2_scg] = im2mcg(I,'fast');
demo_im2mcg.m is following:
%% Demo to show the results of MCG
clear all;close all;home;
% Read an input image
I = imread(fullfile(root_dir, 'demos','101087.jpg'));
tic;
% Test the 'fast' version, which takes around 5 seconds in mean
[candidates_scg, ucm2_scg] = im2mcg(I,'fast');
toc;
tic;
% Test the 'accurate' version, which tackes around 30 seconds in mean
[candidates_mcg, ucm2_mcg] = im2mcg(I,'accurate');
toc;
%% Show UCM results (dilated for visualization)
figure;
subplot(1,3,1)
imshow(I), title('Image')
subplot(1,3,2)
imshow(imdilate(ucm2_scg,strel(ones(3))),[]), title('Fast UCM (SCG)')
subplot(1,3,3)
imshow(imdilate(ucm2_mcg,strel(ones(3))),[]), title('Accurate UCM (MCG)')
%% Show Object Candidates results and bounding boxes
% Candidates in rank position 11 and 12
id1 = 11; id2 = 12;
% Get the masks from superpixels and labels
mask1 = ismember(candidates_mcg.superpixels, candidates_mcg.labels{id1});
mask2 = ismember(candidates_mcg.superpixels, candidates_mcg.labels{id2});
% Bboxes is a matrix that contains the four coordinates of the bounding box
% of each candidate in the form [up,left,down,right]. See folder bboxes for
% more function to work with them
% Show results
figure;
subplot(1,3,1)
imshow(I), title('Image')
subplot(1,3,2)
imshow(mask1), title('Candidate + Box')
hold on
plot([candidates_mcg.bboxes(id1,4) candidates_mcg.bboxes(id1,4) candidates_mcg.bboxes(id1,2) candidates_mcg.bboxes(id1,2) candidates_mcg.bboxes(id1,4)],...
[candidates_mcg.bboxes(id1,3) candidates_mcg.bboxes(id1,1) candidates_mcg.bboxes(id1,1) candidates_mcg.bboxes(id1,3) candidates_mcg.bboxes(id1,3)],'r-')
subplot(1,3,3)
imshow(mask2), title('Candidate + Box')
hold on
plot([candidates_mcg.bboxes(id2,4) candidates_mcg.bboxes(id2,4) candidates_mcg.bboxes(id2,2) candidates_mcg.bboxes(id2,2) candidates_mcg.bboxes(id2,4)],...
[candidates_mcg.bboxes(id2,3) candidates_mcg.bboxes(id2,1) candidates_mcg.bboxes(id2,1) candidates_mcg.bboxes(id2,3) candidates_mcg.bboxes(id2,3)],'r-')
edgesDetect function is following:
Copyright code removed, the function edgesDetect is available here:
can anybody help to solve it? thank you !
  2 Comments
Adam Danz
Adam Danz on 21 Nov 2019
If you edit your question and format your code by selecting the code and using the [>] button, it will be much easier to read.
Adam Danz
Adam Danz on 21 Nov 2019
I don't see where edgesDetect is being called or where the 2nd input 'model' is produced. Obviously 'model' should be a structure with a field "opts" and this variable is likely produced by another function but we don't see that part.

Sign in to comment.

Accepted Answer

Ridwan Alam
Ridwan Alam on 21 Nov 2019
Edited: Ridwan Alam on 21 Nov 2019
Updated Solution:
inside im2mcg.m, (line 52)
sf_model = loadvar(fullfile(mcg_root, 'datasets', 'models', 'sf_modelFinal.mat'),'model');
change that to:
sf_model = load(fullfile(mcg_root, 'datasets', 'models', 'sf_modelFinal.mat'));
sf_model = sf_model.model;
%% old conversation
Can you double check your downloaded version of the model?
This one has model.opts:
  11 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!