forked from MasteringOpenCV/code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultiCameraPnP.h
executable file
·80 lines (71 loc) · 2.44 KB
/
MultiCameraPnP.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*****************************************************************************
* ExploringSfMWithOpenCV
******************************************************************************
* by Roy Shilkrot, 5th Dec 2012
* http://www.morethantechnical.com/
******************************************************************************
* Ch4 of the book "Mastering OpenCV with Practical Computer Vision Projects"
* Copyright Packt Publishing 2012.
* http://www.packtpub.com/cool-projects-with-opencv/book
*****************************************************************************/
#pragma once
#include "MultiCameraDistance.h"
#include "Common.h"
#include "SfMUpdateListener.h"
class MultiCameraPnP : public MultiCameraDistance {
std::vector<CloudPoint> pointcloud_beforeBA;
std::vector<cv::Vec3b> pointCloudRGB_beforeBA;
public:
MultiCameraPnP(
const std::vector<cv::Mat>& imgs_,
const std::vector<std::string>& imgs_names_,
const std::string& imgs_path_):
MultiCameraDistance(imgs_,imgs_names_,imgs_path_)
{
}
virtual void RecoverDepthFromImages();
std::vector<cv::Point3d> getPointCloudBeforeBA() { return CloudPointsToPoints(pointcloud_beforeBA); }
const std::vector<cv::Vec3b>& getPointCloudRGBBeforeBA() { return pointCloudRGB_beforeBA; }
private:
void PruneMatchesBasedOnF();
void AdjustCurrentBundle();
void GetBaseLineTriangulation();
void Find2D3DCorrespondences(int working_view,
std::vector<cv::Point3f>& ppcloud,
std::vector<cv::Point2f>& imgPoints);
bool FindPoseEstimation(
int working_view,
cv::Mat_<double>& rvec,
cv::Mat_<double>& t,
cv::Mat_<double>& R,
std::vector<cv::Point3f> ppcloud,
std::vector<cv::Point2f> imgPoints);
bool TriangulatePointsBetweenViews(
int working_view,
int second_view,
std::vector<struct CloudPoint>& new_triangulated,
std::vector<int>& add_to_cloud
);
int FindHomographyInliers2Views(int vi, int vj);
int m_first_view;
int m_second_view; //baseline's second view other to 0
std::set<int> done_views;
std::set<int> good_views;
/********** Subject / Objserver **********/
std::vector < SfMUpdateListener * > listeners;
public:
void attach(SfMUpdateListener *sul)
{
listeners.push_back(sul);
}
private:
void update()
{
for (int i = 0; i < listeners.size(); i++)
listeners[i]->update(getPointCloud(),
getPointCloudRGB(),
getPointCloudBeforeBA(),
getPointCloudRGBBeforeBA(),
getCameras());
}
};