From Mysql 5.6.4 then on,date,datetime,timestamp support fractional second part (fsp), with up to microseconds (6 digits) precision:
create table
To define a column that includes a fractional seconds part, use the syntax type_name(fsp), where type_name is TIME, DATETIME, or TIMESTAMP, and fsp is the fractional seconds precision. For example:
1
CREATETABLE t1 (t TIME(3), dt DATETIME(6));
The fsp value, if given, must be in the range 0 to 6, by default is 0.
rounding
Inserting a TIME, DATE, or TIMESTAMP value with a fractional seconds part into a column of the same type but having fewer fractional digits results in rounding, as shown in this example:
No warning or error is given when such rounding occurs.
how to generate fsp time
Functions that take temporal arguments accept values with fractional seconds. Return values from temporal functions include fractional seconds as appropriate.
For example, NOW() with no argument returns the current date and time with no fractional part, but takes an optional argument from 0 to 6 to specify that the return value includes a fractional seconds part of that many digits.
we need to select datetime as string, because we must keep fsp,we use concat("",create_time) as create_time to get string time 2014-09-08 17:51:04.777668, and then process with c++ to get boost ptime.
sql
1 2 3 4 5
# select datetime as string # (1) concat("",create_time) as create_time [we can have fsp] # (2) DATE_FORMAT(create_time,'%Y-%m-%d %h:%m:%s') AS create_time [we can not have fsp]
select id, create_time,concat("",create_time) as create_time from camera where id =1;
sudo apt-get install build-essential wget http://www.cmake.org/files/v3.2/cmake-3.2.2.tar.gz tar xf cmake-3.2.2.tar.gz cd cmake-3.2.2 ./configure make && make install
which cmake #/usr/local/bin/cmake cmake --version
or by apt-get -y install cmake
User defined cmake
FindXXX.cmake in CMAKE_MODULE_PATH
xxx-config.cmake in CMAKE_PREFIX_PATH
cmake default package
FindXXX.cmake
use find_package to find default package with name XXX
and cmake file C:\Program Files\CMake\share\cmake-3.10\Modules\FindXXX.cmake
use ${XXX_INCLUDE_DIRS} in include, and ${XXX_LIBRARIES} in libraries
# Name: <Name>Config.cmake or <lower name>-config.cmake # mysqlcppconn-config.cmake or MYSQLCPPCONNConfig.cmake # similar to OpenCVConfig.cmake
# Tips for MYSQLCPPCONN_ROOT_DIR # use "C:/Program Files/MySQL/Connector.C++ 1.1", otherwise cmake-gui can not auto find include and library
set(MYSQLCPPCONN_FOUND TRUE) # auto set(MYSQLCPPCONN_ROOT_DIR "C:/Program Files/MySQL/Connector.C++ 1.1")
find_path(MYSQLCPPCONN_INCLUDE_DIR NAMES cppconn/driver.h PATHS "${MYSQLCPPCONN_ROOT_DIR}/include") mark_as_advanced(MYSQLCPPCONN_INCLUDE_DIR) # show entry in cmake-gui
find_library(MYSQLCPPCONN_LIBRARY NAMES mysqlcppconn.lib PATHS "${MYSQLCPPCONN_ROOT_DIR}/lib/opt") mark_as_advanced(MYSQLCPPCONN_LIBRARY) # show entry in cmake-gui
# use xxx_INCLUDE_DIRS and xxx_LIBRARIES in CMakeLists.txt set(MYSQLCPPCONN_INCLUDE_DIRS ${MYSQLCPPCONN_INCLUDE_DIR} ) set(MYSQLCPPCONN_LIBRARIES ${MYSQLCPPCONN_LIBRARY} )
# cmake entry will be saved to build/CMakeCache.txt
/usr/bin/ld: /usr/local/lib/libdlib.a(test_for_odr_violations.cpp.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libdlib.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status
we’d better to use SSD to compile source code instead HDD. So put source code in C folder on windows. use multiple processor to compile with /MP options.
cd c:/compile/pcl-1.8.1 mkdir build && cd build cmake-gui ..
with options
QT_USE_FILE C:/compile/pcl-1.8.1/build/use-qt5.cmake
VTK_DIR C:/Program Files/VTK/lib/cmake/vtk-8.1
CMAKE_INSTALL_PREFIX C:/Program Files/PCL
PCL_SHARED_LIBS ON
PCL_QT_VERSION 5
PCL_ENABLE_SSE ON
CMAKE_BUILD_TYPE Release
CMAKE_CONFIGURATION_TYPES Release
CMAKE_INSTALL_PREFIX C:/Program Files/PCL
CMAKE_CXX_FLAGS_RELEASE /MD /O2 /Ob2 /DNDEBUG /MP # for multiple processor
Build_visualization ON
Build_apps OFF
Build_examples OFF # error may occur
# Fix zlib and png
zlib include: C:/Program Files/VTK/include/vtk-8.1/vtkzlib
zlib library: C:/Program Files/VTK/lib/vtkzlib-8.1.lib
png include: C:/Program Files/VTK/include/vtk-8.1/vtkpng
png library: C:/Program Files/VTK/lib/vtkpng-8.1.lib
configure output
code;arch=compute_53,code=sm_53;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61
...
Boost version: 1.64.0
Found the following Boost libraries:
system
filesystem
thread
date_time
iostreams
chrono
atomic
regex
DOXYGEN_FOUND
HTML_HELP_COMPILER
Found CPack generators: NSIS
The following subsystems will be built:
common
octree
io
kdtree
search
sample_consensus
filters
2d
geometry
features
ml
segmentation
surface
registration
keypoints
tracking
recognition
stereo
tools
The following subsystems will not be built:
visualization: Disabled manually.
apps: Disabled: visualization missing.
outofcore: Requires visualization.
examples: Code examples are disabled by default.
people: Requires visualization.
simulation: Disabled: visualization missing.
global_tests: No reason
Configuring done
OK.
compile
If everything goes well, then generate PCL.sln
Open PCL.sln in vs2015 and build with Release X64.
NOTICE: this build process will take about 30 minutes.
install pcl
by default install need administrator privilidges to write to C:/Program Files/PCL/.
choose INSTALL and generate , and PCL will be installed to C:/Program Files/PCL.
# Set the output folder where your program will be created set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
// vtk //#include <vtkAutoInit.h> //VTK_MODULE_INIT(vtkRenderingOpenGL2); //VTK_MODULE_INIT(vtkInteractionStyle); #include<vtkRenderWindow.h>// must include
# Set the output folder where your program will be created set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
# Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON)
#============================================================== # PCL (include qt+vtk) #============================================================== # better not use ${PCL_LIBRARIES}, use what we need: # e.g. ${PCL_COMMON_LIBRARIES} ${PCL_VISUALIZATION_LIBRARIES}
#============================================================== # generate and link target #============================================================== add_executable(${PROJECT_NAME}${SRC_LIST}${ui_FILES}${qrc_FILES})
# link qt libraries qt5_use_modules(${PROJECT_NAME} Core Widgets OpenGL Xml Gui Sql)
# link vtk and pcl libraries target_link_libraries(${PROJECT_NAME} ${GLOG_LIBRARIES}
when run example, errors may occur: (which has been fixed by now.)
fix error
fix pcl min,max conflict with windows.h macro
error
C:\Boost\include\boost-1_64\boost\asio\detail\socket_types.hpp(37):# include <windows.h> we use boost which includes <windows.h> and import macro min/max. in pcl, std::numeric_limits<int>::max conflict with min/max.
Resource Contention. If you have some resource that (1) can only have a single instance, and (2) you need to manage that single instance, you need a singleton.
There aren’t many examples. A log file is the big one. You don’t want to just abandon a single log file. You want to flush, sync and close it properly. This is an example of a single shared resource that has to be managed.
It’s rare that you need a singleton. The reason they’re bad is that they feel like a global and they’re a fully paid up member of the GoF Design Patterns book.
When you think you need a global, you’re probably making a terrible design mistake.
/* static config instance will only be created once by calling Config::Config, when program exit,static variable will be destoryed by calling Config::~Config. */
# - Try to find MYSQLCPPCONN # # The following variables are optionally searched for defaults # MYSQLCPPCONN_ROOT_DIR: Base directory where all MYSQLCPPCONN components are found # # The following are set after configuration is done: # MYSQLCPPCONN_FOUND # MYSQLCPPCONN_INCLUDE_DIRS # MYSQLCPPCONN_LIBRARIES # MYSQLCPPCONN_LIBRARYRARY_DIRS