资源简介

针对传统摄像机自标定方法的上述不足,利用遗传算法完成了Hartley新的Kruppa方程的摄像机自标定过程,以便将这个过程完全转化为通过代价函数最小化来求得摄像机的内参数,这就排除了极点的不稳定因素。实验结果表明,该方法是简单、有效的,可以作为一种通用的标定工具

资源截图

代码片段和文件信息

%% generitic algrithm
%% floating encoding
%% f(x)=x1^2+x2^2
%% min f(x)
clear;
clc;
rand(‘state‘sum(100*clock))
NP=30;
pm=0.05;
pc=0.8;
alaf=0.5;
dimentions=2;
b=0.5;
UB=30;
LB=-30;
Maxiterations=50;
child=rand(NPdimentions)*(UB-LB)+LB;  %% initialize 
farther=child;
iterations=0;
bestfx=[];
while iterations%% computer the fitness
for p=1:NP
    x1=farther(p1);
    x2=farther(p2);
    fx(p)=x1^2+x2^2;
    fitness(p)=1/(fx(p)+0.0000001);    
end
[XI]=sort(fitness);
bestnumber=I(NP);
bestfx(iterations+1)=min(fx);

%% computer the fitness accumulation
for p=1:NP
    if p==1
        fitacc(p)=fitness(p);
    else
        fitacc(p)=fitacc(p-1)+fitness(p);
    end
end
%% copy operation
for p=1:NP
    if p==bestnumber
        child(p:)=farther(p:);
    else
        randfit=rand*fitacc(NP);
    
        for i=1:NP
            if fitacc(i)>=randfit
                break;
            end            
        end
        child(p:)=farther(i:);
    end
end

%% crossover operation
for number1=1:NP
    if number1==bestnumber
        child(number1:)=child(number1:);
    else
        number2=number1;
        
        while number2==number1
            number2=rand*NP;
            number2=number2-rem(number21)+1;
        end
    
        if pc>rand
            child(number1:)=alaf*child(number1:)+(1-alaf)*child(number2:);
        else
            child(number1:)=child(number1:);
        end
    end
end

%% mutate operation
for p=1:NP
    if p==bestnumber
        child(p:)=child(p:);
    else
        if pm>rand
            deta=rand;
            power=(1-iterations/Maxiterations)^b;
            d=rand*dimentions;
            d=d-rem(d1)+1;
            if (rand-0.5)>0
                child(pd)=child(pd)+(UB-child(pd))*(1-deta^power);                
            else
                child(pd)=child(pd)-(child(pd)-LB)*(1-deta^power);
            end
        else
            child(p:)=child(p:);
        end
    end
end
farther=child;
iterations=iterations+1;
end
hold on
plot(bestfx);
for i=1:Maxiterations
    if bestfx(i)<0.001
        plot(ibestfx(i)‘r*‘);
        break;
    end
end

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     220100  2010-03-20 22:37  基于遗传算法的摄像机自标定方法.caj

     文件       2249  2008-08-24 16:32  GA.m

----------- ---------  ---------- -----  ----

               222349                    2


评论

共有 条评论