数字摄影测量实习报告(DOC) - 图文(6)

2019-08-30 19:16

} 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(i); uchar *subwind_ptr= subwind.ptr(i); for{ (int j = 0; j < nc; j++) sum += (*(subwin_ptr+j)-avg1)*(*(subwind_ptr+j) - avg2); } } casereturn 3:for// (相关系数法 sum; int i = 0; i < nr; ++i) { uchar *subwin_ptr = subwin.ptr(i); uchar *subwind_ptr= subwind.ptr(i); for { (int j = 0; j < nc; j++) avg1 += *(subwin_ptr+j); } } 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(i); uchar *subwind_ptr= subwind.ptr(i); for (int j = 0; j < nc; j++) { sum += (*(subwin_ptr+j)-avg1)*(*(subwind_ptr+j) - avg2); } } for (int i = 0; i < nr; ++i) { uchar *subwin_ptr = subwin.ptr(i); uchar *subwind_ptr= subwind.ptr(i); for (int { j = 0; j < nc; j++) sdv1 += (*(subwin_ptr+j)-avg1)*(*(subwin_ptr+j) - avg1); } } sdv2 += (*(subwind_ptr+j)-avg2)*(*(subwind_ptr+j) - avg2); sum = sum / sqrtf(sdv1*sdv2); casereturn 4://差平方和法 sum; for ( { int i = 0; i < nr; ++i) uchar *subwin_ptr = subwin.ptr(i); uchar *subwind_ptr= subwind.ptr(i); for{ (int j = 0; j < nc; j++) ( sum float )(*(subwin_ptr+j)-*(subwind_ptr+j))*(*(subwin_ptr+j)-*(subwind_ptr+j)); } } casereturn 5://差绝对值和法 -sum; for (int i = 0; i < nr; ++i) { uchar *subwin_ptr = subwin.ptr(i); uchar *subwind_ptr= subwind.ptr(i); for{ (int j = 0; j < nc; j++) sum += (float)abs(*(subwin_ptr+j) - *(subwind_ptr+j));

24

+= }

} } return -sum; default: break; }

return sum;

图2 相关函数 图3 协方差

图4 相关系数 图5 差平方和

图6 差绝对值

3、同名核线提取

#include \

#include #include #include #include #include #include using namespace std; //构造函数

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(0) = 1.0; tmpB.at(1) = x; tmpB.at(2) = y; tmpB.at(3) = x_; tmpB.at(4) = x_*x; tmpB.at(5) = x*y_; tmpB.at(6) = y*x_; tmpB.at(7) = y*y_; cout << tmpB.at(0) << \\ << tmpB.at(1) << \\ << tmpB.at(2) << \ << tmpB.at(3) << \ << tmpB.at(4) << \ << tmpB.at(5) << \ << tmpB.at(6) << \ << tmpB.at(7) << endl; B.push_back(tmpB); L.push_back(y - y_); } cv::Mat X = (B.t()*B).inv() * B.t() *L; double L1 = X.at(0); double L2 = X.at(1); double L3 = X.at(2); double L4 = X.at(3); double L5 = X.at(4); double L6 = X.at(5); double L7 = X.at(6); double L8 = X.at(7); vector::iterator itr1 = find_if(pic1.begin(), pic1.end(), findxy(4507)); vector::iterator itr2 = find_if(pic2.begin(), pic2.end(), findxy(4507)); double x = (*itr1).x; double y = (*itr1).y; double x0 = 0; double x1 = img1.cols; double x_0 = 0; double x_1 = img2.cols; double y_0 = ((1 - L3)*y - L1 - L2*x - L4*x_0 - L5*x*x_0 - L7*y*x_0) / (1 + L6 * x + L8*y); double y_1 = ((1 - L3)*y - L1 - L2*x - L4*x_1 - L5*x*x_1 - L7*y*x_1) / (1 + L6 * x + L8*y); double y0 = (y_0 + L1 + L2*x0 + L4*x_0 + L5*x1*x_0 + L6*x*y_0) / (1 - L3 - L7*x_0 - L8*y_0); double y1 = (y_0 + L1 + L2*x1 + L4*x_0 + L5*x1*x_0 + L6*x*y_0) / (1 - L3 - L7*x_0

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


数字摄影测量实习报告(DOC) - 图文(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:学校设计招标文件

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: