Optical Flow HS between two Images

조회 수: 23 (최근 30일)
Matteo Cacchioni
Matteo Cacchioni 2021년 7월 7일
댓글: Image Analyst 2023년 11월 5일
Hi, I'm working with the Optical Flow HS method and I would like to know how I can set the "Compute optical flow between" parameter to 'Two images'.
In the description, it says that I have to change it into 'Two images' to compute the optical Flow between images instead of video frames.
% Compute optical flow
flow = estimateFlow(opticFlow, frameGray);
This is the standard input, what exactly I have to digit to change it?
Thank you very much

답변 (1개)

Hrishikesh Borate
Hrishikesh Borate 2021년 7월 15일
Hi,
The following code demonstrates the computation of optical flow between two images.
vidReader = VideoReader('visiontraffic.avi','CurrentTime',11);
frame1 = readFrame(vidReader);
% Extract 11th frame
for i=1:10
frame2 = readFrame(vidReader);
end
frame = {frame1, frame2};
h = figure;
movegui(h);
hViewPanel = uipanel(h,'Position',[0 0 1 1],'Title','Plot of Optical Flow Vectors');
hPlot = axes(hViewPanel);
opticFlow = opticalFlowHS;
for i=1:2
frameRGB = frame{i};
frameGray = im2gray(frameRGB);
flow = estimateFlow(opticFlow,frameGray);
imshow(frameRGB)
hold on
plot(flow,'DecimationFactor',[5 5],'ScaleFactor',60,'Parent',hPlot);
hold off
pause(1)
end
The flow variable stores the optical flow between the two images (frame1 and frame2).
For more information, refer to the opticalFlowHS documentation.
  댓글 수: 2
Vivek Raj
Vivek Raj 2023년 11월 5일
Hello everyone, how i can detect current position of a ball (if i want to track a ball in image) using Horn-Schunk method?
Image Analyst
Image Analyst 2023년 11월 5일
I'm guessing you'd threshold the flow image and then call regionprops and ask for the centroid. Attach a snippet of your video in a new question, and your code, if you still have problems.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by