Larger buffer size seems to cause issue
Closed this issue · 7 comments
Using larger buffer produces error. I was compensating a 3000 frame video, but used my stanrdard settings for 20000 frame vid.
Solved by removing the line 'buffer_size', 24
or reducing buffer_size to 16.
Suggestion: If buffer size will cause errors later in the program, catching this at the start, rather than after running for some time, would be better.
Error:
Finished batch 25, 1 batches left.
Index exceeds the number of array elements. Index must not exceed 0.
Error in mat2gray (line 38)
if limits(2)==limits(1) % Constant Image
Error in compensate_recording>get_eval (line 145)
c1 = mat2gray(imgaussfilt3_multichannel(mat2gray(buffer), options));
Error in compensate_recording (line 107)
= get_eval(options, buffer, c_ref, c_ref_raw, w_init, weight);
Error in test_real_world (line 120)
compensate_recording(options);
Here I was using these options:
options = OF_options(...
'input_file', input_file, ...
'output_path', output_folder, ...
'output_format', 'HDF5', ...
'alpha', 1, ... % smoothness parameter
'sigma', [1, 1, 0.1; ... % gauss kernel size channel 1
1, 1, 0.1], ... % gauss kernel size channel 2
'levels', 40, ... % solver levels
'eta', 0.75, ... % pyramid stepsize
'iterations', 50, ... % outer iterations (the larger the better the result, but slower)
'bin_size', 5, ... % binning over 5 frames from the 30 hz data=
'buffer_size', 24, ... % size of blocks for the parallel evaluation (larger takes more memory)
'reference_frames', baseline_reference ...
);
I am going to look into it, it seems to be a more of problem with the final segment than larger buffer sizes. Do you have a short recording, e.g. 300 frames, that can reproduce the behaviour?
Weird, had no problems with 300 frame vid. I then tried again on another computer, just in case, and found the same error with 3000 frames and 24 buffer
Could you tell me what filetype your input file is? A Tiff with bin_size 5 and buffer_size 24 works for me with 3000 frames
This file was 3000 frames of HDF5 format, converted from a larger MDF file using
vid = get_video_file_reader("filename.MDF", 50);
vid = vid.read_frames(10000:13000);
input_file = "outfilename.HDF5");
writer = get_video_file_writer(input_file, 'HDF5');
writer.write_frames(vid);
I have found the bug, it is a problem with boundary handling after binning. Currently, the toolbox needs at least ceil(bin_size / 2) frames for the last binned frame.
What behaviour would help you the most or what would you normally do for binning, should we discard the last few frames or average over however many frames are left?
The bug is fixed with the latest commit, could you let me know if the behaviour is not as expected?