Error in MATLAB opticalFlow function from the vision toolbox

14 次查看(过去 30 天)
I am trying to run the RealTime_dense_descriptors code from GitHub. Since this is an old MATLAB code & I have the R2022b release, I had to make the following modifications:
  1. I changed the code to read the .avi video using a fullfile function. That part runs fine now (atleast from what I see).
  2. I replaced 'vision.OpticalFlow' with 'opticalFlow' in the Video2OpticalFlow.m file.
The old OpticalFlow function takes several arguments as shown in the Video2OpticalFlow.m file. Here's a snippet:
opticalFlowClass = opticalFlow('OutputValue', ...
'Horizontal and vertical components in complex form', 'Method', method);
Unrecognized function or variable 'method'.
When I run the demo.m file, I get the following error:
Error using opticalFlow
Must have at least two input arguments or no input argument.
Error in Video2OpticalFlow (line 28)
opticalFlowClass = opticalFlow('OutputValue', ...
Error in Video2DenseHOFVolumes (line 33)
opticalFlow = Video2OpticalFlow(video, flowMethod);
Error in demo (line 90)
Video2DenseHOFVolumes(sampledVid, blockSize, numBlocks, numOr, flowMethod);
However, I am unsure how to modify the code to fix this error. Could someone provide guidance on how to resolve this issue and modify the code accordingly? Any help would be appreciated. Thank you.

回答(1 个)

Abhinav Aravindan
Abhinav Aravindan 2024-11-15,9:34
Hi @a_imr,
The “vision.OpticalFlow” system object estimates object velocities from one image or video frame to another. It uses either the Horn-Schunck or the Lucas-Kanade method. This function appears to have been removed from MATLAB R2016a. You may use one of the below mentioned alternative functions as per your requirement in MATLAB R2022b instead of the “opticalFlow” function to resolve the error.
  1. OpticalFlowLKDoG: https://www.mathworks.com/help/releases/R2022b/vision/ref/opticalflowlkdog.html
  2. OpticalFlowLK: https://www.mathworks.com/help/releases/R2022b/vision/ref/opticalflowlk.html
  3. OpticalFlowFarneback: https://www.mathworks.com/help/releases/R2022b/vision/ref/opticalflowfarneback.html
  4. OpticalFlowHS: https://www.mathworks.com/help/releases/R2022b/vision/ref/opticalflowhs.html

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by