V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
740186111rose1
V2EX  ›  问与答

找一位懂 matlab 和 Python 的大佬把一段 matlab 代码转成 Python

  •  
  •   740186111rose1 · 2022-11-30 13:15:05 +08:00 · 472 次点击
    这是一个创建于 568 天前的主题,其中的信息可能已经有所发展或是发生改变。

    D = importdata(strcat(folder_name, 'measurement_matrix.txt'));

    %centering [m, n] = size(D); norm_D = zeros(m, n); for i = 1:m norm_D(i,:) = D(i,:) - mean(D(i,:)); end

    [U, S, V] = svd(norm_D); U3 = U(:, 1:3); W3 = S(1:3, 1:3); V3 = V'; V3 = V3(1:3, :); M = U3*W3^(1/2); S = W3^(1/2)*V3;

    figure() plot3(S(3,:),S(2,:),S(1,:), '.');

    estimated_D = MS; per_frame_residual = zeros(m/2, 1); for i = 1:m/2 for j = 1:n per_frame_residual(i,1) = per_frame_residual(i,1) + ... sqrt(sumsqr(estimated_D(2i-1:2i, j) - norm_D(2i-1:2*i, j))); end end

    selected_frame = [1,50,100]; for i = 1:size(selected_frame, 2) index = selected_frame(i); file_name = strcat(folder_name, 'frame00000', num2str(index, '%.3d'), '.jpg'); I = imread(file_name); figure() imshow(I); hold on;

    scatter(D(2*index-1, :), D(2*index, :), 'r*');
    scatter(estimated_D(2*index-1, :) + mean(D(2*index-1,:)) ...
        , estimated_D(2*index, :) + mean(D(2*index,:)), 'go');
    title(strcat('Frame', num2str(index)))
    

    end

    disp('total residual:'); disp(sum(per_frame_residual));

    figure() plot(per_frame_residual); axis([0 101 0 400]); title('Residuals (per frame) ') xlabel('frame number'); ylabel('residules');

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3015 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:03 · PVG 20:03 · LAX 05:03 · JFK 08:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.