Closed verpeutlab closed 2 years ago
I suspect something is either wrong with the frameInds variable, or you are using hardware that the precompiled mmread binaries do not support. I think newer Macs have this problem, for instance.
Given that things were running fine before, I suspect its just the frameInds, which could also explain the first error. Are your frame inds all positive integers <= the length of the video?
Its also concerning that the params are empty. The example.m script isnt intended to be a standalone, so I'd recommend running cells individually to get things working on your setup.
Thank you for letting me know about this! The values of frameInds+1
, which is in the line videos{nVid} = readFrames(vidPaths{nVid}, frameInds+1);
in example.m
has values from 1 to 100.
I also wanted to let you know that a figure appears when I have been running the example.m
script, and this figure plays the first 100 frames that I should be labeling as a video. I have included a picture of the figure below. This figure did not appear when I ran before I started having issues with error messages. Could you tell me why this figure is appearing instead of the figures needed for me to label the mouse in Label3D?
I now experience this same error when I run the script on both the markerless_mouse_1 data and on my own data. Perhaps another issue could be the value of nVid. In both the demo data and in this set of data that I am running, I believe nVid should be six, but it is only equal to 1.
I do not think hardware should be an issue, as it was running successfully in the past. The computer is using Windows 10, and version 1909 with OS Build 18363.1916
Please provide the script.
Here is the script. It is currently set to run the markerless_mouse_1 demo.
`clear all close all; addpath(genpath('deps')) addpath(genpath('skeletons')) danncePath = 'C:\Users\verpeutlab\Desktop\DANNCE';
projectFolder = fullfile(danncePath,'demo\markerless_mouse_1'); calibPaths = collectCalibrationPaths(projectFolder); params = cellfun(@(X) {load(X)}, calibPaths);
%% Load the videos into memory vidName = '0.mp4'; vidPaths = collectVideoPaths(projectFolder,vidName); videos = cell(6,1); sync = collectSyncPaths(projectFolder, '*.mat'); sync = cellfun(@(X) {load(X)}, sync);
% In case the demo folder uses the dannce.mat data format. if isempty(sync) dannce_file = dir(fullfile(projectFolder, '*dannce.mat')); dannce = load(fullfile(dannce_file(1).folder, dannce_file(1).name)); %load(fullfile(dannce_file(1).folder, dannce_file(2).name)); sync = dannce.sync; params = dannce.params; end
framesToLabel = 1:100; for nVid = 1:numel(vidPaths) frameInds = sync{nVid}.data_frame(framesToLabel); videos{nVid} = readFrames(vidPaths{nVid}, frameInds+1); end
%% Get the skeleton skeleton = load('skeletons/mouse22'); % skeleton = load('com');
%% Start Label3D close all labelGui = Label3D(params, videos, skeleton); `
Thanks for sharing the script.
I just ran it on a win10 system (replacing only the danncePath with my local folder) and it works as expected. Perhaps your demo video files are somehow corrupted, or you are using a different version of Label3D? I would redownload the demo or reinstall/update Label3D and try again.
Thank you! I was able to get the script to work with markerless_mouse_1 demo data.
Here is the script that is causing Matlab to quit. I have loaded in the sync and params cells for data that is using three cameras.
`clear all close all; addpath(genpath('deps')) addpath(genpath('skeletons')) danncePath = 'C:\Users\verpeutlab\Desktop\DANNCE';
projectFolder = fullfile(danncePath,'social_mice_demo\C_26\L');
params = cell (3,1); params{1} = importdata('C:/Users/verpeutlab/Desktop/DANNCE/social_mice_demo/C_26/L/hires_cam1_params.mat'); params{2} = importdata('C:/Users/verpeutlab/Desktop/DANNCE/social_mice_demo/C_26/L/hires_cam2_params.mat'); params{3} = importdata('C:/Users/verpeutlab/Desktop/DANNCE/social_mice_demo/C_26/L/hires_cam3_params.mat'); %% Load the videos into memory vidName = '0.avi'; vidPaths = collectVideoPaths(projectFolder,vidName); videos = cell(3,1); addpath('C:\Users\verpeutlab\Desktop\DANNCE\social_mice_demo\C_26\L\sync\') sync = cell(3,1); sync{1} = importdata('C:/Users/verpeutlab/Desktop/DANNCE/social_mice_demo/C_26/L/sync/Camera1_sync.mat'); sync{2} = importdata('C:/Users/verpeutlab/Desktop/DANNCE/social_mice_demo/C_26/L/sync/Camera2_sync.mat'); sync{3} = importdata('C:/Users/verpeutlab/Desktop/DANNCE/social_mice_demo/C_26/L/sync/Camera3_sync.mat');
% In case the demo folder uses the dannce.mat data format. if isempty(sync) dannce_file = dir(fullfile(projectFolder, '*dannce.mat')); dannce = load(fullfile(dannce_file(1).folder, dannce_file(1).name)); %load(fullfile(dannce_file(1).folder, dannce_file(2).name)); sync = dannce.sync; params = dannce.params; end
framesToLabel = 1:100; for nVid = 1:numel(vidPaths) frameInds = sync{nVid}.data_frame(framesToLabel); videos{nVid} = readFrames(vidPaths{nVid}, frameInds+1); end
%% Get the skeleton skeleton = load('skeletons/mouse22'); % skeleton = load('com');
%% Start Label3D close all labelGui = Label3D(params, videos, skeleton);
`
Glad you got the example working.
I can't be of much help since I don't have your data, but since it crashes on FFGRAB, I would recommend debugging as though its an issue with mmread. https://www.mathworks.com/matlabcentral/fileexchange/8028-mmread
They recommend setting FFGRAB to false in some situations on Windows. You can do this by changing this line in the included video reading function. https://github.com/diegoaldarondo/Animator/blob/6d1f1029cd978bf499f84e238b1c83bf1d80bdd1/deps/video/readFrames.m#L23
Otherwise, I would recommend just writing your own frame reading function using something other than mmread.
@verpeutlab Here is code for readFramesFast
, an alternative to readFrames
that might work better for you.
The arguments are the same as for readFrames
. Put the following code in a file called readFramesFast.m
in your base Label3D directory. Then replace readFrames
with readFramesFast
in example.m
.
function frames = readFramesFast(vidPath,fID)
%readFramesFast Loads vide oframes quickly by frame index
vid = VideoReader(vidPath);
fps = vid.FrameRate;
frames = zeros(vid.Height,vid.Width,3,numel(fID),'uint8');
for i = 1:numel(fID)
vid.CurrentTime = (fID(i)-1)/fps;
frames(:,:,:,i) = readFrame(vid);
end
end
Thank you! I got the code to work by trying the option suggested by @spoonsso .
Hello. I have just started to experience difficulties when running example.m found in the Label3D folder. When I run the demo data in markerless_mouse_1, I receive the following error. Note that I have renamed example.m to be C_26_example.m.
Additionally, MATLAB has been quitting when I have been running this same script with my data. Since I am using three cameras instead of six, I changed
videos = cell(6,1)
to bevideos = cell(3,1);
. I also changed the value ofvidName
from 0.mp4 to 0.avi since the videos that I recorded were saved in .avi format. I also haveload(fullfile(dannce_file(1).folder, dannce_file(2).name));
written asdannce = load(fullfile(dannce_file(1).folder, dannce_file(1).name));
to load the label3d_dannce.mat file I created and discussed in my reply to Issue #84 . However, when I run this code, MATLAB quits. I do not receive an error message, but after running this script in debug mode, I found that this issue occurs on the line that readsvideos{nVid} = readFrames(vidPaths{nVid}, frameInds+1);
This line of code triggers a series of other scripts, and MATLAB quits whenFFGrab('setFrames',frames);
is executed in mmread.m. The script mmread.m can be found in.\Label3D\deps\Animator\deps\video\video_io\mmread
and this line should be around Line 149. This second image shows the data the script has when MATLAB quits.If you could please give me an idea of what is causing MATLAB to quit when I execute it with my data or why I have just started to receive an error when I run the markerless_mouse_1 demo data through the script that is example.m, I would appreciate it!