How to find the angle of rotation of a stabilized video frame on Matlab

We believe that I have a stabilized video frame where stabilization is performed only by rotation and translation (without scaling):

ori

As you can see in the image, the right side of the image is symmetrical for the previous pixels, i.e. the black region after rotation is filled with symmetry. I added a red line to indicate it more clearly. Red line

I would like to find the angle of rotation that I will use later. I could do this through the SURF or SIFT functions, however in the real scenario I will not have the source frame.

, , , , . , . , , V [51 49 47] , [50 50 47] , , RGB.

Matlab python, ffmpeg.

EDIT: , , ffmpeg.

/ ,

+4
1

() ,

  • (///...) (= > dG, . )
  • (//thrid/...) ( ) (= > dGs, . 1 )

, |dGs| - |dG| (= > dGs_dG, . 1 )

1, . (. 2 ) , (. 2 ). .

  • n: , n. , n .

  • : dGs_dG . dG .

  • : hough, , .

enter image description here

enter image description here

, , :

I = imread('bnuqb.png');
G = int16(rgb2gray(I));

n = 3; % use the first, second and third left/right point
dG = int16(zeros(size(G) - [0 2*n+2]));
dGs = int16(zeros(size(G) - [0 2*n+2]));
for i=0:n
  dG = dG + abs(G(:, 1+n-i:end-2-n-i) - G(:, 3+n+i:end-n+i));
  dGs = dGs + abs(G(:, 1+n-i:end-2-n-i) - G(:, 2+n:end-n-1));
end
dGs_dG = dGs - dG;
dGs_dG(dGs_dG < 0) = 0;
figure
subplot(1,3,1);
imshow(dG, [])
subplot(1,3,2);
imshow(dGs, [])
subplot(1,3,3);
imshow(dGs_dG, [])

BW = dGs_dG > 0;
[H,theta,rho] = hough(BW);
P = houghpeaks(H,1);
lines = houghlines(BW,theta,rho,P,'FillGap',50000,'MinLength',7);

figure
subplot(1,2,1);
imshow(H, [])
hold on
plot(P(:, 2),P(:, 1),'r.');

subplot(1,2,2);
imshow(I(:, n+2:end-n-1, :))
hold on
max_len = 0;
for k = 1:length(lines)
   xy = [lines(k).point1; lines(k).point2];
   plot(xy(:,1),xy(:,2),'g');
end
+6

Source: https://habr.com/ru/post/1674338/


All Articles