Permalink
Browse files

cleaning up

  • Loading branch information...
1 parent d0e2b3a commit d4ecefe70cc1ec75dfda93037617cc1a99ab618e Nikolas Engelhard committed May 9, 2012
Showing with 615 additions and 144 deletions.
  1. +1 −1 CMakeLists.txt
  2. +0 −37 include/find_rect.h
  3. +98 −0 include/projector_calibrator.h
  4. +1 −1 manifest.xml
  5. +4 −0 src/cloud_processing.cpp
  6. +0 −54 src/find_rect.cpp
  7. +74 −51 src/main.cpp
  8. +437 −0 src/projector_calibrator.cpp
View
@@ -30,4 +30,4 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
#target_link_libraries(example ${PROJECT_NAME})
-rosbuild_add_executable(subscriber src/main.cpp src/cloud_processing.cpp src/calibration.cpp src/user_input.cpp src/misc.cpp src/meshing.cpp src/find_rect.cpp)
+rosbuild_add_executable(subscriber src/main.cpp src/cloud_processing.cpp src/calibration.cpp src/user_input.cpp src/misc.cpp src/meshing.cpp src/projector_calibrator.cpp)
View
@@ -1,37 +0,0 @@
-/*
- * find_rect.h
- *
- * Created on: Apr 23, 2012
- * Author: engelhan
- */
-
-#ifndef FIND_RECT_H_
-#define FIND_RECT_H_
-
-
-#include "cloud_processing.h"
-#include "ros/ros.h"
-#include <pcl/filters/passthrough.h>
-#include <pcl/filters/voxel_grid.h>
-
-struct Rect_finder{
-
- ros::NodeHandle nh;
- ros::Publisher pub_rect;
-
-
- Cloud find_rect(Cloud& cloud);
-
- Rect_finder(){
- pub_rect = nh.advertise<Cloud>("rectangle", 1);
- }
-
-
-
-
-};
-
-
-
-
-#endif /* FIND_RECT_H_ */
@@ -0,0 +1,98 @@
+/*
+ * projector_calibrator.h
+ *
+ * Created on: May 9, 2012
+ * Author: Nikolas Engelhard
+ */
+
+#ifndef PROJECTOR_CALIBRATOR_H_
+#define PROJECTOR_CALIBRATOR_H_
+
+#include "cloud_processing.h"
+#include "calibration.h"
+#include "user_input.h"
+#include "misc.h"
+#include "meshing.h"
+
+#include <opencv/cv.h>
+#include <opencv/highgui.h>
+#include <opencv2/imgproc/imgproc.hpp>
+
+
+class Projector_Calibrator {
+
+
+ cv::Size C_checkboard_size;
+
+ cv::Size C_proj_size;
+ cv::Mat proj_Matrix, hom_CV, hom_SVD;
+
+ // trafo cloud s.t. checkerboard is z=0, middle of board at x=y=0 and parallel to image axis
+ // the first trafo is stored and used for all following frames
+ Eigen::Affine3f kinect_trafo;
+ bool kinect_trafo_valid;
+
+ cv::Mat input_image;
+ cv::Mat gray;
+
+ cv::Mat mask;
+
+
+ Cloud input_cloud;
+
+ float kinect_tilt_angle_deg;
+ bool kinect_orientation_valid;
+
+ vector<cv::Point2f> corners;
+ void applyMaskOnInputCloud(Cloud& out);
+ float fitPlaneToCloud(const Cloud& cloud, Eigen::Vector4f& model);
+
+ cv::Mat proj_matrix;
+
+ Cloud observations_3d;
+
+public:
+
+
+ bool storeCurrent3DObservations();
+
+ bool isKinectTrafoValid(){return kinect_trafo_valid;}
+ void setKinectOrientation(float angle_deg){kinect_tilt_angle_deg = angle_deg;kinect_orientation_valid = true;}
+
+ bool mask_valid() {return mask.cols > 0;}
+
+ bool findCheckerboardCorners();
+ void setMaskFromDetections();
+
+ void setInputImage(cv::Mat& image){input_image = image; corners.clear();}
+ void setInputCloud(Cloud& cloud){input_cloud = cloud;}
+
+
+ void computeKinectTransformation();
+
+ // pixel coordinates of checkerboard corners
+ void computeProjectionMatrix(const vector<cv::Point2f>& projector_corners);
+ void computeHomography_OPENCV(const vector<cv::Point2f>& projector_corners);
+ void computeHomography_SVD(const vector<cv::Point2f>& projector_corners);
+
+
+
+ Projector_Calibrator(){
+ kinect_orientation_valid = false;
+ kinect_trafo_valid = false;
+ C_checkboard_size = cv::Size(8,6);
+ C_proj_size = cv::Size(1152,864);
+ }
+
+
+
+
+
+
+
+};
+
+
+
+
+#endif /* PROJECTOR_CALIBRATOR_H_ */
View
@@ -15,7 +15,6 @@
<depend package="image_view"/>
<depend package="geometry_msgs"/>
<depend package="eigen"/>
- <depend package="cv_bridge"/>
<depend package="camera_calibration"/>
<depend package="tf"/>
<depend package="tf_conversions"/>
@@ -25,6 +24,7 @@
<depend package="image_rotate"/>
<depend package="image_transport"/>
<depend package="image_view"/>
+ <depend package="cv_bridge"/>
<depend package="pcl_ros"/>
<depend package="pcl"/>
<depend package="visualization_msgs"/>
View
@@ -9,6 +9,10 @@
#include "cloud_processing.h"
+
+
+
+
// apply mask to orig (remove all points with mask(p)==0 and p.x = NAN)
void applyMask(const Cloud& orig, Cloud& masked, const IplImage* mask){
assert(mask);
View
@@ -1,54 +0,0 @@
-/*
- * find_rect.cpp
- *
- * Created on: Apr 23, 2012
- * Author: engelhan
- */
-
-
-#include "find_rect.h"
-
-
-Cloud Rect_finder::find_rect(Cloud& cloud){
-
-
- Cloud filtered;
-
-
- pcl::PassThrough<pcl_Point> pass;
- pass.setInputCloud (cloud.makeShared());
- pass.setFilterFieldName ("z");
- pass.setFilterLimits (0.5, 1.5);
- //pass.setFilterLimitsNegative (true);
- pass.filter (filtered);
-
- // pcl::VoxelGrid<pcl_Point> sor;
- // sor.setInputCloud(filtered.makeShared());
- // sor.setLeafSize (0.005f, 0.005f, 0.005f);
- // sor.filter(filtered);
-
-
-// Cloud result;
-//
-// Eigen::Vector4f coefficients;
-//
-// std::vector<int> inlier;
-// float quality = fitPlaneToCloud(filtered, coefficients,&inlier);
-//
-// ROS_INFO("Cloud had %zu points, %zu inlier", filtered.size(),inlier.size());
-//
-//
-// for (uint i=0; i<inlier.size(); ++i)
-// result.push_back(filtered.at(inlier.at(i)));
-
-
- Cloud::Ptr msg = filtered.makeShared();
- msg->header.frame_id = "/openni_rgb_optical_frame";
- msg->header.stamp = ros::Time::now ();
- pub_rect.publish(msg);
-
-
-
- return filtered;
-
-}
Oops, something went wrong.

0 comments on commit d4ecefe

Please sign in to comment.