Selecting ROI doesn't work
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I am using code written by someone who doesn't work with me anymore. When I run the code, it prompts me to select one of my regions of interest and opens the image from a video file. When I select the region and complete the polygon, nothing happens. Matlab says "busy" and the command window still tells me to select the region of interest. What is supposed to happen is that the program prompts me to choose another region (this is an elevated plus maze, so it has two 'open' arms, and I need to select both of them. This is the relevant chunk of code.
for i = 1:length(nameFolds)
cd(cell2mat(nameFolds(i)));
ToDoList = dir('*.mp4');
ToDo = {ToDoList.name}';
mov = VideoReader(char(ToDo));
imag = read(mov, 60);
imshow(imag);
title(nameFolds(i));
disp('Please draw the boundaries of one of the OPEN arms');
Opens(i,:,:) = roipoly;
disp('Now please draw the boundaries of the other OPEN arm');
Opens(i,:,:) = squeeze(Opens(i,:,:)) + roipoly;
cd(home);
end
It keeps getting stuck on the first "please draw the boundaries". I also have multiple videos in this folder, and the program is supposed to go ahead to the next video automatically. I've used a similar program to score open field videos before which has a similar chunk of code, and it worked fine.
for i = 1:length(nameFolds)
cd(cell2mat(nameFolds(i)));
ToDoList = dir('*.mp4');
ToDo = {ToDoList.name}';
mov = VideoReader(char(ToDo));
imag = read(mov, 60);
imshow(imag);
title(nameFolds(i));
disp('Please drag a rectangle over the ENTIRE arena');
fullsquare(i,:) = getrect;
square(i,1) = (fullsquare(i,1)) + fullsquare(i,3)/ratio;
square(i,2) = (fullsquare(i,2)) + fullsquare(i,4)/ratio;
square(i,3) = fullsquare(i,1) + fullsquare(i,3) - (fullsquare(i,3)/ratio);
square(i,4) = fullsquare(i,2) + fullsquare(i,4) - (fullsquare(i,4)/ratio);
x(i,:) = [square(i,1),square(i,3), square(i,3), square(i,1), square(i,1)];
y(i,:) = [square(i,2), square(i,2),square(i,4), square(i,4), square(i,2)];
hold on;
plot(x(i,:), y(i,:), 'r*', 'LineWidth', 2, 'MarkerSize', 15);
plot(x(i,:), y(i,:), 'b-');
hold off;
cd(home);
end
I didn't write this code and I know very little about Matlab, but this other program worked well for me in the past and I can't see anything different with this code. What should I try to force Matlab to move to the next line of code?
0 commentaires
Réponses (1)
Ayush Bansal
le 20 Nov 2020
After selecting the area you need to create the mask by double-clicking, or by right-clicking inside the region and selecting Create mask from the context menu.
0 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!