How to find the next position of an object in an image based on the displacement of nearby objects?
2 views (last 30 days)
Show older comments
I have 2 images, or let's say 2 frames( first one: reference image) obtained from a shaky video. The second frame is different from the first because of the vibration/shake. I want to find the pixel position of an object in the 2nd frame using the displacement/ distance between the pixels of other objects(like some markers) in these images.
What I did is I calculate the distance between the pixel positions of selected points in the 1st and 2nd images(same objects). But this distance are not the same and i cannot make an equation using this distance to find the (x2,y2) co-ordinates of the required object. How can I proceed further?
%%Input video file which needs to be stabilized.
filename = 'SS-75_zoom_Trim.mp4';
videoFReader = vision.VideoFileReader(filename, ...
'ImageColorSpace', 'RGB',...
'VideoOutputDataType', 'double');
%Create a video player object to play the video file
videoPlayer = vision.VideoPlayer;
img1=step(videoFReader); % obtain the first frame
img2=step(videoFReader); % second frame
figure;
imshow(img18);
[Ax,Ay] = getpts; %select points in image 1
figure;
imshow(img19);
[Bx,By] = getpts; %select the same point sin image 2
for i=1:3
dis(i) = hypot((Bx(i)-Ax(i)), (By(i)-Ay(i))); % calculate distance
end
0 Comments
Answers (1)
See Also
Categories
Find more on Computer Vision Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!