Skip to content

Commit

Permalink
upload third chapter
Browse files Browse the repository at this point in the history
Signed-off-by: Hao Guo <[email protected]>
  • Loading branch information
LiveStockShapeAnalysis committed Feb 25, 2019
1 parent 5f41bdb commit bd7071a
Show file tree
Hide file tree
Showing 126 changed files with 23,490 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Point-Cloud-Processing-example
更多点云数据处理相关资源请去http:https://www.pclcn.org/ 和相应的 http:https://www.pclcn.org/bbs/forum.php
点云库PCL从入门到精通 书中配套案例
第二章代码 其中五个源码案例,一个是笔者做实验时用的第三方库,由于一些资源太大,没有上传。
更多点云数据处理相关资源请去 http:https://www.pclcn.org/ 和相应的论坛 http:https://www.pclcn.org/bbs/forum.php



8 changes: 8 additions & 0 deletions 第三章/1 reading pcd/source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(pcd_read)
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_read pcd_read.cpp)
target_link_libraries(pcd_read ${PCL_LIBRARIES})
25 changes: 25 additions & 0 deletions 第三章/1 reading pcd/source/pcd_read.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

int
main(int argc,char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

if(pcl::io::loadPCDFile<pcl::PointXYZ>("test_pcd.pcd",*cloud)==-1)//*´ò¿ªµãÔÆÎļþ
{
PCL_ERROR("Couldn't read file test_pcd.pcd\n");
return(-1);
}
std::cout<<"Loaded "
<<cloud->width*cloud->height
<<" data points from test_pcd.pcd with the following fields: "
<<std::endl;
for(size_t i=0;i<cloud->points.size();++i)
std::cout<<" "<<cloud->points[i].x
<<" "<<cloud->points[i].y
<<" "<<cloud->points[i].z<<std::endl;

return(0);
}
16 changes: 16 additions & 0 deletions 第三章/1 reading pcd/source/test_pcd.pcd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z
SIZE 4 4 4
TYPE F F F
COUNT 1 1 1
WIDTH 5
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 5
DATA ascii
1.28125 577.09375 197.9375
828.125 599.03125 491.375
358.6875 917.4375 842.5625
764.5 178.28125 879.53125
727.53125 525.84375 311.28125
75 changes: 75 additions & 0 deletions 第三章/10/linescaner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
cmake_minimum_required(VERSION 2.8)
include (GenerateExportHeader)
project(Lslib)

FIND_PACKAGE(Qt4 REQUIRED)
find_package(PCL 1.7 REQUIRED)



SET (LIB_TYPE SHARED)

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/third" "${CMAKE_CURRENT_SOURCE_DIR}/header")
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_definitions(-DNOMINMAX)

set(INCS
"header/stdafx.h"
"third/InterfaceLLT_2.h"
"third/DllLoader.h"
"third/scanControlDataTypes.h"
)

set(SRCS
src/LineScaner.cpp
third/DllLoader.cpp
third/InterfaceLLT_2.cpp
)


set(MOC_LINESCANER_INC "header/LineScaner.h")

INCLUDE(${QT_USE_FILE})
qt4_wrap_cpp(MOC_LINESCANER_SRC "${MOC_LINESCANER_INC}")

list(APPEND ADDITIONAL_LIBS ${QT_LIBRARIES})
list(APPEND SRCS "${MOC_LINESCANER_SRC}")
list(APPEND INCS "${MOC_LINESCANER_INC}")

# Create a target for the library
ADD_LIBRARY(LsLib ${LIB_TYPE} ${SRCS} ${INCS})
target_link_libraries(LsLib ${QT_LIBRARIES} ${PCL_LIBRARIES})

add_subdirectory(sourceio)
add_subdirectory(sourceads)

GENERATE_EXPORT_HEADER( LsLib
BASE_NAME LsLib
EXPORT_MACRO_NAME LsLib_EXPORT
EXPORT_FILE_NAME LsLib_Export.h)

find_package (VTK REQUIRED)

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/header" "${CMAKE_CURRENT_SOURCE_DIR}/sourceio/header" "${CMAKE_CURRENT_SOURCE_DIR}/sourceads/header" "${CMAKE_CURRENT_SOURCE_DIR}/sourceads/third")
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/sourceads/third")
set (test_SRCS test/src/main.cpp
test/src/MYscaner.cpp )
set (test_INCS test/header/MYscaner.h)
set (test_FORMS test/resource/mainUI.ui)
set (test_RSRC test/resource/resource.qrc)
set (VTK_LIBRARIES vtkRendering vtkGraphics vtkHybrid QVTK)

QT4_WRAP_CPP (project_HEADERS_MOC ${test_INCS})
QT4_WRAP_UI (project_FORMS_HEADERS ${test_FORMS})
QT4_ADD_RESOURCES(RESOURCES_SRCS ${test_RSRC})

ADD_EXECUTABLE (MIYI_capturing ${test_SRCS}
${test_INCS}
${project_FORMS_HEADERS}
${project_HEADERS_MOC}
${RESOURCES_SRCS})

TARGET_LINK_LIBRARIES (MIYI_capturing ${QT_LIBRARIES} ${PCL_LIBRARIES} ${VTK_LIBRARIES} LsLib IOLib AdsLib)

190 changes: 190 additions & 0 deletions 第三章/10/linescaner/header/LineScaner.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*! \file LineScaner.h
*this file declare the class which was designed for using the line scaner
*/
#ifndef LINESCANERH
#define LINESCANERH
#include <QObject>
#include "InterfaceLLT_2.h"
#include<vector>
#include "LsLib_Export.h"
#include <Eigen/Geometry>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/common/eigen.h>
#include <pcl/common/transforms.h>
#include <boost/thread/mutex.hpp>

#define MAX_INTERFACE_COUNT 5
#define MAX_RESOULUTIONS 6
/*! \namespace LS
*LS contains all the members for line scanning
*
*/

namespace LS
{
/*!
* call back function provided for Line Scanner Driver
* capturing and storing the data periodically
*/
void __stdcall CallBack(const unsigned char* pucData, unsigned int uiSize, void* pUserData);
/*! \class LineScaner
* Line Scanner contains all the operation and data related with line scanning
*
*/
class LsLib_EXPORT LineScaner:public QObject
{
Q_OBJECT
public:
/*!
*load the API dll and initalize parameter for device
*/
LineScaner();
/*!
*stop capturing data and diconnect device
*/
~LineScaner();
/*!
*return the number of devices connected with server
*/
int NumofDevice();
/*!
*set which device is going to work default 0
*/
bool SetDevice(int device_id);
/*!
*build connection with device
*/
bool BuildConnection();
/*!
* get the device type store in m_tscanCONTROLType member
*/
bool GetDeviceType();
/*!
*get all support resoulution store in vdwResolutions[]
*/
bool GetSupportResoulutions();
/*!
*Set resoulution id defualt 0
*/
bool SetResoulution(int resuolution_id);
/*!
*set filter
*/
bool Setfilter(unsigned long filtering);
/*!
*set the trigger type,always internal.
*/
bool SetTrigger();
/*!
*set profile type defualt PROFILE.
*/
bool SetProfileType(TProfileConfig type);
/*!
* set shutter time defualt 100
*/
bool SetShutterTime( unsigned int shuttertime);
/*!
*set idle time defualt 900
*/
bool SetIdleTime( unsigned int idleTime);
/*!
*register callback function which will capturing data periodically
*/
bool StartCapturing();
/*!
*called in callback function broadcast the new frame captured news by signal.
*/
void Fire_new();
/*!
*stop calling the callback stop the transfering of data
*/
bool EndCapturing();
/*!
* get how many frame are captured so far
*/
void Get_num_frame(unsigned int &num_frame);
/*!
* set data state. true means data are good in sense of size
*/
void SetDataState(bool test);
/*!
*return the resoulution(not ID)
*/
unsigned int GetResoulution();
/*!
* set the pose for transform the data in device frame to world frame.
*must called before Get_W3D.
*/
void Set_Last_Pose(double x,double y,double z,double roll,double pitch,double yaw);
/*\brief Get the lastest point cloud data in the world coordinate system
*and sent the final data ready signal W3D_Ready(),user can be notified for further processing.
*
*\param[in/out] cloud store the final data.
*/
void Get_W3D(pcl::PointCloud<pcl::PointXYZ> &cloud);

/**
* convert the current frame to 3d in device frame
*/
void Get_L3D(pcl::PointCloud<pcl::PointXYZ> &cloud);
protected:


void OnError(const char* szErrorTxt, int iErrorValue);

public slots:
bool DismissConnection();
signals:
void New_Frame_comed()const;
void Connection_okay()const;
void Connection_off(bool)const;
void W3D_Ready(bool)const;
void L3D_Ready(bool)const;

public:
unsigned int m_uiProfileDataSize;
std::vector<unsigned char> vucProfileBuffer_Last;
bool debug_verbose;

private:
/*!
*convert the data frame the callback to hunman understand minimeter
*/
bool GetXZinMM();
/*!
* current frame to 3d in device frame
*/
void Convert_to_3DL();
/*!
*Get the lastest point cloud data in the world coordinate system,must called after setpose
*/
void Convert_to_3DW();
private:
boost::mutex mutex_;
unsigned int Numer_of_new_frame;
double _x,_y,_z,_roll,_pitch,_yaw;
Eigen::Transform<double, 3, Eigen::Affine> last_T_W;
std::vector<unsigned int> vuiEthernetInterfaces;
std::vector<unsigned long> vdwResolutions;
unsigned int uiEthernetInterfaceCount;
unsigned int uiShutterTime;
unsigned int uiIdleTime;
unsigned long ulFilter;
bool bLoadError;
int iRetValue;
bool bOK,Atleastone;
bool bConnected;
bool Capturing_state;
bool Data_fine;
unsigned int m_uiResolution;
CInterfaceLLT* m_pLLT;
TScannerType m_tscanCONTROLType;
std::vector<double> vdValueX_Last;
std::vector<double> vdValueZ_Last;
pcl::PointCloud<pcl::PointXYZ>::Ptr P_last_cloud_W;
pcl::PointCloud<pcl::PointXYZ>::Ptr P_last_cloud_L;
};
}

#endif
18 changes: 18 additions & 0 deletions 第三章/10/linescaner/header/stdafx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// stdafx.h : Includedatei für Standardsystem-Includedateien,
// oder häufig verwendete, projektspezifische Includedateien,
// die nur in unregelmäßigen Abständen geändert werden.

#include <vector>
#include <string>
#include <list>
#include <map>
#include <deque>
#include <sstream>
#include <fstream>
#include <ostream>
#include <istream>
#include <iomanip>
#include <algorithm>



Loading

0 comments on commit bd7071a

Please sign in to comment.