diff --git a/odtools/odcomparepointcloud/CMakeLists.txt b/odtools/odcomparepointcloud/CMakeLists.txt deleted file mode 100644 index 02cf728f..00000000 --- a/odtools/odcomparepointcloud/CMakeLists.txt +++ /dev/null @@ -1,99 +0,0 @@ -# odcomparepointcloud - Tool for comparing data between shared point cloud and -# compact point cloud -# Copyright (C) 2016 Hang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -CMAKE_MINIMUM_REQUIRED (VERSION 2.8) - -PROJECT (odcomparepointcloud) - -########################################################################### -# Set the search path for .cmake files. -SET (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake.Modules" ${CMAKE_MODULE_PATH}) - -# Add a local CMake module search path dependent on the desired installation destination. -# Thus, artifacts from the complete source build can be given precendence over any installed versions. -IF(UNIX) - SET (CMAKE_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/share/cmake-${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}/Modules" ${CMAKE_MODULE_PATH}) -ENDIF() -IF(WIN32) - SET (CMAKE_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/CMake-${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}/Modules" ${CMAKE_MODULE_PATH}) -ENDIF() - -########################################################################### -# Include flags for compiling. -INCLUDE (CompileFlags) - -########################################################################### -# Find and configure CxxTest. -SET (CXXTEST_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../cxxtest") -INCLUDE (CheckCxxTestEnvironment) - -########################################################################### -# Find OpenDaVINCI. -SET(OPENDAVINCI_DIR "${CMAKE_INSTALL_PREFIX}") -FIND_PACKAGE (OpenDaVINCI REQUIRED) - -############################################################################### -# Set header files from OpenDaVINCI. -INCLUDE_DIRECTORIES (${OPENDAVINCI_INCLUDE_DIRS}) -# Set include directory. -INCLUDE_DIRECTORIES(include) - -############################################################################### -# Build this project. -FILE(GLOB_RECURSE thisproject-sources "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") -ADD_LIBRARY (${PROJECT_NAME}lib-static STATIC ${thisproject-sources}) -ADD_EXECUTABLE (${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/apps/${PROJECT_NAME}.cpp") -TARGET_LINK_LIBRARIES (${PROJECT_NAME} ${PROJECT_NAME}lib-static ${OPENDAVINCI_LIBRARIES}) - -############################################################################### -# Enable CxxTest for all available testsuites. -IF(CXXTEST_FOUND) - FILE(GLOB thisproject-testsuites "${CMAKE_CURRENT_SOURCE_DIR}/testsuites/*.h") - - FOREACH(testsuite ${thisproject-testsuites}) - STRING(REPLACE "/" ";" testsuite-list ${testsuite}) - - LIST(LENGTH testsuite-list len) - MATH(EXPR lastItem "${len}-1") - LIST(GET testsuite-list "${lastItem}" testsuite-short) - - SET(CXXTEST_TESTGEN_ARGS ${CXXTEST_TESTGEN_ARGS} --world=${PROJECT_NAME}-${testsuite-short}) - CXXTEST_ADD_TEST(${testsuite-short}-TestSuite ${testsuite-short}-TestSuite.cpp ${testsuite}) - IF(UNIX) - IF( ( ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") - OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly") ) - AND (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") ) - SET_SOURCE_FILES_PROPERTIES(${testsuite-short}-TestSuite.cpp PROPERTIES COMPILE_FLAGS "-Wno-effc++ -Wno-float-equal -Wno-error=suggest-attribute=noreturn") - ELSE() - SET_SOURCE_FILES_PROPERTIES(${testsuite-short}-TestSuite.cpp PROPERTIES COMPILE_FLAGS "-Wno-effc++ -Wno-float-equal") - ENDIF() - ENDIF() - IF(WIN32) - SET_SOURCE_FILES_PROPERTIES(${testsuite-short}-TestSuite.cpp PROPERTIES COMPILE_FLAGS "") - ENDIF() - SET_TESTS_PROPERTIES(${testsuite-short}-TestSuite PROPERTIES TIMEOUT 3000) - TARGET_LINK_LIBRARIES(${testsuite-short}-TestSuite ${PROJECT_NAME}lib-static ${OPENDAVINCI_LIBRARIES}) - ENDFOREACH() -ENDIF(CXXTEST_FOUND) - -############################################################################### -# Install this project. -INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin COMPONENT odtools) -INSTALL(FILES man/${PROJECT_NAME}.1 DESTINATION man/man1 COMPONENT odtools) - diff --git a/odtools/odcomparepointcloud/LICENSE-GPL-v2 b/odtools/odcomparepointcloud/LICENSE-GPL-v2 deleted file mode 100644 index d159169d..00000000 --- a/odtools/odcomparepointcloud/LICENSE-GPL-v2 +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/odtools/odcomparepointcloud/apps/odcomparepointcloud.cpp b/odtools/odcomparepointcloud/apps/odcomparepointcloud.cpp deleted file mode 100644 index 3239b616..00000000 --- a/odtools/odcomparepointcloud/apps/odcomparepointcloud.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/** - * odcomparepointcloud - Tool for comparing data between shared point cloud and - * compact point cloud - * Copyright (C) 2017 Hang - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "ComparePointCloudModule.h" - -int32_t main(int32_t argc, char **argv) { - odcomparepointcloud::ComparePointCloudModule cppc(argc, argv); - return cppc.runModule(); -} diff --git a/odtools/odcomparepointcloud/include/ComparePointCloudModule.h b/odtools/odcomparepointcloud/include/ComparePointCloudModule.h deleted file mode 100644 index a5215cb1..00000000 --- a/odtools/odcomparepointcloud/include/ComparePointCloudModule.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - * odcomparepointcloud - Tool for comparing data between shared point cloud and - * compact point cloud - * Copyright (C) 2017 Hang - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef COMPAREPOINTCLOUDMODULE_H_ -#define COMPAREPOINTCLOUDMODULE_H_ - -#include -#include -#include -#include - -#include "opendavinci/odcore/base/module/TimeTriggeredConferenceClientModule.h" -#include -#include -#include "opendavinci/generated/odcore/data/CompactPointCloud.h" -#include -#include "opendavinci/odcore/wrapper/SharedMemory.h" - -namespace odcomparepointcloud { - - /** - * This class can be used to inspect recorded data. - */ - class ComparePointCloudModule : public odcore::base::module::TimeTriggeredConferenceClientModule { - private: - /** - * "Forbidden" copy constructor. Goal: The compiler should warn - * already at compile time for unwanted bugs caused by any misuse - * of the copy constructor. - * - * @param obj Reference to an object of this class. - */ - ComparePointCloudModule(const ComparePointCloudModule &/*obj*/); - - /** - * "Forbidden" assignment operator. Goal: The compiler should warn - * already at compile time for unwanted bugs caused by any misuse - * of the assignment operator. - * - * @param obj Reference to an object of this class. - * @return Reference to this instance. - */ - ComparePointCloudModule& operator=(const ComparePointCloudModule &/*obj*/); - - public: - ComparePointCloudModule(const int32_t &argc, char **argv); - - virtual ~ComparePointCloudModule(); - - odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode body(); - /** - * This method validates a specified file regarding integrity. - * - * @param argc Number of command line arguments. - * @param argv Command line arguments. - * @return 0 if specified file is integer, 1 if the file is not integer, and 255 if the file could not be opened. - */ - - private: - virtual void setUp(); - virtual void tearDown(); - //void parseAdditionalCommandLineParameters(const int &argc, char **argv); - void readCPC(odcore::data::Container&, const uint8_t &); - void readSPC(odcore::data::Container&); - inline void clearVectors(const uint8_t &, const bool &); - private: - bool m_CPCfound; - bool m_SPCfound; - uint32_t m_frameNumber; - odcore::data::SharedPointCloud m_spc; - odcore::data::CompactPointCloud m_cpc; - bool m_hasAttachedToSharedImageMemory; - std::shared_ptr m_spcSharedMemory; - uint8_t m_compareOption; //0: compare azimuth and distance; 1: compare xyz - std::vector m_distanceCpc; - std::vector m_azimuthCpc; - std::vector m_verticalAngleCpc; - std::vector m_xCpc; - std::vector m_yCpc; - std::vector m_zCpc; - std::vector m_distanceSpc; - std::vector m_azimuthSpc; - std::vector m_verticalAngleSpc; - std::vector m_xSpc; - std::vector m_ySpc; - std::vector m_zSpc; - //If the SPC has "xyz+intensity" structure, m_Error1, m_Error2, and m_Error3 represent the differences in xyz, respectively. - //Otherwise, they represent the differences in distance, azimuth, and vertical angle, respectively. - std::vector m_Error1; - std::vector m_Error2; - std::vector m_Error3; - std::ofstream m_outputData; - std::ofstream m_cpcFrame; - std::ofstream m_spcFrame; - float m_verticalAngles[16]; - uint16_t m_sensorOrderIndex[16]; - uint16_t m_16SortedDistances[16]; - std::string m_recordingFile; - bool m_allFrames; - uint64_t m_chosenFrame; - uint64_t m_currentFrame; - //const float START_V_ANGLE = -15.0;//For each azimuth there are 16 points with unique vertical angles from -15 to 15 degrees - //const float V_INCREMENT = 2.0; //The vertical angle increment for the 16 points with the same azimuth is 2 degrees - }; - -} // odcomparepointcloud - -#endif /*COMPAREPOINTCLOUDMODULE_H_*/ diff --git a/odtools/odcomparepointcloud/src/ComparePointCloudModule.cpp b/odtools/odcomparepointcloud/src/ComparePointCloudModule.cpp deleted file mode 100644 index 61f816c7..00000000 --- a/odtools/odcomparepointcloud/src/ComparePointCloudModule.cpp +++ /dev/null @@ -1,501 +0,0 @@ -/** - * odComparePointCloudModule - Tool for comparing data between shared point cloud and - * compact point cloud - * Copyright (C) 2017 Hang - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include - -#include "opendavinci/odcore/base/CommandLineParser.h" -#include "opendavinci/odtools/player/Player.h" -#include "opendavinci/odcore/base/Lock.h" -#include "opendavinci/odcore/wrapper/SharedMemoryFactory.h" -#include "opendavinci/odcore/base/KeyValueConfiguration.h" - -#include "ComparePointCloudModule.h" - -namespace odcomparepointcloud { - - using namespace std; - using namespace odcore::data; - using namespace odtools::player; - - ComparePointCloudModule::ComparePointCloudModule(const int32_t &argc, char **argv) : - TimeTriggeredConferenceClientModule(argc, argv, "ComparePointCloud"), - m_CPCfound(false), - m_SPCfound(false), - m_frameNumber(0), - m_spc(), - m_cpc(), - m_hasAttachedToSharedImageMemory(false), - m_spcSharedMemory(NULL), - m_compareOption(0), - m_distanceCpc(), - m_azimuthCpc(), - m_verticalAngleCpc(), - m_xCpc(), - m_yCpc(), - m_zCpc(), - m_distanceSpc(), - m_azimuthSpc(), - m_verticalAngleSpc(), - m_xSpc(), - m_ySpc(), - m_zSpc(), - m_Error1(), - m_Error2(), - m_Error3(), - m_outputData("output.csv", std::ios_base::app | std::ios_base::out), - m_cpcFrame("cpcFrame.csv", std::ios_base::app | std::ios_base::out), - m_spcFrame("spcFrame.csv", std::ios_base::app | std::ios_base::out), - m_recordingFile(""), - m_allFrames(false), - m_chosenFrame(0), - m_currentFrame(0) { - //The vertical angles sorted by sensor IDs from 0 to 15 according to the data sheet - m_verticalAngles[0] = -15.0; - m_verticalAngles[1] = 1.0; - m_verticalAngles[2] = -13.0; - m_verticalAngles[3] = 3.0; - m_verticalAngles[4] = -11.0; - m_verticalAngles[5] = 5.0; - m_verticalAngles[6] = -9.0; - m_verticalAngles[7] = 7.0; - m_verticalAngles[8] = -7.0; - m_verticalAngles[9] = 9.0; - m_verticalAngles[10] = -5.0; - m_verticalAngles[11] = 11.0; - m_verticalAngles[12] = -3.0; - m_verticalAngles[13] = 13.0; - m_verticalAngles[14] = -1.0; - m_verticalAngles[15] = 15.0; - - //Distance values are reordered with increasing vertical angles while storing CPC - m_sensorOrderIndex[0] = 0; - m_sensorOrderIndex[1] = 2; - m_sensorOrderIndex[2] = 4; - m_sensorOrderIndex[3] = 6; - m_sensorOrderIndex[4] = 8; - m_sensorOrderIndex[5] = 10; - m_sensorOrderIndex[6] = 12; - m_sensorOrderIndex[7] = 14; - m_sensorOrderIndex[8] = 1; - m_sensorOrderIndex[9] = 3; - m_sensorOrderIndex[10] = 5; - m_sensorOrderIndex[11] = 7; - m_sensorOrderIndex[12] = 9; - m_sensorOrderIndex[13] = 11; - m_sensorOrderIndex[14] = 13; - m_sensorOrderIndex[15] = 15; - - for (uint8_t counter = 0; counter < 16; counter++) { - m_16SortedDistances[counter] = 0.0; - } - } - - ComparePointCloudModule::~ComparePointCloudModule() {} - - void ComparePointCloudModule::setUp() { - m_recordingFile = getKeyValueConfiguration().getValue< string >("ComparePointCloud.recording"); - m_allFrames = getKeyValueConfiguration().getValue< uint16_t >("ComparePointCloud.compareAllFrames") == 1; - m_chosenFrame = getKeyValueConfiguration().getValue< uint64_t >("ComparePointCloud.frame"); - } - - void ComparePointCloudModule::tearDown() {} - - void ComparePointCloudModule::readCPC(Container &c, const uint8_t &comparisonOption) { - m_cpc = c.getData(); - float startAzimuth = m_cpc.getStartAzimuth(); - float endAzimuth = m_cpc.getEndAzimuth(); - uint8_t entriesPerAzimuth = m_cpc.getEntriesPerAzimuth(); - string distances = m_cpc.getDistances(); - const uint8_t numberOfBitsForIntensity = m_cpc.getNumberOfBitsForIntensity(); - const uint8_t intensityPlacement = m_cpc.getIntensityPlacement(); - uint16_t mask = 0xFFFF; - if (numberOfBitsForIntensity > 0) { - if (intensityPlacement == 0) { - mask = mask << numberOfBitsForIntensity; - } else { - mask = mask >> numberOfBitsForIntensity; - } - } - uint16_t distanceEncoding = m_cpc.getDistanceEncoding(); - uint16_t distanceThreshold = 0; - switch (distanceEncoding) { - case CompactPointCloud::CM : distanceThreshold = 100; - break; - case CompactPointCloud::MM : distanceThreshold = 500; - break; - } - - uint32_t numberOfPoints = distances.size() / 2; - uint32_t numberOfAzimuths = numberOfPoints / entriesPerAzimuth; - float azimuthIncrement = (endAzimuth - startAzimuth) / numberOfAzimuths;//Calculate the azimuth increment - stringstream sstr(distances); - const float toRadian = static_cast< float >(M_PI) / 180.0f; - uint16_t distance_integer = 0; - float xyDistance = 0; - float azimuth = startAzimuth; - for (uint32_t azimuthIndex = 0; azimuthIndex < numberOfAzimuths; azimuthIndex++) { - for (uint8_t sensorIndex = 0; sensorIndex < entriesPerAzimuth; sensorIndex++) { - sstr.read((char*)(&m_16SortedDistances[m_sensorOrderIndex[sensorIndex]]), 2); // Read distance value from the string in a CPC container point by point - m_16SortedDistances[m_sensorOrderIndex[sensorIndex]] = ntohs(m_16SortedDistances[m_sensorOrderIndex[sensorIndex]]); - } - - for (uint8_t sensorIndex = 0; sensorIndex < entriesPerAzimuth; sensorIndex++) { - distance_integer = m_16SortedDistances[sensorIndex]; - if (numberOfBitsForIntensity !=0) { - distance_integer = distance_integer & mask; - } - if (distance_integer >= distanceThreshold) { - float distance = 0.0f; - switch (distanceEncoding) { - case CompactPointCloud::CM : distance = static_cast< float >(distance_integer / 100.0f); //convert to meter from resolution 1 cm - break; - case CompactPointCloud::MM : distance = static_cast< float >(distance_integer / 500.0f); //convert to meter from resolution 2mm - break; - } - if (comparisonOption == 0) { - m_distanceCpc.push_back(distance); - m_azimuthCpc.push_back(azimuth); - m_verticalAngleCpc.push_back(m_verticalAngles[sensorIndex]); - } else { - // Compute x, y, z coordinate based on distance, azimuth, and vertical angle - xyDistance = distance * cos(m_verticalAngles[sensorIndex] * toRadian); - m_xCpc.push_back(xyDistance * sin(azimuth * toRadian)); - m_yCpc.push_back(xyDistance * cos(azimuth * toRadian)); - m_zCpc.push_back(distance * sin(m_verticalAngles[sensorIndex] * toRadian)); - } - } - } - azimuth += azimuthIncrement; - } - } - - void ComparePointCloudModule::readSPC(Container &c){ - m_spc = c.getData< SharedPointCloud >(); - bool comparePolar = false; - if (m_spc.getUserInfo() == SharedPointCloud::POLAR_INTENSITY) { - comparePolar = true; - } - if (!m_hasAttachedToSharedImageMemory) { - m_spcSharedMemory = odcore::wrapper::SharedMemoryFactory::attachToSharedMemory(m_spc.getName()); // Attach the shared point cloud to the shared memory. - m_hasAttachedToSharedImageMemory = true; - } - if (m_spcSharedMemory.get() != NULL && m_spcSharedMemory->isValid()) { - // Using a scoped lock to lock and automatically unlock a shared memory segment. - odcore::base::Lock lv(m_spcSharedMemory); - float *spcData = static_cast< float*>(m_spcSharedMemory->getSharedMemory()); - uint32_t startID = 0; - for (uint32_t counter = 0; counter < m_spc.getWidth(); counter++) { - if (comparePolar) { - m_distanceSpc.push_back(spcData[startID]); - m_azimuthSpc.push_back(spcData[startID + 1]); - m_verticalAngleSpc.push_back(spcData[startID + 2]); - } else { - m_xSpc.push_back(spcData[startID]); - m_ySpc.push_back(spcData[startID + 1]); - m_zSpc.push_back(spcData[startID + 2]); - } - startID += 4; - } - } - } - - inline void ComparePointCloudModule::clearVectors(const uint8_t &comparisonOption, const bool &clearComparison) { - if (comparisonOption == 0) { - m_distanceCpc.clear(); - m_azimuthCpc.clear(); - m_verticalAngleCpc.clear(); - m_distanceSpc.clear(); - m_azimuthSpc.clear(); - m_verticalAngleSpc.clear(); - } else { - m_xCpc.clear(); - m_yCpc.clear(); - m_zCpc.clear(); - m_xSpc.clear(); - m_ySpc.clear(); - m_zSpc.clear(); - } - - if (clearComparison) { - m_Error1.clear(); - m_Error2.clear(); - m_Error3.clear(); - } - } - - odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode ComparePointCloudModule::body() { - odcore::io::URL url("file://" + m_recordingFile); - unique_ptr< Player > player; - //player = unique_ptr< Player >(new Player(url, AUTO_REWIND, MEMORY_SEGMENT_SIZE, NUMBER_OF_SEGMENTS, THREADING)); - player = unique_ptr< Player >(new Player(url, false, 2800000, 20, false)); - Container c; - Container cpcFrame; - Container spcFrame; - - if (m_allFrames) { - /*uint32_t spcFrameNumber = 0; - while (player->hasMoreData()){ - c = player->getNextContainerToBeSent(); - if (c.getDataType() == odcore::data::CompactPointCloud::ID()) { - m_frameNumber++; - } - if (c.getDataType() == odcore::data::SharedPointCloud::ID()) { - spcFrameNumber++; - } - } - cout << m_frameNumber << endl; - cout << spcFrameNumber << endl; - return 0;*/ - - if (player->hasMoreData()) { - c = player->getNextContainerToBeSent(); - if (c.getDataType() == odcore::data::SharedPointCloud::ID()) { - - readSPC(c); - m_frameNumber++; - if (m_xSpc.empty()) { - m_compareOption = 0; //compare distance, azimuth, vertical angle - } else { - m_compareOption = 1; //compare xyz - } - } - - c = player->getNextContainerToBeSent(); - if (c.getDataType() == odcore::data::CompactPointCloud::ID()) { - readCPC(c, m_compareOption); - } - } - - while (player->hasMoreData() && m_frameNumber < 3000) { - c = player->getNextContainerToBeSent(); - if (c.getDataType() == odcore::data::SharedPointCloud::ID()) { - readSPC(c); - m_frameNumber++; - } - - c = player->getNextContainerToBeSent(); - if (c.getDataType() == odcore::data::CompactPointCloud::ID()) { - readCPC(c, m_compareOption); - } - - float error_1, error_2, error_3; - uint32_t spc_index = 0; - if (m_compareOption == 0) { - for (uint32_t cpc_index = 0; cpc_index < m_distanceCpc.size(); cpc_index++) { - error_1 = abs(m_distanceCpc[cpc_index] - m_distanceSpc[spc_index]); - error_2 = abs(m_azimuthCpc[cpc_index] - m_azimuthSpc[spc_index]); - error_3 = abs(m_verticalAngleCpc[cpc_index] - m_verticalAngleSpc[spc_index]); - if (error_3 < 0.003) { - m_Error1.push_back(error_1); - m_Error2.push_back(error_2); - m_Error3.push_back(error_3); - spc_index++; - } - } - } else { - for (uint32_t cpc_index = 0; cpc_index < m_xCpc.size(); cpc_index++) { - error_1 = abs(m_xCpc[cpc_index] - m_xSpc[spc_index]); - error_2 = abs(m_yCpc[cpc_index] - m_ySpc[spc_index]); - error_3 = abs(m_zCpc[cpc_index] - m_zSpc[spc_index]); - if (error_3 < 0.003) { - m_Error1.push_back(error_1); - m_Error2.push_back(error_2); - m_Error3.push_back(error_3); - spc_index++; - } - } - } - - float max_Error1 = m_Error1[0]; - float sum_Error1 = 0.0; - for (float i : m_Error1) { - sum_Error1 += i; - if (i > max_Error1) { - max_Error1 = i; - } - } - float avg_Error1 = sum_Error1 / m_Error1.size(); - - float max_Error2 = m_Error2[0]; - float sum_Error2 = 0.0; - for (float i : m_Error2) { - sum_Error2 += i; - if (i > max_Error2) { - max_Error2 = i; - } - } - float avg_Error2 = sum_Error2 / m_Error2.size(); - - float max_Error3 = m_Error3[0]; - float sum_Error3 = 0.0; - for (float i : m_Error3) { - sum_Error3 += i; - if (i > max_Error3) { - max_Error3 = i; - } - } - float avg_Error3 = sum_Error3 / m_Error3.size(); - - if (avg_Error1 > 5 || avg_Error2 > 5 || avg_Error3 > 5) { - cout << "Abnormal frame:" << m_frameNumber << endl; - } - - if (m_compareOption == 0) { - if (m_Error1.size() == m_distanceSpc.size() && m_Error2.size() == m_azimuthSpc.size() && - m_Error3.size() == m_verticalAngleSpc.size()) { - m_outputData << max_Error1 << "," << avg_Error1 << "," << max_Error2 << "," << avg_Error2 << "," - << max_Error3 << "," << avg_Error3 << endl; - } - else { - cout << "Abnormal frame:" << m_frameNumber << endl; - } - } else { - if (m_Error1.size() == m_xSpc.size() && m_Error2.size() == m_ySpc.size() && - m_Error3.size() == m_zSpc.size()) { - m_outputData << max_Error1 << "," << avg_Error1 << "," << max_Error2 << "," << avg_Error2 << "," - << max_Error3 << "," << avg_Error3 << endl; - } - else { - cout << "Abnormal frame:" << m_frameNumber << endl; - } - } - clearVectors(m_compareOption, true); - } - } - else {//Compare a single frame - /*if (player->hasMoreData()) { - //CPC has one more frame than SPC. Discard the first frame of CPC - c = player->getNextContainerToBeSent(); - }*/ - while (player->hasMoreData() && m_currentFrame < m_chosenFrame) { - c = player->getNextContainerToBeSent(); - c = player->getNextContainerToBeSent(); - m_currentFrame++; - } - - if (m_currentFrame < m_chosenFrame) { - cerr << "The chosen frame number is too large for the recording. Choose a smaller frame." << endl; - } - else { - //Compare a set of 3 values of the chosen frame between CPC and SPC: - //either (1) distance, azimuth, vertical angle, or (2) xyz - spcFrame = player->getNextContainerToBeSent(); - if (spcFrame.getDataType() == odcore::data::SharedPointCloud::ID()) { - readSPC(spcFrame); - if (m_xSpc.empty()) { - m_compareOption = 0; //compare distance, azimuth, vertical angle - } else { - m_compareOption = 1; //compare xyz - } - } - - cout << "Compare option:" << +m_compareOption <getNextContainerToBeSent(); - if (cpcFrame.getDataType() == odcore::data::CompactPointCloud::ID()) { - readCPC(cpcFrame, m_compareOption); - } - - if (m_compareOption == 0) { - cout << "Number of points of Frame " << m_chosenFrame << " of SPC:" << m_distanceSpc.size() << endl; - cout << "Number of points of Frame " << m_chosenFrame << " of CPC:" << m_distanceCpc.size() << endl; - - //cout << "The first 20 points of CPC:" << endl; - for (uint64_t index = 0; index < m_distanceCpc.size(); index++) { - m_cpcFrame << m_distanceCpc[index] << "," << m_azimuthCpc[index] << "," << m_verticalAngleCpc[index] << endl; - } - - //cout << "The first 20 points of SPC:" << endl; - for (uint64_t index = 0; index < m_distanceSpc.size(); index++) { - m_spcFrame << m_distanceSpc[index] << "," << m_azimuthSpc[index] << "," << m_verticalAngleSpc[index] << endl; - } - - float error_1, error_2, error_3; - uint32_t spc_index = 0; - for (uint32_t cpc_index = 0; cpc_index < m_distanceCpc.size(); cpc_index++) { - error_1 = abs(m_distanceCpc[cpc_index] - m_distanceSpc[spc_index]); - error_2 = abs(m_azimuthCpc[cpc_index] - m_azimuthSpc[spc_index]); - error_3 = abs(m_verticalAngleCpc[cpc_index] - m_verticalAngleSpc[spc_index]); - - //For the same point in CPC and SPC, the difference in z should be smaller - //than 0.003 - //Max distance error: 0.8cm (original integer value divided by 5 to get cm - //while storing CPC), i.e., 0.008m. Hence, the maximum difference in z should - //be 0.008 * sin(verticalAngle * toRadian), while verticalAngle is from -15 to - //15 with increment 2 - if (error_3 < 0.003) { - m_outputData << error_1 << "," << error_2 << "," << error_3 << endl; - spc_index++; - } - } - } else { - cout << "Number of points of Frame " << m_chosenFrame << " of SPC:" << m_xSpc.size() << endl; - cout << "Number of points of Frame " << m_chosenFrame << " of CPC:" << m_xCpc.size() << endl; - - //cout << "The first 20 points of CPC:" << endl; - for (uint64_t index = 0; index < m_xCpc.size(); index++) { - m_cpcFrame << m_xCpc[index] << "," << m_yCpc[index] << "," << m_zCpc[index] << endl; - } - - //cout << "The first 20 points of SPC:" << endl; - for (uint64_t index = 0; index < m_xSpc.size(); index++) { - m_spcFrame << m_xSpc[index] << "," << m_ySpc[index] << "," << m_zSpc[index] << endl; - } - - float error_x, error_y, error_z; - uint32_t spc_index = 0; - for (uint32_t cpc_index = 0; cpc_index < m_xCpc.size(); cpc_index++) { - error_x = abs(m_xCpc[cpc_index] - m_xSpc[spc_index]); - error_y = abs(m_yCpc[cpc_index] - m_ySpc[spc_index]); - error_z = abs(m_zCpc[cpc_index] - m_zSpc[spc_index]); - //For the same point in CPC and SPC, the difference in z should be smaller - //than 0.003 - //Max distance error: 0.8cm (original integer value divided by 5 to get cm - //while storing CPC), i.e., 0.008m. Hence, the maximum difference in z should - //be 0.008 * sin(verticalAngle * toRadian), while verticalAngle is from -15 to - //15 with increment 2 - if (error_z < 0.003) { - m_outputData << error_x << "," << error_y << "," << error_z << endl; - spc_index++; - } - } - } - clearVectors(m_compareOption, false); - } - } - - cout << "Comparison completed!" << endl; - - while (getModuleStateAndWaitForRemainingTimeInTimeslice() == odcore::data::dmcp::ModuleStateMessage::RUNNING) { - if (m_chosenFrame == m_currentFrame) { - getConference().send(spcFrame); - getConference().send(cpcFrame); - } - } - - return odcore::data::dmcp::ModuleExitCodeMessage::OKAY; - } - -} // odcomparepointcloud -