} avg2 += *(subwind_ptr+j); } avg1 = avg1 / (subwin.rows*subwin.cols); avg2 = avg2 / (subwind.rows*subwind.cols); for (int i = 0; i < nr; ++i) { uchar *subwin_ptr = subwin.ptr
24
+= }
} } return -sum; default: break; }
return sum;
图2 相关函数 图3 协方差
图4 相关系数 图5 差平方和
图6 差绝对值
3、同名核线提取
#include \
#include
HXDialog::HXDialog(QWidget *parent): QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); }
HXDialog::~HXDialog() { }
void HXDialog::on_pushButton_clicked() { path1 = QFileDialog::getOpenFileName(this);
25
ui->lineEdit->setText(path1); }
void HXDialog::on_pushButton_2_clicked() { path2= QFileDialog::getOpenFileName(this); ui->lineEdit_2->setText(path2); }
void HXDialog::on_pushButton_3_clicked() { tpath1= QFileDialog::getOpenFileName(this); ui->lineEdit_3->setText(tpath1); }
void HXDialog::on_pushButton_4_clicked() { tpath2= QFileDialog::getOpenFileName(this); ui->lineEdit_4->setText(tpath2); }
//读取同名点数据
int HXDialog::readxy(string p1,string p2) { int index = 1; ifstream fil; xy tmp; int head; //读取图像1的像点坐标 fil.open(p1); if (!fil) { cout << \ << endl; return -1; } fil >> head; while (!fil.eof()) { fil >> tmp.index >> tmp.x >> tmp.y; cout << \ << index << \ << tmp.index << \ << tmp.x << \ << tmp.y << endl; index++; pic1.push_back(tmp); } fil.clear(); fil.close(); //读取图像2的像点坐标 index = 1; fil.open(p2); if (!fil) { cout << \ << endl; return -1; } fil >> head; while (!fil.eof()) { fil >> tmp.index >> tmp.x >> tmp.y; cout << \ << index << \ << tmp.index << \ << tmp.x << \ << tmp.y << endl; index++; pic2.push_back(tmp); } cout << \ << endl; fil.close(); cout << \ << endl; return 0; }
class findxy {
public: findxy(int index){ ind = index; } int ind;
26
bool operator () (HXDialog::xy &pt){ return ind == pt.index; } };
//同名核线算法主函数 void HXDialog::HX() { string p1 = tpath1.toLocal8Bit(); string p2 = tpath2.toLocal8Bit(); //读取同名点坐标 readxy(p1,p2); //初始值 p1 = path1.toLocal8Bit(); p2 = path2.toLocal8Bit(); cv::Mat img1 = cv::imread(p1); cv::Mat img2 = cv::imread(p2); cv::Mat B; cv::Mat L; if (img1.empty() || img2.empty()) { cout << \ << endl; return; } for (int i = 0; i < pic1.size(); ++i) { double x = pic1[i].x; double y = pic1[i].y; double x_ = pic2[i].x; double y_ = pic2[i].y; cv::Mat tmpB(cv::Size(8, 1), CV_64FC1); tmpB.at
27
- L8*y_0); cv::line(img1, cv::Point(x0, y0), cv::Point(x1, y1), CV_RGB(255,0,0), 5); cv::line(img2, cv::Point(x_0, y_0), cv::Point(x_1, y_1), CV_RGB(255, 0, 0), 5); cv::circle(img1, cv::Point(x, y), 10, CV_RGB(0, 255, 0), 5); cv::circle(img2, cv::Point((*itr2).x, (*itr2).y), 10, CV_RGB(0, 255, 0), 5); cv::resize(img1, dst1, cv::Size(1000, 1000 * img1.rows / img1.cols)); cv::resize(img2, dst2, cv::Size(1000, 1000 * img2.rows / img2.cols)); }
void HXDialog::on_okButton_clicked() { HX(); emit signelHX(dst1,dst2); }
void HXDialog::on_cancelButton_clicked() { }
图7 左核线 图8 右核线
五、心得体会
通过这次的实习,我学习了数字摄影测量系统VirtuoZo和GeoWay的操作方法,了解了通过这两套系统生成4D产品的生产流程。在操作过程中,结合老师的讲解,对于以前课堂上学过的有关知识也进行了回顾。同时我体会到了VirtuoZo和GeoWay这两款数字摄影测量系统的强大功能,操作的步骤也比较复杂,但是只要熟练掌握,就能够快速生成产品。
这次的数字摄影测量系统操作过程中也遇到了这样那样的问题,比如说内定向失败、相对定向失败等,最后通过问老师同学都得到了解决。大部分的问题归结起来都是由于没有严格按照流程来做,比如说漏掉哪个步骤或者哪个参数没有设置等等。通过老师的讲解,也学到了很多在实际生产中有用的方法。
通过这次的编程实习,我回顾了学过的相关摄影测量原理,并把他们通过程序实现了。在这过程中提高了自己的编程能力以及加深对于相关原理的理解。同时也认识到了一些实际的问题。比如说在做匹配的时候,五种方法得到的结果区别十分大,相关函数法基本不能够成功匹配。
28
这次实习我感受到,即使是在计算机技术如此发达的时代,即使有如此完整的数字摄影测量系统,但是整个生产过程也离不开人的干预。而且人的干预直接影响了得到的结果。所以我们学习数字摄影测量具有十分重要的意义,一方面我们只有理解了相关的原理,才能写出相应的算法,以推动数字摄影测量系统的发展,另一方面,我们只有了解了相关知识,才能在操作中准确的进行干预,得到最好的结果。
29