mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 11:45:30 +08:00
Update code
This commit is contained in:
parent
0d2bc9b0a1
commit
7b0be9cf8f
@ -341,7 +341,7 @@ The following parameters work for this application:
|
|||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
// RANSAC parameters
|
// RANSAC parameters
|
||||||
|
|
||||||
int iterationsCount = 500; // number of Ransac iterations.
|
int iterationsCount = 500; // number of Ransac iterations.
|
||||||
float reprojectionError = 2.0; // maximum allowed distance to consider it an inlier.
|
float reprojectionError = 2.0; // maximum allowed distance to consider it an inlier.
|
||||||
float confidence = 0.95; // ransac successful confidence.
|
float confidence = 0.95; // ransac successful confidence.
|
||||||
|
@ -417,7 +417,7 @@ cv::Mat dls::cayley_LS_M(const std::vector<double>& a, const std::vector<double>
|
|||||||
{
|
{
|
||||||
// TODO: input matrix pointer
|
// TODO: input matrix pointer
|
||||||
// TODO: shift coefficients one position to left
|
// TODO: shift coefficients one position to left
|
||||||
|
|
||||||
cv::Mat M = cv::Mat::zeros(120, 120, CV_64F);
|
cv::Mat M = cv::Mat::zeros(120, 120, CV_64F);
|
||||||
|
|
||||||
M.at<double>(0,0)=u[1]; M.at<double>(0,35)=a[1]; M.at<double>(0,83)=b[1]; M.at<double>(0,118)=c[1];
|
M.at<double>(0,0)=u[1]; M.at<double>(0,35)=a[1]; M.at<double>(0,83)=b[1]; M.at<double>(0,118)=c[1];
|
||||||
@ -662,11 +662,3 @@ bool dls::positive_eigenvalues(const cv::Mat * eigenvalues)
|
|||||||
cv::MatConstIterator_<double> it = eigenvalues->begin<double>();
|
cv::MatConstIterator_<double> it = eigenvalues->begin<double>();
|
||||||
return *(it) > 0 && *(it+1) > 0 && *(it+2) > 0;
|
return *(it) > 0 && *(it+1) > 0 && *(it+2) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ ADD_DEFINITIONS(
|
|||||||
|
|
||||||
find_package( OpenCV REQUIRED )
|
find_package( OpenCV REQUIRED )
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${OpenCV_INCLUDE_DIRS}
|
${OpenCV_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
@ -39,9 +39,9 @@ pnp_verification
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
pnp_detection
|
pnp_detection
|
||||||
src/main_detection.cpp
|
src/main_detection.cpp
|
||||||
src/CsvReader.cpp
|
src/CsvReader.cpp
|
||||||
src/CsvWriter.cpp
|
src/CsvWriter.cpp
|
||||||
src/ModelRegistration.cpp
|
src/ModelRegistration.cpp
|
||||||
src/Mesh.cpp
|
src/Mesh.cpp
|
||||||
|
@ -1,81 +1,79 @@
|
|||||||
#include <string>
|
|
||||||
#include "CsvReader.h"
|
#include "CsvReader.h"
|
||||||
|
|
||||||
/** The default constructor of the CSV reader Class */
|
/** The default constructor of the CSV reader Class */
|
||||||
CsvReader::CsvReader(const std::string &path, const char &separator){
|
CsvReader::CsvReader(const std::string &path, const char &separator){
|
||||||
_file.open(path.c_str(), ifstream::in);
|
_file.open(path.c_str(), ifstream::in);
|
||||||
_separator = separator;
|
_separator = separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read a plane text file with .ply format */
|
/* Read a plane text file with .ply format */
|
||||||
void CsvReader::readPLY(std::vector<cv::Point3f> &list_vertex, std::vector<std::vector<int> > &list_triangles)
|
void CsvReader::readPLY(std::vector<cv::Point3f> &list_vertex, std::vector<std::vector<int> > &list_triangles)
|
||||||
{
|
{
|
||||||
std::string line, tmp_str, n;
|
std::string line, tmp_str, n;
|
||||||
int num_vertex, num_triangles;
|
int num_vertex, num_triangles;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
bool end_header = false;
|
bool end_header = false;
|
||||||
bool end_vertex = false;
|
bool end_vertex = false;
|
||||||
|
|
||||||
// Read the whole *.ply file
|
// Read the whole *.ply file
|
||||||
while (getline(_file, line)) {
|
while (getline(_file, line)) {
|
||||||
stringstream liness(line);
|
stringstream liness(line);
|
||||||
|
|
||||||
// read header
|
// read header
|
||||||
if(!end_header)
|
if(!end_header)
|
||||||
{
|
{
|
||||||
getline(liness, tmp_str, _separator);
|
getline(liness, tmp_str, _separator);
|
||||||
if( tmp_str == "element" )
|
if( tmp_str == "element" )
|
||||||
{
|
{
|
||||||
getline(liness, tmp_str, _separator);
|
getline(liness, tmp_str, _separator);
|
||||||
getline(liness, n);
|
getline(liness, n);
|
||||||
if(tmp_str == "vertex") num_vertex = std::stoi(n);
|
if(tmp_str == "vertex") num_vertex = StringToNumber(n);
|
||||||
if(tmp_str == "face") num_triangles = std::stoi(n);
|
if(tmp_str == "face") num_triangles = StringToNumber(n);
|
||||||
}
|
}
|
||||||
if(tmp_str == "end_header") end_header = true;
|
if(tmp_str == "end_header") end_header = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read file content
|
// read file content
|
||||||
else if(end_header)
|
else if(end_header)
|
||||||
{
|
{
|
||||||
// read vertex and add into 'list_vertex'
|
// read vertex and add into 'list_vertex'
|
||||||
if(!end_vertex && count < num_vertex)
|
if(!end_vertex && count < num_vertex)
|
||||||
{
|
{
|
||||||
string x, y, z;
|
string x, y, z;
|
||||||
getline(liness, x, _separator);
|
getline(liness, x, _separator);
|
||||||
getline(liness, y, _separator);
|
getline(liness, y, _separator);
|
||||||
getline(liness, z);
|
getline(liness, z);
|
||||||
|
|
||||||
cv::Point3f tmp_p;
|
cv::Point3f tmp_p;
|
||||||
tmp_p.x = std::stof(x);
|
tmp_p.x = StringToNumber(x);
|
||||||
tmp_p.y = std::stof(y);
|
tmp_p.y = StringToNumber(y);
|
||||||
tmp_p.z = std::stof(z);
|
tmp_p.z = StringToNumber(z);
|
||||||
list_vertex.push_back(tmp_p);
|
list_vertex.push_back(tmp_p);
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
if(count == num_vertex)
|
if(count == num_vertex)
|
||||||
{
|
{
|
||||||
count = 0;
|
count = 0;
|
||||||
end_vertex = !end_vertex;
|
end_vertex = !end_vertex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// read faces and add into 'list_triangles'
|
// read faces and add into 'list_triangles'
|
||||||
else if(end_vertex && count < num_triangles)
|
else if(end_vertex && count < num_triangles)
|
||||||
{
|
{
|
||||||
std::string num_pts_per_face, id0, id1, id2;
|
std::string num_pts_per_face, id0, id1, id2;
|
||||||
getline(liness, num_pts_per_face, _separator);
|
getline(liness, num_pts_per_face, _separator);
|
||||||
getline(liness, id0, _separator);
|
getline(liness, id0, _separator);
|
||||||
getline(liness, id1, _separator);
|
getline(liness, id1, _separator);
|
||||||
getline(liness, id2);
|
getline(liness, id2);
|
||||||
|
|
||||||
std::vector<int> tmp_triangle(3);
|
std::vector<int> tmp_triangle(3);
|
||||||
tmp_triangle[0] = std::stoi(id0);
|
tmp_triangle[0] = StringToNumber(id0);
|
||||||
tmp_triangle[1] = std::stoi(id1);
|
tmp_triangle[1] = StringToNumber(id1);
|
||||||
tmp_triangle[2] = std::stoi(id2);
|
tmp_triangle[2] = StringToNumber(id2);
|
||||||
list_triangles.push_back(tmp_triangle);
|
list_triangles.push_back(tmp_triangle);
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,5 +71,3 @@ void Model::load(const std::string path)
|
|||||||
storage.release();
|
storage.release();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +33,3 @@ void ModelRegistration::reset()
|
|||||||
list_points2d_.clear();
|
list_points2d_.clear();
|
||||||
list_points3d_.clear();
|
list_points3d_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -310,6 +310,3 @@ bool PnPProblem::intersect_MollerTrumbore(Ray &Ray, Triangle &Triangle, double *
|
|||||||
// No hit, no win
|
// No hit, no win
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -273,4 +273,3 @@ cv::Mat euler2rot(const cv::Mat & euler)
|
|||||||
|
|
||||||
return rotationMatrix;
|
return rotationMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,4 +141,3 @@ int main(int argc, char *argv[])
|
|||||||
data2file("computation_time.txt", comp_time);
|
data2file("computation_time.txt", comp_time);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user