modify some logical bugs,add remove point function
This commit is contained in:
@@ -16,11 +16,11 @@ Calibrator::~Calibrator()
|
||||
|
||||
}
|
||||
|
||||
void Calibrator::addFrameSequence(std::vector<cv::Mat> &frameSeq)
|
||||
void Calibrator::addFrameSequence(std::vector<Mat> &frameSeq)
|
||||
{
|
||||
int n = frameSeqs.size();
|
||||
frameSeqs.resize(n+1);
|
||||
std::vector<cv::Mat> &frame = frameSeqs[n];
|
||||
std::vector<Mat> &frame = frameSeqs[n];
|
||||
for(int i = 0; i < frameSeq.size(); i++)
|
||||
{
|
||||
frame.push_back(frameSeq[i]);
|
||||
@@ -38,17 +38,17 @@ void Calibrator::reset()
|
||||
|
||||
void Calibrator::setBoardRows(int rows) {
|
||||
board_rows = rows;
|
||||
board_size = cv::Size(board_rows, board_cols);
|
||||
board_size = Size(board_rows, board_cols);
|
||||
}
|
||||
|
||||
void Calibrator::setBoardCols(int cols) {
|
||||
board_cols = cols;
|
||||
board_size = cv::Size(board_rows, board_cols);
|
||||
board_size = Size(board_rows, board_cols);
|
||||
}
|
||||
|
||||
void Calibrator::setCornerSize(double cornerSize) {
|
||||
dot_dis = cornerSize;
|
||||
corner_size = cv::Size2f(cornerSize, cornerSize);
|
||||
corner_size = Size2f(cornerSize, cornerSize);
|
||||
}
|
||||
|
||||
void Calibrator::setDotDiameter(double dotDiameter) {
|
||||
@@ -66,7 +66,7 @@ CalibrationData* Calibrator::calibrate()
|
||||
// detect corners ////////////////////////////////////
|
||||
for(int i = 0; i < frameSeqs.size(); i++)
|
||||
{
|
||||
std::vector<cv::Point2f> corners = extract_board_corners( frameSeqs[i][0] );
|
||||
std::vector<Point2f> corners = extract_board_corners( frameSeqs[i][0] );
|
||||
board_corners.push_back(corners);
|
||||
// std::cout<<i<<" corners: "<<corners.size()<<std::endl;
|
||||
// for(int j = 0; j < corners.size(); j++) {
|
||||
@@ -75,12 +75,12 @@ CalibrationData* Calibrator::calibrate()
|
||||
}
|
||||
|
||||
// collect projector correspondences
|
||||
std::vector<cv::Point2f> pcorners;
|
||||
std::vector<Point2f> pcorners;
|
||||
for(int i = 0; i < frameSeqs.size(); i++)
|
||||
{
|
||||
std::vector<cv::Point2f> const& corners = board_corners[i];
|
||||
cv::Mat pattern_image;
|
||||
cv::Mat min_max_image;
|
||||
std::vector<Point2f> const& corners = board_corners[i];
|
||||
Mat pattern_image;
|
||||
Mat min_max_image;
|
||||
if(corners.size()==0)
|
||||
{
|
||||
projector_corners.push_back(pcorners);
|
||||
@@ -95,25 +95,25 @@ CalibrationData* Calibrator::calibrate()
|
||||
}
|
||||
|
||||
pattern_list.push_back(pattern_image);
|
||||
for (std::vector<cv::Point2f>::const_iterator iter=corners.begin(); iter!=corners.end(); iter++)
|
||||
for (std::vector<Point2f>::const_iterator iter=corners.begin(); iter!=corners.end(); iter++)
|
||||
{
|
||||
const cv::Point2f & p = *iter;
|
||||
cv::Point2f q;
|
||||
const Point2f & p = *iter;
|
||||
Point2f q;
|
||||
//find an homography around p
|
||||
unsigned WINDOW_SIZE = 30;
|
||||
std::vector<cv::Point2f> img_points , proj_points;
|
||||
std::vector<Point2f> img_points , proj_points;
|
||||
if (p.x>WINDOW_SIZE && p.y>WINDOW_SIZE && p.x+WINDOW_SIZE<pattern_image.cols && p.y+WINDOW_SIZE<pattern_image.rows)
|
||||
{
|
||||
for (unsigned h=p.y-WINDOW_SIZE; h<p.y+WINDOW_SIZE; h++)
|
||||
{
|
||||
register const cv::Vec2f * row = pattern_image.ptr<cv::Vec2f>(h);
|
||||
register const cv::Vec2b * min_max_row = min_max_image.ptr<cv::Vec2b>(h);
|
||||
//cv::Vec2f * out_row = out_pattern_image.ptr<cv::Vec2f>(h);
|
||||
register const Vec2f * row = pattern_image.ptr<Vec2f>(h);
|
||||
register const Vec2b * min_max_row = min_max_image.ptr<Vec2b>(h);
|
||||
//Vec2f * out_row = out_pattern_image.ptr<Vec2f>(h);
|
||||
for (unsigned w=p.x-WINDOW_SIZE; w<p.x+WINDOW_SIZE; w++)
|
||||
{
|
||||
const cv::Vec2f & pattern = row[w];
|
||||
const cv::Vec2b & min_max = min_max_row[w];
|
||||
//cv::Vec2f & out_pattern = out_row[w];
|
||||
const Vec2f & pattern = row[w];
|
||||
const Vec2b & min_max = min_max_row[w];
|
||||
//Vec2f & out_pattern = out_row[w];
|
||||
if (std::isnan(pattern[0])>0 || std::isnan(pattern[1])>0)
|
||||
{
|
||||
continue;
|
||||
@@ -123,16 +123,16 @@ CalibrationData* Calibrator::calibrate()
|
||||
continue;
|
||||
}
|
||||
|
||||
img_points.push_back(cv::Point2f(w, h));
|
||||
proj_points.push_back(cv::Point2f(pattern));
|
||||
img_points.push_back(Point2f(w, h));
|
||||
proj_points.push_back(Point2f(pattern));
|
||||
|
||||
//out_pattern = pattern;
|
||||
}
|
||||
}
|
||||
cv::Mat H = cv::findHomography(img_points , proj_points, cv::RANSAC);
|
||||
Mat H = findHomography(img_points , proj_points, RANSAC);
|
||||
// std::cout << " H:\n" << H << std::endl;
|
||||
cv::Point3d Q = cv::Point3d(cv::Mat(H*cv::Mat(cv::Point3d(p.x , p.y , 1.0))));
|
||||
q = cv::Point2f(Q.x/Q.z ,Q.y/Q.z);
|
||||
Point3d Q = Point3d(Mat(H*Mat(Point3d(p.x , p.y , 1.0))));
|
||||
q = Point2f(Q.x/Q.z ,Q.y/Q.z);
|
||||
// jiuzheng
|
||||
// q.y += 118;
|
||||
pcorners.push_back(q);
|
||||
@@ -159,15 +159,15 @@ CalibrationData* Calibrator::calibrate()
|
||||
count++;
|
||||
}
|
||||
}
|
||||
std::vector<cv::Point3f> world_corners;
|
||||
std::vector<Point3f> world_corners;
|
||||
for (int h=0; h<board_size.height; h++)
|
||||
{
|
||||
for (int w=0; w<board_size.width; w++)
|
||||
{
|
||||
world_corners.push_back(cv::Point3f(corner_size.width * w, corner_size.height * h , 0.f));
|
||||
world_corners.push_back(Point3f(corner_size.width * w, corner_size.height * h , 0.f));
|
||||
}
|
||||
}
|
||||
std::vector<std::vector<cv::Point3f> > objectPoints;
|
||||
std::vector<std::vector<Point3f> > objectPoints;
|
||||
objectPoints.reserve(count);
|
||||
for (unsigned i=0; i<count; i++)
|
||||
{
|
||||
@@ -175,16 +175,16 @@ CalibrationData* Calibrator::calibrate()
|
||||
}
|
||||
|
||||
//generate world object coordinates
|
||||
std::vector<cv::Point3f> world_corners_p;
|
||||
std::vector<Point3f> world_corners_p;
|
||||
for (int h=0; h<board_size.height; h++)
|
||||
{
|
||||
for (int w=0; w<board_size.width; w++)
|
||||
{
|
||||
world_corners_p.push_back(cv::Point3f(corner_size.width * w , corner_size.height * h ,0.f));
|
||||
world_corners_p.push_back(Point3f(corner_size.width * w , corner_size.height * h ,0.f));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::vector<cv::Point3f> > objectPoints_p;
|
||||
std::vector<std::vector<Point3f> > objectPoints_p;
|
||||
objectPoints_p.reserve(count);
|
||||
for (unsigned i=0; i<count; i++)
|
||||
{
|
||||
@@ -196,48 +196,48 @@ CalibrationData* Calibrator::calibrate()
|
||||
pattern_list.resize(count);
|
||||
|
||||
int cal_flags = 0
|
||||
//+ cv::CALIB_FIX_K1
|
||||
//+ cv::CALIB_FIX_K2
|
||||
//+ cv::CALIB_ZERO_TANGENT_DIST
|
||||
+ cv::CALIB_FIX_K3
|
||||
//+ CALIB_FIX_K1
|
||||
//+ CALIB_FIX_K2
|
||||
//+ CALIB_ZERO_TANGENT_DIST
|
||||
+ CALIB_FIX_K3
|
||||
;
|
||||
//calibrate the camera ////////////////////////////////////
|
||||
std::vector<cv::Mat> cam_rvecs , cam_tvecs;
|
||||
std::vector<Mat> cam_rvecs , cam_tvecs;
|
||||
int cam_flags = cal_flags;
|
||||
cv::Size imageSize = frameSeqs[0][0].size();
|
||||
res->cam_error = cv::calibrateCamera(objectPoints , board_corners , imageSize , res->Kc , res->kc ,cam_rvecs , cam_tvecs);
|
||||
Size imageSize = frameSeqs[0][0].size();
|
||||
res->cam_error = calibrateCamera(objectPoints , board_corners , imageSize , res->Kc , res->kc ,cam_rvecs , cam_tvecs);
|
||||
std::cout<<"calibrate the camera !"<<std::endl;
|
||||
|
||||
//calibrate the projector ////////////////////////////////////
|
||||
std::vector<cv::Mat> proj_rvecs , proj_tvecs;
|
||||
std::vector<Mat> proj_rvecs , proj_tvecs;
|
||||
int proj_flags = cal_flags;
|
||||
cv::Size projector_size(912, 1140);
|
||||
res->proj_error = cv::calibrateCamera(objectPoints_p , projector_corners, projector_size , res->Kp , res->kp , proj_rvecs , proj_tvecs);
|
||||
Size projector_size(912, 1140);
|
||||
res->proj_error = calibrateCamera(objectPoints_p , projector_corners, projector_size , res->Kp , res->kp , proj_rvecs , proj_tvecs);
|
||||
|
||||
std::cout<<"calibrate the projector !"<<std::endl;
|
||||
//stereo calibration
|
||||
cv::Mat E, F;
|
||||
res->stereo_error = cv::stereoCalibrate(objectPoints , board_corners , projector_corners ,
|
||||
Mat E, F;
|
||||
res->stereo_error = stereoCalibrate(objectPoints , board_corners , projector_corners ,
|
||||
res->Kc , res->kc , res->Kp ,res->kp ,imageSize /*ignored*/ ,
|
||||
res->Rp , res->Tp , E , F );
|
||||
// res->stereo_error = cv::stereoCalibrate(objectPoints , board_corners , projector_corners , res->Kc , res->kc , res->Kp ,res->kp ,imageSize /*ignored*/ , res->Rp , res->Tp , E , F ,
|
||||
// cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS ,50 ,DBL_EPSILON) ,
|
||||
// cv::CALIB_FIX_INTRINSIC /*cv::CALIB_USE_INTRINSIC_GUESS + cal_flags*/);
|
||||
// res->stereo_error = stereoCalibrate(objectPoints , board_corners , projector_corners , res->Kc , res->kc , res->Kp ,res->kp ,imageSize /*ignored*/ , res->Rp , res->Tp , E , F ,
|
||||
// TermCriteria(TermCriteria::COUNT + TermCriteria::EPS ,50 ,DBL_EPSILON) ,
|
||||
// CALIB_FIX_INTRINSIC /*CALIB_USE_INTRINSIC_GUESS + cal_flags*/);
|
||||
std::cout<<"stereo calibration !"<<std::endl;
|
||||
|
||||
|
||||
cv::FileStorage fsc("rtc.xml", cv::FileStorage::WRITE);
|
||||
cv::FileStorage fsp("rtp.xml", cv::FileStorage::WRITE);
|
||||
FileStorage fsc("rtc.xml", FileStorage::WRITE);
|
||||
FileStorage fsp("rtp.xml", FileStorage::WRITE);
|
||||
|
||||
// objectPoints projector_corners board_corners
|
||||
std::ofstream opout("objectPoints.txt");
|
||||
std::ofstream pcout("projector_corners.txt");
|
||||
std::ofstream ccout("board_corners.txt");
|
||||
for (int i = 0; i < objectPoints.size(); i++) {
|
||||
fsc << "R" + std::to_string(i) << cv::Mat(cam_rvecs[i]);
|
||||
fsc << "T" + std::to_string(i) << cv::Mat(cam_tvecs[i]);
|
||||
fsp << "R" + std::to_string(i) << cv::Mat(proj_rvecs[i]);
|
||||
fsp << "T" + std::to_string(i) << cv::Mat(proj_tvecs[i]);
|
||||
fsc << "R" + std::to_string(i) << Mat(cam_rvecs[i]);
|
||||
fsc << "T" + std::to_string(i) << Mat(cam_tvecs[i]);
|
||||
fsp << "R" + std::to_string(i) << Mat(proj_rvecs[i]);
|
||||
fsp << "T" + std::to_string(i) << Mat(proj_tvecs[i]);
|
||||
for (int j = 0; j < objectPoints[i].size(); j++) {
|
||||
opout << objectPoints[i][j] << std::endl;
|
||||
pcout << projector_corners[i][j] << std::endl;
|
||||
@@ -254,24 +254,24 @@ CalibrationData* Calibrator::calibrate()
|
||||
|
||||
}
|
||||
|
||||
std::vector<cv::Point2f> Calibrator::extract_board_corners(cv::Mat &gray_image)
|
||||
std::vector<Point2f> Calibrator::extract_board_corners(Mat &gray_image)
|
||||
{
|
||||
std::vector<cv::Point2f> corners;
|
||||
std::vector<Point2f> corners;
|
||||
int image_scale = 1;
|
||||
if (gray_image.rows<1)
|
||||
{
|
||||
return corners;
|
||||
}
|
||||
cv::Size imageSize = gray_image.size();
|
||||
Size imageSize = gray_image.size();
|
||||
if (imageSize.width>1024)
|
||||
{
|
||||
image_scale = imageSize.width/1024;
|
||||
}
|
||||
|
||||
cv::Mat small_img;
|
||||
Mat small_img;
|
||||
if (image_scale>1)
|
||||
{
|
||||
cv::resize(gray_image , small_img , cv::Size(gray_image.cols/image_scale , gray_image.rows/image_scale));
|
||||
resize(gray_image , small_img , Size(gray_image.cols/image_scale , gray_image.rows/image_scale));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -279,27 +279,27 @@ std::vector<cv::Point2f> Calibrator::extract_board_corners(cv::Mat &gray_image)
|
||||
}
|
||||
|
||||
if(board_type == Chessboard) {
|
||||
cv::findChessboardCorners(small_img, board_size, corners);
|
||||
findChessboardCorners(small_img, board_size, corners);
|
||||
}
|
||||
else if(board_type == Circular) {
|
||||
cv::findCirclesGrid(small_img, board_size, corners);
|
||||
findCirclesGrid(small_img, board_size, corners);
|
||||
}
|
||||
|
||||
if (corners.size())
|
||||
{
|
||||
for (std::vector<cv::Point2f>::iterator iter=corners.begin(); iter!=corners.end(); iter++)
|
||||
for (std::vector<Point2f>::iterator iter=corners.begin(); iter!=corners.end(); iter++)
|
||||
{
|
||||
*iter = image_scale*(*iter);
|
||||
}
|
||||
cv::cornerSubPix(gray_image , corners , cv::Size(11 , 11) , cv::Size(-1 , -1) ,
|
||||
cv::TermCriteria(cv::TermCriteria::EPS + cv::TermCriteria::MAX_ITER, 30 , 0.1));
|
||||
cornerSubPix(gray_image , corners , Size(11 , 11) , Size(-1 , -1) ,
|
||||
TermCriteria(TermCriteria::EPS + TermCriteria::MAX_ITER, 30 , 0.1));
|
||||
}
|
||||
|
||||
return corners;
|
||||
}
|
||||
|
||||
|
||||
bool Calibrator::decode_gray_set(int ind , cv::Mat & pattern_image, cv::Mat & min_max_image)
|
||||
bool Calibrator::decode_gray_set(int ind , Mat & pattern_image, Mat & min_max_image)
|
||||
{
|
||||
if (ind >= frameSeqs.size())
|
||||
{ //out of bounds
|
||||
@@ -308,7 +308,7 @@ bool Calibrator::decode_gray_set(int ind , cv::Mat & pattern_image, cv::Mat & m
|
||||
|
||||
//estimate direct component
|
||||
//b = config.value("robust_estimation/b" DEFAULT_B).toFloat();
|
||||
std::vector<cv::Mat> images;
|
||||
std::vector<Mat> images;
|
||||
// QList<unsigned> direct_component_images(QList<unsigned>() << 15 << 16 << 17 << 18 << 35 << 36 << 37 << 38);
|
||||
int total_images = frameSeqs[ind].size();
|
||||
int total_patterns = total_images/2 - 1;
|
||||
@@ -326,12 +326,12 @@ bool Calibrator::decode_gray_set(int ind , cv::Mat & pattern_image, cv::Mat & m
|
||||
{
|
||||
images.push_back(frameSeqs[ind][i]);
|
||||
}
|
||||
cv::Mat direct_light = sl::estimate_direct_light(images, b);
|
||||
Mat direct_light = sl::estimate_direct_light(images, b);
|
||||
|
||||
//m = config.value("robust_estimation/m" DEFAULT_M).toUInt();
|
||||
// return sl::decode_pattern(frameSeqs[ind] , pattern_image , min_max_image , sl::RobustDecode|sl::GrayPatternDecode , direct_light, m);
|
||||
|
||||
cv::Size projector_size(912, 1140);
|
||||
Size projector_size(912, 1140);
|
||||
bool rv = sl::decode_pattern(frameSeqs[ind], pattern_image, min_max_image, projector_size, sl::RobustDecode|sl::GrayPatternDecode, direct_light, m);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ void MyThread::run()
|
||||
io::loadPCDFile(pcd, *cloudPtr);
|
||||
cloud = *cloudPtr;
|
||||
}
|
||||
|
||||
auto pclData = PointCloudData::getInstance(cloud);
|
||||
pclData->setCloud(cloud);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <qthread.h>
|
||||
#include <pcl/point_types.h>
|
||||
#include <pcl/io/vtk_lib_io.h>
|
||||
#include "PointCloudData.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace pcl;
|
||||
|
||||
70
Classes/PointCloudData.cpp
Normal file
70
Classes/PointCloudData.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include "PointCloudData.h"
|
||||
|
||||
PointCloudData* PointCloudData::instance = nullptr;
|
||||
|
||||
PointCloudData::PointCloudData(PointCloud<PointXYZRGB> cloudArg)
|
||||
{
|
||||
cloud = cloudArg;
|
||||
num = 0;
|
||||
}
|
||||
|
||||
PointCloudData* PointCloudData::getInstance(PointCloud<PointXYZRGB> cloudArg)
|
||||
{
|
||||
if (instance == nullptr) instance = new PointCloudData(cloudArg);
|
||||
return instance;
|
||||
}
|
||||
|
||||
PointCloudData* PointCloudData::getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
PointCloud<PointXYZRGB> PointCloudData::getCloud() const{
|
||||
return cloud;
|
||||
}
|
||||
|
||||
void PointCloudData::setCloud(PointCloud<PointXYZRGB> cloudArg){
|
||||
cloud= cloudArg;
|
||||
}
|
||||
|
||||
boost::shared_ptr<visualization::PCLVisualizer> PointCloudData::getViewer()
|
||||
{
|
||||
return viewer;
|
||||
}
|
||||
|
||||
|
||||
void PointCloudData::setViewer(boost::shared_ptr<visualization::PCLVisualizer> viewerArg)
|
||||
{
|
||||
viewer = viewerArg;
|
||||
}
|
||||
|
||||
std::vector<int> PointCloudData::getIndices()
|
||||
{
|
||||
return indices;
|
||||
}
|
||||
|
||||
void PointCloudData::setIndices(std::vector<int> indicesArg)
|
||||
{
|
||||
indices = indicesArg;
|
||||
}
|
||||
|
||||
Ui::ReconstructionClass PointCloudData::getUI()
|
||||
{
|
||||
return ui;
|
||||
}
|
||||
|
||||
void PointCloudData::setUI(Ui::ReconstructionClass uiArg)
|
||||
{
|
||||
ui = uiArg;
|
||||
}
|
||||
|
||||
int PointCloudData::getNum()
|
||||
{
|
||||
return num;
|
||||
}
|
||||
|
||||
void PointCloudData::setNum()
|
||||
{
|
||||
num++;
|
||||
}
|
||||
|
||||
35
Classes/PointCloudData.h
Normal file
35
Classes/PointCloudData.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include <pcl/point_types.h>
|
||||
#include <pcl/io/pcd_io.h>
|
||||
#include <pcl/visualization/pcl_visualizer.h>
|
||||
#include <pcl/io/vtk_lib_io.h>
|
||||
#include "Reconstruction.h"
|
||||
|
||||
using namespace pcl;
|
||||
|
||||
class PointCloudData
|
||||
{
|
||||
private:
|
||||
PointCloudData(PointCloud<PointXYZRGB> cloudArg);
|
||||
~PointCloudData(){};
|
||||
PointCloud<PointXYZRGB> cloud;
|
||||
boost::shared_ptr<visualization::PCLVisualizer> viewer;
|
||||
std::vector<int> indices;
|
||||
Ui::ReconstructionClass ui;
|
||||
int num;// 用于框选删除点云的名称
|
||||
|
||||
public:
|
||||
static PointCloudData* getInstance();
|
||||
static PointCloudData* getInstance(PointCloud<PointXYZRGB> cloudArg);
|
||||
static PointCloudData* instance ;
|
||||
PointCloud<PointXYZRGB> getCloud() const;
|
||||
void setCloud(PointCloud<PointXYZRGB> cloudArg);
|
||||
boost::shared_ptr<visualization::PCLVisualizer> getViewer();
|
||||
void setViewer(boost::shared_ptr<visualization::PCLVisualizer> viewerArg);
|
||||
std::vector<int> getIndices();
|
||||
void setIndices(std::vector<int> indicesArg);
|
||||
Ui::ReconstructionClass getUI();
|
||||
void setUI(Ui::ReconstructionClass uiArg);
|
||||
int getNum();
|
||||
void setNum();
|
||||
};
|
||||
@@ -134,42 +134,98 @@ void Reconstruction::on_pushButton_3_clicked()
|
||||
#pragma endregion
|
||||
|
||||
#pragma region 多线程
|
||||
// 点云框选回调函数
|
||||
void pp_callback(const visualization::AreaPickingEvent& event, void* args)
|
||||
{
|
||||
auto pclData = PointCloudData::getInstance();
|
||||
PointCloud<PointXYZRGB>::Ptr cloudPtr(new PointCloud<PointXYZRGB>);
|
||||
cloudPtr = pclData->getCloud().makeShared();
|
||||
int num = pclData->getNum();
|
||||
std::vector<int> indices;
|
||||
|
||||
if (event.getPointsIndices(indices) == -1)
|
||||
return;
|
||||
// cout << indices.size() << "\n";
|
||||
PointCloud<PointXYZRGB>::Ptr clicked_points_3d(new PointCloud<PointXYZRGB>);
|
||||
for (int i = 0; i < indices.size(); ++i)
|
||||
{
|
||||
clicked_points_3d->points.push_back(cloudPtr->points.at(indices[i]));
|
||||
}
|
||||
visualization::PointCloudColorHandlerCustom<PointXYZRGB> red(clicked_points_3d, 255, 0, 0);
|
||||
std::stringstream ss;
|
||||
std::string cloudName;
|
||||
pclData->setNum();
|
||||
ss <<num++;
|
||||
ss >> cloudName;
|
||||
cloudName += "_cloudName";
|
||||
|
||||
pclData->getViewer()->addPointCloud(clicked_points_3d, red, cloudName);
|
||||
pclData->getViewer()->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 10, cloudName);
|
||||
// pclData->getViewer()->updatePointCloud(clicked_points_3d,"cloudName");
|
||||
pclData->setIndices(indices);
|
||||
pclData->getUI().qvtkWidget->SetRenderWindow(pclData->getViewer()->getRenderWindow());
|
||||
pclData->getUI().qvtkWidget->update();
|
||||
|
||||
}
|
||||
|
||||
void Reconstruction::setCloud()
|
||||
{
|
||||
cout << cloud.width;
|
||||
ui.label_9->setVisible(false);
|
||||
|
||||
if(loadingStatus)
|
||||
|
||||
if (loadingStatus)
|
||||
{
|
||||
cloud = t->getCloud();
|
||||
loadingStatus = false;
|
||||
}
|
||||
|
||||
if(reconstructStatus)
|
||||
if (reconstructStatus)
|
||||
{
|
||||
reconstructStatus = false;
|
||||
}
|
||||
cout << cloud[0].r;
|
||||
|
||||
|
||||
updateQVTK(cloud, color);
|
||||
}
|
||||
|
||||
void Reconstruction::updateQVTK(PointCloud<PointXYZRGB> cloud, QColor color)
|
||||
{
|
||||
boost::shared_ptr<visualization::PCLVisualizer> viewer(new visualization::PCLVisualizer("3D Viewer"));
|
||||
viewer->setBackgroundColor(0.458, 0.529, 0.844);
|
||||
viewer->setPointCloudRenderingProperties(visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud");
|
||||
boost::shared_ptr<visualization::PCLVisualizer> viewer;
|
||||
visualization::Camera camera;
|
||||
if (PointCloudData::getInstance() != nullptr)
|
||||
{
|
||||
auto pclData = PointCloudData::getInstance();
|
||||
pclData->setCloud(cloud);
|
||||
pclData->getViewer()->getCameraParameters(camera);
|
||||
cout<<cloud.size()<<"," << camera.pos[0] << "," << camera.pos[1] << "," << camera.pos[2] << "," << camera.view[0] <<
|
||||
"," << camera.view[1] << "," << camera.view[2] << "\n";
|
||||
viewer = pclData->getViewer();
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::shared_ptr<visualization::PCLVisualizer> viewerArg(new visualization::PCLVisualizer("3D Viewer"));
|
||||
viewer=viewerArg;
|
||||
viewer->setBackgroundColor(0.458, 0.529, 0.844);
|
||||
auto pclData = PointCloudData::getInstance(cloud);
|
||||
pclData->setViewer(viewer);
|
||||
pclData->setUI(ui);
|
||||
}
|
||||
double size=1;
|
||||
viewer->getPointCloudRenderingProperties(visualization::PCL_VISUALIZER_POINT_SIZE, size, "cloud");
|
||||
viewer->removeAllPointClouds();
|
||||
// viewer->setPointCloudRenderingProperties(visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud");
|
||||
if (cloud.size() != 0)
|
||||
{
|
||||
PointCloud<PointXYZRGB>::Ptr cloudPtr(new PointCloud<PointXYZRGB>);
|
||||
cloudPtr = cloud.makeShared();
|
||||
|
||||
int x = int(color.redF() * 255);
|
||||
int y = int(color.greenF() * 255);
|
||||
int z = int(color.blueF() * 255);
|
||||
visualization::PointCloudColorHandlerCustom<PointXYZRGB> cloud_color(cloudPtr, x, y, z);// 统一处理点云颜色
|
||||
visualization::PointCloudColorHandlerCustom<PointXYZRGB> cloud_color(cloudPtr, x, y, z); // 统一处理点云颜色
|
||||
viewer->addPointCloud(cloudPtr, cloud_color, "cloud");
|
||||
viewer->setPointCloudRenderingProperties(visualization::PCL_VISUALIZER_POINT_SIZE, 1, "cloud");
|
||||
viewer->setPointCloudRenderingProperties(visualization::PCL_VISUALIZER_POINT_SIZE, size, "cloud");
|
||||
// viewer->setCameraPosition(camera.pos[0], camera.pos[1], camera.pos[2], camera.view[0], camera.view[1], camera.view[2],0,0,1);
|
||||
viewer->registerAreaPickingCallback(pp_callback, (void*)&cloud);
|
||||
}
|
||||
ui.qvtkWidget->SetRenderWindow(viewer->getRenderWindow());
|
||||
ui.qvtkWidget->update();
|
||||
@@ -562,7 +618,7 @@ void Reconstruction::on_pushButton_10_clicked()
|
||||
|
||||
screen->grabWindow(ui.label_21->winId()).save(fileName);
|
||||
|
||||
|
||||
|
||||
// QImage iim(picPath); //创建一个图片对象,存储源图片
|
||||
// QPainter painter(&iim); //设置绘画设备
|
||||
// QFile file(fileName); //创建一个文件对象,存储用户选择的文件
|
||||
@@ -582,7 +638,6 @@ void Reconstruction::on_pushButton_10_clicked()
|
||||
QMessageBox mesg;
|
||||
mesg.warning(this, "WARNING", "Haven't taken picture!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 开始重建
|
||||
@@ -610,15 +665,31 @@ void Reconstruction::on_pushButton_11_clicked()
|
||||
void Reconstruction::on_pushButton_12_clicked()
|
||||
{
|
||||
// todo 异常点剔除
|
||||
auto pclData = PointCloudData::getInstance();
|
||||
// cloud = pclData->getCloud();
|
||||
auto indices = pclData->getIndices();
|
||||
for (auto i = 0; i < indices.size(); ++i)
|
||||
{
|
||||
// cout << "i:" << i << " indices:" << indices[i] << " diff:" << indices[i]-i << "\n";
|
||||
auto index = cloud.begin() + (indices[i] - i);
|
||||
// cout << "size:" << cloudPtr->size() << ",index:" << indices[i] - i<<"\n" ;
|
||||
if (indices[i] - i >= cloud.size())break;
|
||||
cloud.erase(index);
|
||||
}
|
||||
indices.clear();
|
||||
pclData->setIndices(indices);
|
||||
pclData->setCloud(cloud);
|
||||
updateQVTK(cloud, color);
|
||||
// pclData->getViewer()->updatePointCloud();
|
||||
}
|
||||
|
||||
// 导入点云
|
||||
void Reconstruction::on_pushButton_13_clicked()
|
||||
{
|
||||
if (loadingStatus)
|
||||
if (loadingStatus || reconstructStatus)
|
||||
{
|
||||
QMessageBox mesg;
|
||||
mesg.warning(this, "WARNING", "正在加载… ");
|
||||
mesg.warning(this, "WARNING", "There is a Point Cloud Loading.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -632,7 +703,11 @@ void Reconstruction::on_pushButton_13_clicked()
|
||||
mesg.warning(this, "WARNING", "Failed to open file");
|
||||
return;
|
||||
}
|
||||
|
||||
boost::shared_ptr<visualization::PCLVisualizer> viewer(new visualization::PCLVisualizer("3D Viewer"));
|
||||
viewer->setBackgroundColor(0.458, 0.529, 0.844);
|
||||
ui.qvtkWidget->SetRenderWindow(viewer->getRenderWindow());
|
||||
auto pclData = PointCloudData::getInstance(cloud);
|
||||
pclData->setViewer(viewer);
|
||||
ui.label_9->setVisible(true);
|
||||
QCoreApplication::processEvents();
|
||||
t->setPcd(fileName);
|
||||
@@ -667,8 +742,10 @@ void Reconstruction::on_pushButton_15_clicked()
|
||||
// 颜色选取
|
||||
void Reconstruction::on_pushButton_16_clicked()
|
||||
{
|
||||
auto pclData = PointCloudData::getInstance(cloud);
|
||||
QColor colortmp = QColorDialog::getColor(Qt::black);
|
||||
if (colortmp.isValid()) {
|
||||
if (colortmp.isValid())
|
||||
{
|
||||
color = colortmp;
|
||||
updateQVTK(cloud, color);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "CoreAlgorithm.h"
|
||||
#include "MyThread.h"
|
||||
#include "YourThread.h"
|
||||
#include "PointCloudData.h"
|
||||
#include "Help.h"
|
||||
#include <iostream>
|
||||
using namespace pcl;
|
||||
|
||||
@@ -63,4 +63,7 @@ void YourThread::run()
|
||||
cloud->points[i].z = coordinates[index].at<float>(0, 2);
|
||||
index++;
|
||||
}
|
||||
|
||||
auto pclData = PointCloudData::getInstance(*cloud);
|
||||
pclData->setCloud(*cloud);
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <pcl/point_types.h>
|
||||
#include <pcl/io/vtk_lib_io.h>
|
||||
#include "CoreAlgorithm.h"
|
||||
#include "PointCloudData.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace pcl;
|
||||
|
||||
3071
Data/result/1.pcd
Normal file
3071
Data/result/1.pcd
Normal file
File diff suppressed because it is too large
Load Diff
176786
Data/result/ball.pcd
Normal file
176786
Data/result/ball.pcd
Normal file
File diff suppressed because it is too large
Load Diff
35958
Data/result/bunny.pcd
Normal file
35958
Data/result/bunny.pcd
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Data/result/table_scene_lms400.pcd
Normal file
BIN
Data/result/table_scene_lms400.pcd
Normal file
Binary file not shown.
@@ -131,6 +131,7 @@
|
||||
<ClCompile Include="Classes\log2.cpp" />
|
||||
<ClCompile Include="Classes\main.cpp" />
|
||||
<ClCompile Include="Classes\MyThread.cpp" />
|
||||
<ClCompile Include="Classes\PointCloudData.cpp" />
|
||||
<ClCompile Include="Classes\ProjectorLC4500.cpp" />
|
||||
<ClCompile Include="Classes\Reconstruction.cpp" />
|
||||
<ClCompile Include="Classes\rtGetInf.cpp" />
|
||||
@@ -156,6 +157,7 @@
|
||||
<ClInclude Include="Classes\Camera.h" />
|
||||
<ClInclude Include="Classes\CameraPointGrey.h" />
|
||||
<ClInclude Include="Classes\CameraArguments.h" />
|
||||
<ClInclude Include="Classes\PointCloudData.h" />
|
||||
<ClInclude Include="Classes\YourThread.h" />
|
||||
<QtMoc Include="Classes\Loading.h" />
|
||||
<QtMoc Include="Classes\DisplayPic.h" />
|
||||
|
||||
@@ -59,6 +59,9 @@
|
||||
<Filter Include="src\reconstruction\projector">
|
||||
<UniqueIdentifier>{762af5a3-10df-4dc7-8ce8-ed2501d9eb12}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="src\reconstruction\pointcloud">
|
||||
<UniqueIdentifier>{cdf9f84f-4a3a-4fc8-b596-038eb3990675}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="UI\Reconstruction.ui">
|
||||
@@ -81,9 +84,6 @@
|
||||
<ClCompile Include="Classes\Reconstruction.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Classes\CameraArguments.cpp">
|
||||
<Filter>src\reconstruction</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Classes\Loading.cpp">
|
||||
<Filter>src\scene\loadingscene</Filter>
|
||||
</ClCompile>
|
||||
@@ -198,6 +198,12 @@
|
||||
<ClCompile Include="Classes\YourThread.cpp">
|
||||
<Filter>src\scene\mainscene</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Classes\CameraArguments.cpp">
|
||||
<Filter>src\reconstruction\calibrator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Classes\PointCloudData.cpp">
|
||||
<Filter>src\reconstruction\pointcloud</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="Classes\Reconstruction.h">
|
||||
@@ -219,9 +225,6 @@
|
||||
</QtRcc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Classes\CameraArguments.h">
|
||||
<Filter>src\reconstruction</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Classes\cwt_emxAPI.h">
|
||||
<Filter>src\reconstruction\cwt</Filter>
|
||||
</ClInclude>
|
||||
@@ -345,5 +348,11 @@
|
||||
<ClInclude Include="Classes\YourThread.h">
|
||||
<Filter>src\scene\mainscene</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Classes\CameraArguments.h">
|
||||
<Filter>src\reconstruction\calibrator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Classes\PointCloudData.h">
|
||||
<Filter>src\reconstruction\pointcloud</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
152
et --soft HEAD^q
152
et --soft HEAD^q
@@ -1,152 +0,0 @@
|
||||
[33mcommit 263248a52082067cca0360e3ce8a125427d9e8c1[m[33m ([m[1;36mHEAD -> [m[1;32mmaster[m[33m)[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Sat Apr 4 09:59:50 2020 +0800
|
||||
|
||||
修改vtk显示点云
|
||||
|
||||
[33mcommit 0f1d54ae5950b98f5095be44b7ada61d304ab32d[m[33m ([m[1;31morigin/master[m[33m)[m
|
||||
Author: ZESl <823989065@qq.com>
|
||||
Date: Thu Apr 2 10:48:22 2020 +0800
|
||||
|
||||
ui 0.7 增加按钮图标,增加qss,修改部分方法,界面优化
|
||||
|
||||
[33mcommit f6d84c5470b7a3adbbfc96a45b77590b8dacd8a4[m
|
||||
Author: ZESl <823989065@qq.com>
|
||||
Date: Wed Apr 1 18:50:56 2020 +0800
|
||||
|
||||
修复bug 测试是否连接成功
|
||||
|
||||
[33mcommit 689b04a05cfcbbbd00464941da3b567191621813[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Wed Feb 12 16:55:39 2020 +0800
|
||||
|
||||
wo shi yi ge python/c++ fan yi ji
|
||||
|
||||
[33mcommit 2c2a0e2ae036552bd69a79821fa317946a3ff8b5[m
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Tue Feb 11 17:25:57 2020 +0800
|
||||
|
||||
ui 0.6 界面调整
|
||||
|
||||
[33mcommit 7c028498e845f3b76ac582710820631afa9c3f8d[m
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Fri Feb 7 19:53:11 2020 +0800
|
||||
|
||||
ui 0.5 载入界面(loading) ui修改
|
||||
|
||||
[33mcommit 5511dd247d572ad0eead9303374d7cbf9b889ec5[m
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Fri Feb 7 15:25:20 2020 +0800
|
||||
|
||||
ui 0.4 界面微小改动 添加QSS文件 仍需继续调整
|
||||
|
||||
[33mcommit 856f11a29696cc3278dcc7cd4f2e1d9ff2f18117[m
|
||||
Merge: 4cc40c90 7fe10d49
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Wed Feb 5 11:08:44 2020 +0800
|
||||
|
||||
Merge remote-tracking branch 'refs/remotes/origin/master'
|
||||
|
||||
[33mcommit 4cc40c903c863cffd8a998380a0778460b6df732[m
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Wed Feb 5 10:55:39 2020 +0800
|
||||
|
||||
ui 0.3 添加存储图像等功能 按钮进一步优化
|
||||
|
||||
[33mcommit 7fe10d49e57dcef672ff00e02f6c82903cede195[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Mon Feb 3 19:50:47 2020 +0800
|
||||
|
||||
del a file
|
||||
|
||||
[33mcommit 0e7376ccd5c729422976c8bfc9b1fa77e2a17884[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Mon Feb 3 19:48:30 2020 +0800
|
||||
|
||||
add some function of reconstruciton
|
||||
|
||||
[33mcommit 8ae4c44bece2ae61ed905de19276926c26b3b7ca[m
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Mon Feb 3 15:37:04 2020 +0800
|
||||
|
||||
ui 0.3 添加图案投影拍照后展示照片的界面 DisplayPic
|
||||
|
||||
[33mcommit f4d6cc81b5ecb87d6c948d3bece5deac426771e1[m
|
||||
Merge: 178c1ac1 257aed70
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Sat Feb 1 21:46:27 2020 +0800
|
||||
|
||||
Merge branch 'master' of https://github.com/Tang1705/Reconstruction
|
||||
|
||||
[33mcommit 178c1ac179e3e0138882089e448046e978db24b2[m
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Sat Feb 1 21:26:08 2020 +0800
|
||||
|
||||
ui 0.2 添加loading界面 待美观
|
||||
|
||||
[33mcommit 257aed703040f85b81b2d7f08a8cd86b23ba99d5[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Sat Feb 1 18:35:26 2020 +0800
|
||||
|
||||
add camera arguments class
|
||||
|
||||
[33mcommit c0cb15818bdb0a49dd3ea87b95c80f11aafb611e[m
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Fri Jan 31 22:47:57 2020 +0800
|
||||
|
||||
ui 0.1 继续按钮填充
|
||||
|
||||
[33mcommit 897fa805822ba731f3c650ae8a01d0ef223d36e8[m
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Fri Jan 31 22:19:08 2020 +0800
|
||||
|
||||
ui 0.1 部分按钮填充 + bug修复
|
||||
|
||||
[33mcommit 7d4d5f742313936c61154a284315957f3e8b4508[m
|
||||
Author: Norah <30373753+ZESl@users.noreply.github.com>
|
||||
Date: Thu Jan 30 23:04:10 2020 +0800
|
||||
|
||||
ui 0.1
|
||||
|
||||
[33mcommit 1fc76542f76abb89be52c023113244da5a05e149[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Wed Jan 29 17:40:22 2020 +0800
|
||||
|
||||
fix errors
|
||||
|
||||
[33mcommit a53f2ed8c52294a02b04bf110b4af522b9df9d84[m
|
||||
Merge: a71fa476 54c5864e
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Mon Jan 27 20:21:47 2020 +0800
|
||||
|
||||
Merge branch 'master' of https://github.com/Tang1705/Reconstruction
|
||||
|
||||
[33mcommit a71fa476202ab6800a3800b5807ec4db7962f8c9[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Mon Jan 27 20:20:56 2020 +0800
|
||||
|
||||
add part of opencv
|
||||
|
||||
[33mcommit 54c5864e7e7f938f4320b0742628ea5484c65762[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Mon Jan 27 19:26:57 2020 +0800
|
||||
|
||||
add part of opencv
|
||||
|
||||
[33mcommit 0c4ac1d8bb49f7eb98fb4e7e8866902df639dcdb[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Mon Jan 27 18:56:50 2020 +0800
|
||||
|
||||
add flycapture
|
||||
|
||||
[33mcommit 1b7d21abf5549c3272e874777ec3774fa105b401[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Sun Jan 26 18:08:38 2020 +0800
|
||||
|
||||
add lib
|
||||
|
||||
[33mcommit 9f79c4a67939400e003a9a4a5b1411ff2aef9e0b[m
|
||||
Author: Tang1705 <17301138@bjtu.edu.cn>
|
||||
Date: Sun Jan 26 17:45:44 2020 +0800
|
||||
|
||||
init project
|
||||
170470
result.pcd
170470
result.pcd
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -38,4 +38,5 @@ D:\BJTU\Reconstruction\Lib\FlyCapture2\include\Utilities.h(1,1): warning C4819:
|
||||
D:\BJTU\Reconstruction\Lib\FlyCapture2\include\AVIRecorder.h(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
|
||||
D:\BJTU\Reconstruction\Lib\FlyCapture2\include\TopologyNode.h(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
|
||||
D:\BJTU\Reconstruction\Lib\FlyCapture2\include\ImageStatistics.h(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
|
||||
D:\BJTU\Reconstruction\Classes\Reconstruction.cpp(146,43): warning C4806: “==”: 不安全操作: 从类型“bool”提升到类型“int”的值不能等于给定的常量
|
||||
Reconstruction.vcxproj -> D:\BJTU\Reconstruction\x64\Debug\Reconstruction.exe
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user