保存各种角点检测算法在变换下的角点坐标

function Result=savedetecttxt()
 close all
 clc
 tic

Result=[];
methodfilename='hedetecttxt';
for cnt =5:21
cnt
% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Rotation
% %rotation transformation,from -90°to 90°,at 10° apart,excluding 0°
% 
for angle=0
    commonpath=strcat(num2str(cnt),'_r_',num2str(angle));
    picpathname=strcat('changeimages8904/', commonpath,'.jpg')
    f=imread( picpathname);
%     imshow(f);
    f=rgb2gray(f);
        [corners]=bhe(f);
     fid=fopen(strcat(methodfilename,'/', commonpath,'.txt'),'wt'); %写入的文件名
     [m,n]=size(corners);
      for i=1:1:m
      for j=1:1:n
       if j==n
       fprintf(fid,'%g\n',corners(i,j));
       else
       fprintf(fid,'%g\t',corners(i,j));
       end
      end
      end
    fclose(fid);

end
% 
for angle=-90:10:-10
      commonpath=strcat(num2str(cnt),'_r_',num2str(angle));
    picpathname=strcat('changeimages8904/', commonpath,'.jpg')
    f=imread( picpathname);
%     imshow(f);
    f=rgb2gray(f);
        [corners]=bhe(f);
     fid=fopen(strcat(methodfilename,'/', commonpath,'.txt'),'wt'); %写入的文件名
     [m,n]=size(corners);
      for i=1:1:m
      for j=1:1:n
       if j==n
       fprintf(fid,'%g\n',corners(i,j));
       else
       fprintf(fid,'%g\t',corners(i,j));
       end
      end
      end
    fclose(fid);

end


for angle=10:10:90
      commonpath=strcat(num2str(cnt),'_r_',num2str(angle));
    picpathname=strcat('changeimages8904/', commonpath,'.jpg');
    f=imread( picpathname);
    imshow(f);
    f=rgb2gray(f);
        [corners]=bhe(f);
     fid=fopen(strcat(methodfilename,'/', commonpath,'.txt'),'wt'); %写入的文件名
     [m,n]=size(corners);
      for i=1:1:m
      for j=1:1:n
       if j==n
       fprintf(fid,'%g\n',corners(i,j));
       else
       fprintf(fid,'%g\t',corners(i,j));
       end
      end
      end
    fclose(fid);

end
% % 
% % 
% % %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% scaling
% % %%uniform and nonuniform scaling transformation,x from 0.5 to 2.0,at 0.1 apart,y from 0.5 
% % %%to 2.0,at 0.1 apart,excluding x=y
% % 
% % 
for scale_x=0.5:0.1:2.0
    for scale_y=0.5:0.1:2.0
            if scale_x~=1 ||scale_y~=1 
                
           commonpath=strcat(num2str(cnt),'_s_',num2str(scale_x),'_',num2str(scale_y));
           picpathname=strcat('changeimages8904/', commonpath,'.jpg');
        f=imread( picpathname);
%         imshow(f);
        f=rgb2gray(f);
        corners=bhe(f);
        fid=fopen(strcat(methodfilename,'/', commonpath,'.txt'),'wt'); %写入的文件名
     [m,n]=size(corners);
      for i=1:1:m
      for j=1:1:n
       if j==n
       fprintf(fid,'%g\n',corners(i,j));
       else
       fprintf(fid,'%g\t',corners(i,j));
       end
      end
      end
     fclose(fid);
                                
            end
    end
end
% 
% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    Affine
% %combined(affine) transformation,angles range form -30°to -30°;x,y from 
% %0.8 to 1.2,at 0.1 apart,y from 0.8 to 1.2,at 0.1 apart,excluding x=y
angle_array=[-30 -20 -10 10 20 30 ];
for i=1:6
    angle=angle_array(i);
    for scale_x=0.8:0.1:1.2
        for scale_y=0.8:0.1:1.2
            if abs(scale_x-scale_y)>1e-3
                if scale_x~=1 ||scale_y~=1 
                     commonpath=strcat(num2str(cnt),'_a_',num2str(angle),'_',num2str(scale_x),'_',num2str(scale_y));
           picpathname=strcat('changeimages8904/', commonpath,'.jpg');
        f=imread( picpathname);
%         imshow(f);
        f=rgb2gray(f);
        [corners]=bhe(f);
        fid=fopen(strcat(methodfilename,'/', commonpath,'.txt'),'wt'); %写入的文件名
     [m,n]=size(corners);
      for i=1:1:m
      for j=1:1:n
       if j==n
       fprintf(fid,'%g\n',corners(i,j));
       else
       fprintf(fid,'%g\t',corners(i,j));
       end
      end
      end
     fclose(fid);
                    
                end
            end
        end
    end
end
% 
% 
% 
% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Jpeg
% %%Jpeg lossy compression ,quality factors range from 5 to 100,at 5 apart
% 
% 
for quality_factor=5:5:100
      commonpath=strcat(num2str(cnt),'_j_',num2str(quality_factor));
           picpathname=strcat('changeimages8904/', commonpath,'.jpg');
        f=imread( picpathname);
        f=rgb2gray(f);
        [corners]=bhe(f);
        fid=fopen(strcat(methodfilename,'/', commonpath,'.txt'),'wt'); %写入的文件名
     [m,n]=size(corners);
      for i=1:1:m
      for j=1:1:n
       if j==n
       fprintf(fid,'%g\n',corners(i,j));
       else
       fprintf(fid,'%g\t',corners(i,j));
       end
      end
      end
     fclose(fid);
end
% 
% 
% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Gaussian
% %gaussian white noise, range from0.005 to 0.05,at 0.005 apart
% 
for noise=0.005:0.005:0.05
          commonpath=strcat(num2str(cnt),'_n_',num2str(noise));
           picpathname=strcat('changeimages8904/', commonpath,'.jpg');
        f=imread( picpathname);
%         imshow(f);
        f=rgb2gray(f);
        [corners]=bhe(f);
        fid=fopen(strcat(methodfilename,'/', commonpath,'.txt'),'wt'); %写入的文件名
     [m,n]=size(corners);
      for i=1:1:m
      for j=1:1:n
       if j==n
       fprintf(fid,'%g\n',corners(i,j));
       else
       fprintf(fid,'%g\t',corners(i,j));
       end
      end
      end
     fclose(fid);
    
end

end
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: OpenCV中的棋盘格角点匹配是一种常见的计算机视觉算法,用于在图像中检测棋盘格的角点,并将其匹配到实际世界中的坐标。这个过程主要涉及两个步骤:棋盘格角点检测角点匹配。 在棋盘格角点检测步骤中,我们首先加载一张包含棋盘格的图像。然后,使用OpenCV中的函数`cv2.findChessboardCorners()`来检测图像中的角点。这个函数会自动寻找图像中的棋盘格,并返回角点的像素坐标。 在角点匹配步骤中,我们需要传入已知的实际世界中的角点坐标。这些坐标可以通过测量或建模来获取。然后,使用OpenCV中的函数`cv2.calibrateCamera()`来计算摄像机的内部参数和外部参数。这个函数会使用棋盘格角点在图像上的像素坐标和实际世界中的角点坐标来估计摄像机的参数。 最后,我们可以使用OpenCV中的函数`cv2.projectPoints()`来将实际世界中的点投影到图像上。这个函数会使用之前估计的摄像机参数来计算投影后的图像中的点位置。 总结来说,OpenCV中的棋盘格角点匹配是一种基于摄像机参数估计的算法,用于将图像中的角点与实际世界中的角点进行匹配。这个算法对于摄像机标定和计算机视觉中的3D重建等应用非常有用。 ### 回答2: OpenCV是一个计算机视觉库,可以用于棋盘格角点匹配。棋盘格角点匹配是指在给定一个棋盘格图像的情况下,通过检测出角点并与预定义的角点进行匹配,以确定棋盘格在图像中的位置和姿态。 在OpenCV中,可以使用函数`findChessboardCorners()`来检测棋盘格图像中的角点。这个函数需要输入棋盘格图像,以及棋盘格的大小。它会返回一个布尔值,表示是否成功检测到角点,以及检测到的角点坐标。 如果检测到了角点,我们可以使用函数`drawChessboardCorners()`将角点标记在棋盘格图像上,以便可视化。这样可以帮助我们确认角点是否正确检测。 接下来,我们可以使用函数`findHomography()`来估计棋盘格在图像中的位置和姿态。这个函数需要输入棋盘格的三维坐标和检测到的角点的二维坐标。它会返回一个3x3的变换矩阵,用于将图像上的点映射到棋盘格坐标系中。 最后,我们可以使用函数`drawFrameAxes()`将棋盘格的姿态绘制在图像上,以显示其在三维空间中的位置和方向。 总之,OpenCV提供了一系列函数来实现棋盘格角点匹配。通过检测角点并与预定义的角点进行匹配,我们可以确定棋盘格在图像中的位置和姿态,这对于计算机视觉应用中的摄像机校准和目标追踪等任务非常有用。 ### 回答3: opencv棋盘格角点匹配是指通过opencv库及相关函数,将棋盘格图像中的角点进行识别和匹配的过程。 在使用opencv进行棋盘格角点匹配前,需要先准备一张包含棋盘格的图像,并确定该棋盘格的行列数。接下来,可以通过cv2.findChessboardCorners函数找到图像中的棋盘格角点位置。 首先,我们需要将图像转换为灰度图像,这可以通过调用cv2.cvtColor函数实现。然后,使用cv2.findChessboardCorners函数,传入灰度图像以及棋盘格的行列数作为参数,该函数将返回一个布尔值和角点坐标。如果找到了棋盘格角点,布尔值将为真,并且角点坐标保存在一个numpy数组中。 接下来,可以通过调用cv2.cornerSubPix函数对角点坐标进行亚像素级别的精确化。该函数需要传入原始图像、角点坐标、搜索窗的一半大小和迭代终止条件等参数。这样可以得到更准确的角点位置。 最后,可以通过调用cv2.drawChessboardCorners函数将角点绘制在原始图像上,该函数需要传入原始图像、角点坐标和布尔值等参数。 总结起来,opencv棋盘格角点匹配的过程可以简述为:图像灰度化 -> 角点检测 -> 亚像素级角点精确化 -> 绘制角点。通过这一系列操作,我们可以在棋盘格图像中精确地找到角点,并进行后续的处理和分析。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值