diff --git a/CMakeLists_ubuntu_mate.txt b/CMakeLists_ubuntu_mate.txt new file mode 100755 index 0000000..66ac5b1 --- /dev/null +++ b/CMakeLists_ubuntu_mate.txt @@ -0,0 +1,102 @@ +cmake_minimum_required (VERSION 2.8.13) +project (depth_eye) + +#set(CMAKE_INCLUDE_CURRENT_DIR 1) +string(REPLACE "\n" "" SYSTEM_VERSION ${CMAKE_SYSTEM_VERSION}) + +string (REGEX REPLACE "^([0-9]+).*" "\\1" + SYSTEM_MAJOR_VERSION "${SYSTEM_VERSION}") +string (REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" + SYSTEM_MINOR_VERSION "${SYSTEM_VERSION}") +string (REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" + SYSTEM_PATCH_VERSION ${SYSTEM_VERSION}) + +message("CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME} VERSION=${SYSTEM_VERSION}(${SYSTEM_MAJOR_VERSION}-${SYSTEM_MINOR_VERSION}-${SYSTEM_PATCH_VERSION})") +message("ARCH = ${CMAKE_SYSTEM_PROCESSOR}") +#set(CMAKE_SYSTEM_NAME "Linux") +set(VOXEL_INCLUDE ./third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7) +set(VOXEL_LIB ./third_party/voxelsdk_ubuntu_mate/lib) + +message("use Voxel SDK ${VOXEL_LIB}") +message("use Voxel INCLUDE ${VOXEL_INCLUDE}") + + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + #set(CMAKE_CXX_FLAGS "-msse2 -pthread -std=c++11 -fPIC -ffast-math") + set(CMAKE_CXX_FLAGS "-pthread -std=c++11 -fPIC -ffast-math") + set(COMMON_LIBS + /usr/local/lib + ./lib) + + if(SYSTEM_MAJOR_VERSION STREQUAL "3") + set(COMMON_INCLUDE + /usr/include/libusb-1.0 + ./include/ + ${VOXEL_INCLUDE}) + set(voxel ${VOXEL_LIB}) + message("use Voxel SDK ${VOXEL_LIB}") + else(SYSTEM_MAJOR_VERSION STREQUAL "4") + set(COMMON_INCLUDE + /usr/include/libusb-1.0 + ./include/ + ${VOXEL_INCLUDE}) + set(voxel ${VOXEL_LIB}) + message("use Voxel SDK ${VOXEL_LIB}") + endif() + +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(CMAKE_CXX_FLAGS "-msse2 -std=c++11 -fPIC -ffast-math") + set(COMMON_LIBS + /usr/local/lib + ./lib) + set(COMMON_INCLUDE + /usr/include/libusb-1.0 + ./include/ + ./third_party/voxelsdk_osx/include/voxel-0.6.7/ + ) + set(voxel ./third_party/voxelsdk_osx/lib) + message("use Voxel SDK ./third_party/voxelsdk_osx/lib") + +elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") + set(CMAKE_CXX_FLAGS "-pthread -std=c++11 -fPIC -ffast-math") + ADD_DEFINITIONS(-DANDROID) + set(ANDROID_ABI armeabi-v7a) + set(COMMON_INCLUDE + ./include/ + ./third_party/voxelsdk_android_jni/include/ + ./third_party/voxelsdk_android_jni/include/libusb/ + ./third_party/voxelsdk_android_jni/include/voxel-0.6.7/) + set(LIBUSB_DIR ./third_party/voxelsdk_android_jni/lib/libusb/) + add_library(usb-1.0 SHARED IMPORTED) + set_target_properties(usb-1.0 PROPERTIES IMPORTED_LOCATION ${LIBUSB_DIR}/${ANDROID_ABI}/libusb1.0.so) + set(COMMON_LIBS + usb-1.0 + dl) + set(voxel ./third_party/voxelsdk_android_jni/lib/) + message("use Voxel SDK ./third_party/voxelsdk_android_jni/lib/") + +else() + message(FATAL_ERROR "This project not support platform:${CMAKE_SYSTEM_NAME}") +endif() + +SET(BINDIR bin/) +SET(LIBDIR lib/) +SET(ARCDIR lib/) +SET(SHAREDIR share/) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${ARCDIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBDIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${BINDIR}) + +include_directories(${COMMON_INCLUDE}) +link_directories("/usr/local/lib" ${COMMON_LIBS} ${voxel}) + +#### Packaging related information -- common to both platforms +set(CPACK_PACKAGE_NAME "Depth Eye SDK") +set(CPACK_PACKAGE_VERSION "0.1") +set(CPACK_PACKAGE_CONTACT "Developer@pointcloud.ai") +set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE) +set(CPACK_PACKAGE_VENDOR "pointcloud.ai") +set(CPACK_SOURCE_GENERATOR "Developer") + +add_subdirectory(src) +add_subdirectory(test) diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/CameraSystem.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/CameraSystem.h new file mode 100755 index 0000000..4d8c464 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/CameraSystem.h @@ -0,0 +1,77 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_CAMERASYSTEM_H +#define VOXEL_CAMERASYSTEM_H + +#include +#include "DownloaderFactory.h" + +namespace Voxel +{ + +/** + * \defgroup CamSys Camera System Components + * @{ + * \brief This group of classes provide the higher level API for cameras + * @} + */ + +/** + * \ingroup CamSys + * + * \brief This class provides ways to instantiate individual cameras and components like filters. + */ +class VOXEL_EXPORT CameraSystem +{ +protected: + Vector _libraries; + Map _factories; // Key = device ID as returned by Device::id() + Map _depthCameras; // Key = device ID as returned by Device::id() + + Map _filterFactories; // Key = filter name + + Map _downloaderFactories;// Key = device ID as returned by Device::id() + + Map _factoryForGeneratorID; // Key = frame generator ID + + void _init(); + + void _loadLibraries(const Vector &paths); + +public: + CameraSystem(); + + bool addDepthCameraFactory(DepthCameraFactoryPtr factory); + + Vector scan(); + + DepthCameraPtr connect(const DevicePtr &device); + // Remove local reference. Outside calling function should remove reference to its DepthCamera as well + bool disconnect(const DepthCameraPtr &depthCamera, bool reset = false); + + + + bool addFilterFactory(FilterFactoryPtr filterFactory); + + Vector getSupportedFilters(); + bool getFilterDescription(const String &filterName, FilterDescription &description); + FilterPtr createFilter(const String &name, DepthCamera::FrameType type); + + Vector getProgrammableDevices(); + bool addDownloaderFactory(DownloaderFactoryPtr downloaderFactory); + DownloaderPtr getDownloader(const DevicePtr &device); + + bool getFrameGenerator(uint8_t frameType, GeneratorIDType generatorID, FrameGeneratorPtr &frameGenerator); + + + + virtual ~CameraSystem(); +}; + +} + +#endif // VOXEL_CAMERASYSTEM_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Common.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Common.h new file mode 100755 index 0000000..8fade6e --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Common.h @@ -0,0 +1,205 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_COMMON_H +#define VOXEL_COMMON_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include + +#include +#include + +#include "VoxelConfig.h" +#include "VoxelExports.h" + +#if defined(_WIN32) || defined(APPLE) || defined(ANDROID) +typedef uint32_t uint; +#endif + +namespace Voxel +{ + +/** + * \defgroup Util Common and Utility classes + * @{ + */ + +#ifndef SWIG +template +using Vector = std::vector; + +template +using List = std::list; + +template +using Set = std::set; + +template +using Map = std::unordered_map; + +template +using Function = std::function; + +template +using Atomic = std::atomic; + +template +using Lock = std::unique_lock; + +template +using shared_ptr = Ptr; +#else +#define Vector std::vector +#define List std::list +#define Set std::set +#define Map std::unordered_map +#define Function std::function +#define Atomic std::atomic +#define Lock std::unique_lock +#endif + +typedef std::string String; +typedef int IndexType; +typedef std::size_t SizeType; +typedef uint8_t ByteType; +typedef uint64_t TimeStampType; +typedef uint32_t GeneratorIDType; +typedef uint64_t FileOffsetType; + + +typedef std::complex Complex; +typedef std::complex ComplexDouble; + +typedef std::thread Thread; +typedef Ptr ThreadPtr; +typedef std::mutex Mutex; +typedef std::condition_variable ConditionVariable; + +typedef std::ifstream InputFileStream; +typedef std::ofstream OutputFileStream; + +typedef std::istream InputStream; +typedef std::ostream OutputStream; +typedef std::ostringstream OutputStringStream; +typedef std::istringstream InputStringStream; + +struct Version { uint8_t major, minor; }; + +/// String functions +String VOXEL_EXPORT getHex(uint16_t value); +void VOXEL_EXPORT split(const String &str, const char delimiter, Vector &split); +void VOXEL_EXPORT breakLines(const String &str, std::ostream &out, const uint maxPerLine, const String &newlinePrefix); + +/// Array handling template +template +int arraySize(T(&)[sz]) +{ + return sz; +} + +// Allocate in bytes and irrespective of size required by 'T'. This is useful if 'T' is has data structures which could have extendable elements. +// E.g.: Windows USB device handling structures in usbioctl.h +template +Ptr byteAlloc(unsigned long sizeInBytes) +{ + return Ptr((T *)new uint8_t[sizeInBytes], [](T *d) { delete[]((uint8_t *)d); }); +} + +uint VOXEL_EXPORT gcd(uint n, uint m); + +// This returns nearest 'n = 2^m' such that 2^(m - 1) < value < 2^m +unsigned int VOXEL_EXPORT nearestPowerOf2(unsigned int value, unsigned int &index); + +#define FLOAT_EPSILON 1E-5f + +inline bool floatEquals(float lhs, float rhs) +{ + if((lhs - rhs > FLOAT_EPSILON) || (rhs - lhs > FLOAT_EPSILON)) + return false; + else + return true; +} + +/** + * @brief Left Trim + * + * Trims whitespace from the left end of the provided String + * + * @param[out] s The String to trim + * + * @return The modified String& + */ +inline String& ltrim(String& s) { + s.erase(s.begin(), std::find_if(s.begin(), s.end(), + std::ptr_fun(std::isgraph))); + return s; +} + +/** + * @brief Right Trim + * + * Trims whitespace from the right end of the provided String + * + * @param[out] s The String to trim + * + * @return The modified String& + */ +inline String& rtrim(String& s) { + s.erase(std::find_if(s.rbegin(), s.rend(), + std::ptr_fun(std::isgraph)).base(), s.end()); + return s; +} + +/** + * @brief Trim + * + * Trims whitespace from both ends of the provided String + * + * @param[out] s The String to trim + * + * @return The modified String& + */ +inline String& trim(String& s) { + return ltrim(rtrim(s)); +} + +/// Filesystem functions -- returns the number of files read or else -1 for error. Only those files whose name matches "matchString" partially (sub-string) are returned "files" +int VOXEL_EXPORT getFiles(const String &dir, const String &matchString, Vector &files); + +bool VOXEL_EXPORT isFilePresent(const String &filename); +bool VOXEL_EXPORT isDirectory(const String &filename); +bool VOXEL_EXPORT makeDirectory(const String &filename); +String VOXEL_EXPORT dirname(const String &filename); +String VOXEL_EXPORT basename(const String &filename); + +String VOXEL_EXPORT substitute(const String &s, const Vector &keys, const Vector &values); + +/** + * @} + */ + +} + +#endif //VOXEL_COMMON_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Configuration.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Configuration.h new file mode 100755 index 0000000..6d25787 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Configuration.h @@ -0,0 +1,505 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_CONFIGURATION_H +#define VOXEL_CONFIGURATION_H + +#include "Common.h" +#include "Serializable.h" +#include "DataPacket.h" +#include "HardwareSerializer.h" + +#define FILE_PREFIX "file:" + +#define CALIB_DISABLE "calib_disable" + +namespace Voxel +{ + +/** + * \ingroup Util + */ + +struct SDKVersion +{ + uint8_t major, minor, patch, abi, conf; +}; + +class VOXEL_EXPORT Configuration +{ +protected: + struct _Path + { + String installPath; + String environmentVariable; + }; + + String _sdkPath; + String _sdkVersion; + + Vector _pathKeys; + Vector _pathValues; + + static const Map _pathTypes; + + bool _getPaths(const String &type, Vector &paths); + + bool _get(const String &type, String &name); + + static bool _addPath(const String &type, const String &path); + +public: + static SDKVersion getSDKVersion(); + + Configuration(); + + inline bool getFirmwarePaths(Vector &paths) { return _getPaths("fw", paths); } + inline bool getConfPaths(Vector &paths) { return _getPaths("conf", paths); } + inline bool getLibPaths(Vector &paths) { return _getPaths("lib", paths); } + + inline static bool addFirmwarePath(const String &path) { return _addPath("fw", path); } + inline static bool addConfPath(const String &path) { return _addPath("conf", path); } + inline static bool addLibPath(const String &path) { return _addPath("lib", path); } + static bool addPathToEnvironmentVariable(const String &environmentVariable, const String &path, bool prepend = true); + + inline static bool getEnvironmentVariable(const String &environmentVariable, String &value) + { + char *p = getenv(environmentVariable.c_str()); + if(p) { value = p; return true; } + return false; + } + + static bool setEnvironmentVariable(const String &environmentVariable, const String &value); + + inline static bool setSDKPath(const String &path) { return setEnvironmentVariable("VOXEL_SDK_PATH", path); } + inline static bool getSDKPath(String &path) { return getEnvironmentVariable("VOXEL_SDK_PATH", path); } + + bool getLocalPath(const String &type, String &path); + inline bool getLocalFirmwarePath(String &path) { return getLocalPath("fw", path); } + inline bool getLocalConfPath(String &path) { return getLocalPath("conf", path); } + inline bool getLocalLibPath(String &path) { return getLocalPath("lib", path); } + + bool getLocalFile(const String &type, String &fileName); + inline bool getLocalFirmwareFile(String &fileName) { return getLocalFile("fw", fileName); } + inline bool getLocalConfFile(String &fileName) { return getLocalFile("conf", fileName); } + inline bool getLocalLibFile(String &fileName) { return getLocalFile("lib", fileName); } + + /// Updates "name" to full path + inline bool getConfFile(String &fileName) { return _get("conf", fileName); } + inline bool getFirmwareFile(String &fileName) { return _get("fw", fileName); } + inline bool geLibFile(String &fileName) { return _get("lib", fileName); } + +}; + +class ConfigurationFile; + +class VOXEL_EXPORT ConfigSet +{ +protected: + bool _get(const String &name, String &value) const; + bool _set(const String &name, const String &value); + +public: + Map params; + Vector paramNames; + + bool remove(const String &name); + + bool isEmpty() { return params.size() == 0; } + + bool isPresent(const String &name) const; + String get(const String &name) const; + int getInteger(const String &name) const; + float getFloat(const String &name) const; + bool getBoolean(const String &name) const; + + bool set(const String &name, const String &value); + bool setInteger(const String &name, int value); + bool setFloat(const String &name, float value); + bool setBoolean(const String &name, bool value); + + friend class ConfigurationFile; +}; + +struct ConfigDataPacket: public DataPacket +{ + enum PacketType + { + PACKET_CONFIG = 0, + PACKET_2D_DATA_FILE = 1 + }; + + ConfigDataPacket(): DataPacket() {} +}; + +class MainConfigurationFile; + +class VOXEL_EXPORT ConfigurationFile +{ +protected: + bool _get(const String §ion, const String &name, String &value) const; + bool _set(const String §ion, const String &name, const String &value); + + String _fileName; + + Map> _dataFiles; + + MainConfigurationFile *_mainConfigurationFile; + + int _id, _parentID; + String _profileName; + + mutable Mutex _mutex; + + bool _serializeAllDataFiles(OutputStream &out); + bool _saveAllDataFiles(const String &prefix); + + template + bool _getData(const String &fileName, Vector &data); + + template + bool _setData(const String &fileName, const Vector &data); + + bool _copyFromParentIfNotPresent(ConfigurationFile *other, bool recurse = true); + +public: + typedef Map ConfigSetMap; + + enum Location + { + IN_HOST = 0, + IN_CAMERA = 1 + }; + +protected: + Location _location; + +public: + ConfigSetMap configs; + + inline Location getLocation() const { return _location; } + inline int getID() const { return _id; } + inline int getParentID() const { return _parentID; } + inline const String &getProfileName() const { return _profileName; } + + virtual bool isPresent(const String §ion, const String &name, bool includeParent = true) const; + virtual String get(const String §ion, const String &name) const; + + inline void setProfileName(const String &name) { _profileName = name; set("global", "name", name); } + inline void setID(const int id) { _id = id; setInteger("global", "id", id); } + inline void setParentID(const int id) { _parentID = id; setInteger("global", "parent", id); } + + template + bool getFile(const String §ion, const String &name, String &fileName, Vector &data); + + int getInteger(const String §ion, const String &name) const; + float getFloat(const String §ion, const String &name) const; + bool getBoolean(const String §ion, const String &name) const; + + virtual bool set(const String §ion, const String &name, const String &value); + + template + bool setFile(const String §ion, const String &name, const String &fileName, const Vector &data); + + bool setInteger(const String §ion, const String &name, int value); + bool setFloat(const String §ion, const String &name, float value); + bool setBoolean(const String §ion, const String &name, bool value); + + bool remove(const String §ion, const String &name); + bool removeSection(const String §ion); + + virtual bool getConfigSet(const String §ion, const ConfigSet *&configSet, bool includeParent = true) const; + + virtual bool read(const String &configFile); + virtual bool read(InputStream &in); + + virtual bool write(const String &configFile = ""); + virtual bool write(OutputStream &out); + + bool isValidCameraProfile(); + + virtual bool removeFile(); + + inline void clear() { Lock _(_mutex); configs.clear(); } + + inline const String &getConfigFileName() { return _fileName; } + + ConfigurationFile(): ConfigurationFile(0) {} + ConfigurationFile(MainConfigurationFile *mainConfigurationFile): + _mainConfigurationFile(mainConfigurationFile), _id(-1), _parentID(-1), _location(IN_HOST) {} + + ConfigurationFile(const ConfigurationFile &other) + { + operator =(other); + } + + inline ConfigurationFile &operator =(const ConfigurationFile &other) + { + configs = other.configs; + _fileName = other._fileName; + _mainConfigurationFile = other._mainConfigurationFile; + _id = other._id; + _profileName = other._profileName; + _parentID = other._parentID; + _location = other._location; + _dataFiles = other._dataFiles; + return *this; + } + + inline bool mergeParentConfiguration() + { + return _copyFromParentIfNotPresent(this); + } + + inline ConfigurationFile ©(const ConfigurationFile &other) + { + return operator =(other); + } + + virtual ~ConfigurationFile() {} + + friend class MainConfigurationFile; +}; + +template +bool ConfigurationFile::getFile(const String §ion, const String &name, String &fileName, Vector &data) +{ + String v = get(section, name); + + if(v.compare(0, sizeof(FILE_PREFIX) - 1, FILE_PREFIX) != 0 || v.size() <= sizeof(FILE_PREFIX) - 1) + { + logger(LOG_ERROR) << "ConfigurationFile: section = " << section << ", name = " << name << ", is not a file type." << std::endl; + return false; + } + + fileName = v.substr(sizeof(FILE_PREFIX) - 1); + + return _getData(fileName, data); +} + +template +bool ConfigurationFile::setFile(const String §ion, const String &name, const String &fileName, const Vector &data) +{ + return _setData(fileName, data) && set(section, name, "file:" + fileName); +} + +template +bool ConfigurationFile::_setData(const String &fileName, const Vector &data) +{ + Configuration c; + + String f = fileName; + if(!c.getLocalConfFile(f)) + { + logger(LOG_ERROR) << "ConfigurationFile: Failed to locate file '" << fileName << "'" << std::endl; + return false; + } + + OutputFileStream fs(f, std::ios::out | std::ios::binary); + + if(!fs.good()) + { + logger(LOG_ERROR) << "ConfigurationFile: Could not open file '" << fileName << "'" << std::endl; + return false; + } + + fs.write((const char *)data.data(), data.size()*sizeof(T)); + + fs.close(); + + _dataFiles[fileName].resize(data.size()*sizeof(T)); + + memcpy(_dataFiles[fileName].data(), data.data(), data.size()*sizeof(T)); + + return true; +} + +struct CalibrationInformation +{ + String name; + int id; + Vector definingParameters; + Vector calibrationParameters; +}; + +class VOXEL_EXPORT MainConfigurationFile: public ConfigurationFile +{ +protected: + Map _cameraProfiles; + Map _cameraProfileNames; + int _defaultCameraProfileID, _defaultCameraProfileIDInHardware; + int _currentCameraProfileID; + ConfigurationFile *_currentCameraProfile; + + bool _updateCameraProfileList(); + + String _mainConfigName, _hardwareID; + + int _getNewCameraProfileID(bool inHost = true); + + bool _saveHardwareImage(Version &version, TimeStampType ×tamp, SerializedObject &so); + + HardwareSerializerPtr _hardwareSerializer; + + int _quantizationFactor; + + Map _calibrationInformation; + + bool _removeCameraProfile(const int id, bool updateHardware = true); + bool _saveCameraProfileToHardware(int &id, Vector &newIDsAdded, Vector &oldIDsModified, bool saveParents = false, bool updateHardware = true, bool setAsDefault = false, const String &namePrefix = ""); + bool _rollbackCameraProfiles(const Vector &newIDsAdded, const Vector &oldIDsModified); + +public: + MainConfigurationFile(const String &name, const String &hardwareID, int quantizationFactor = 4, HardwareSerializerPtr hardwareSerializer = nullptr): + _currentCameraProfile(nullptr), _defaultCameraProfileID(-1), _defaultCameraProfileIDInHardware(-1), _mainConfigName(name), _hardwareSerializer(hardwareSerializer), + _quantizationFactor(quantizationFactor) + { + if(!hardwareSerializer) + _hardwareSerializer = HardwareSerializerPtr(new HardwareSerializer()); + } + + void setSerializationQuantizationFactor(int quantizationFactor) { _quantizationFactor = quantizationFactor; } + + virtual bool read(const String &configFile); + + bool readFromHardware(); + bool writeToHardware(); + + inline bool hasHardwareConfigurationSupport() { return _hardwareSerializer && *_hardwareSerializer; } + + inline void setHardwareConfigSerializer(const HardwareSerializerPtr &hardwareSerializer) { _hardwareSerializer = hardwareSerializer; } + + virtual String get(const String §ion, const String &name) const; + virtual bool isPresent(const String §ion, const String &name, bool includeParent = true) const; + + int addCameraProfile(const String &profileName, const int parentID = -1); + bool setCurrentCameraProfile(const int id); + bool removeAllHardwareCameraProfiles(); + bool removeCameraProfile(const int id); + bool saveCameraProfileToHardware(int &id, bool saveParents = false, bool setAsDefault = false, const String &namePrefix = ""); + + ConfigurationFile *getDefaultCameraProfile(); + ConfigurationFile *getCameraProfile(const int id); + + template + bool getFile(const String §ion, const String &name, String &fileName, Vector &data); + + inline int getDefaultCameraProfileID() + { + if(_defaultCameraProfileIDInHardware >= 0) + return _defaultCameraProfileIDInHardware; + else + return _defaultCameraProfileID; + } + + inline int getDefaultCameraProfileIDInHost() + { + return _defaultCameraProfileID; + } + + inline int getDefaultCameraProfileIDInCamera() + { + return _defaultCameraProfileIDInHardware; + } + + /// This only removes the default ID from hardware and not the profile itself + bool removeDefaultCameraProfileIDInCamera(); + + bool setDefaultCameraProfile(const int id); + + inline void setHardwareID(const String &hwID) { _hardwareID = hwID; } + + inline int getCurrentProfileID() { return _currentCameraProfileID; } + + bool getCameraProfileName(const int id, String &cameraProfileName); + + inline const Map &getCameraProfileNames() { return _cameraProfileNames; } + + inline const Map &getCalibrationInformation() const { return _calibrationInformation; } + + virtual ~MainConfigurationFile() {} + + friend class ConfigurationFile; + friend class DepthCamera; +}; + +template +bool ConfigurationFile::_getData(const String &fileName, Vector &data) +{ + bool loadFromFile = false; + if(_dataFiles.find(fileName) == _dataFiles.end()) + { + if(_mainConfigurationFile && _parentID >= 0) + { + ConfigurationFile *parentConfig = _mainConfigurationFile->getCameraProfile(_parentID); + + // TODO This does not handle circular references between profiles + if(parentConfig && parentConfig->_getData(fileName, data)) + return true; + else + loadFromFile = true; + } + else + loadFromFile = true; + } + + if(loadFromFile) + { + Configuration c; + + String f = fileName; + if(!c.getConfFile(f)) + { + logger(LOG_ERROR) << "ConfigurationFile: Could not locate file '" << fileName << "'" << std::endl; + return false; + } + + InputFileStream fs(f, std::ios::in | std::ios::binary | std::ios::ate); + + if(!fs.good()) + { + logger(LOG_ERROR) << "ConfigurationFile: Could not open file '" << fileName << "'" << std::endl; + return false; + } + + int size = fs.tellg(); + + if(size == 0) + { + logger(LOG_ERROR) << "ConfigurationFile: Null config data '" << f << "'" << std::endl; + return false; + } + + Vector &d = _dataFiles[fileName]; + + d.resize(size); + fs.seekg(std::ios::beg); + fs.clear(); + fs.read((char *)d.data(), size); + } + + Vector &d = _dataFiles[fileName]; + + data.resize((d.size() + sizeof(T)/2)/sizeof(T)); + + memcpy(data.data(), d.data(), d.size()); + + return true; +} + +template +bool MainConfigurationFile::getFile(const String §ion, const String &name, String &fileName, Vector &data) +{ + if(!_currentCameraProfile || !_currentCameraProfile->getFile(section, name, fileName, data)) + return ConfigurationFile::getFile(section, name, fileName, data); + else + return true; +} + + +} + +#endif // CONFIGURATION_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Convolve2D.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Convolve2D.h new file mode 100755 index 0000000..3554651 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Convolve2D.h @@ -0,0 +1,28 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + + +#include + +namespace Voxel +{ + +class VOXEL_EXPORT Convolve2D +{ +protected: + Vector _coefficients; + + SizeType _rows, _columns; + +public: + Convolve2D(const Vector &coefficients, SizeType rows, SizeType columns); + + bool convolve(const Vector &in, SizeType rows, SizeType columns, Vector &out); + +}; + + +} \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DFT.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DFT.h new file mode 100755 index 0000000..50fa6de --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DFT.h @@ -0,0 +1,89 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + * + * Borrowed from: DFT (Discrete Fourier Transform) and FFT (Fast Fourier Transform) + * Written by Paul Bourke, June 1993. WWW - http://paulbourke.net/miscellaneous/dft/ + * + * Modifications done for datatypes. + * + */ + +#ifndef VOXEL_DFT_H +#define VOXEL_DFT_H + +#include + +namespace Voxel +{ + +/** + * \defgroup Flt Filter related classes + * @{ + */ + +typedef Vector Complex1D; +typedef Vector> Complex2D; + +class VOXEL_EXPORT DFT +{ +public: + enum Direction + { + FORWARD = 1, + REVERSE = -1 + }; + +protected: + Complex2D _internal; + + Map _expTable; + + void _computeExpTable(SizeType size, Direction dir); + +public: + /** + * Perform a 2D FFT inplace given a complex 2D array + * The direction dir, 1 for forward, -1 for reverse + * The size of the array (nx,ny) + * Return false if there are memory problems or + * the dimensions are not powers of 2 + */ + bool DFT2D(Complex2D &data, Direction dir); + + /** + * This computes an in-place complex-to-complex DFT + * x and y are the real and imaginary arrays of 2^m points. + * dir = 1 gives forward transform + * dir = -1 gives reverse transform + * + * Formula: forward + * N-1 + * --- + * 1 \ - j k 2 pi n / N + * X(n) = --- > x(k) e = forward transform + * N / n=0..N-1 + * --- + * k=0 + * + * Formula: reverse + * N-1 + * --- + * \ j k 2 pi n / N + * X(n) = > x(k) e = forward transform + * / n=0..N-1 + * --- + * k=0 + */ + bool DFT1D(const Complex1D &in, Complex1D &out, Direction dir); +}; + +/** + * @} + */ + + +} + +#endif \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Data2DCodec.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Data2DCodec.h new file mode 100755 index 0000000..70876e5 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Data2DCodec.h @@ -0,0 +1,69 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + * + */ + +#ifndef VOXEL_DATA_2D_CODEC_H +#define VOXEL_DATA_2D_CODEC_H + +#include "Common.h" + +#include "DFT.h" + +namespace Voxel +{ + +/** + * \defgroup Flt Filter related classes + * @{ + */ + +/** + * @brief This class is used for compressing and decompressing 16-bit signed data. + * + * Primary application of this is for 2D phase offset data compression to store in + * permanent memory of depth camera + * + */ +class VOXEL_EXPORT Data2DCodec +{ + struct EightBitOffset + { + int r, c; + int8_t offset; + + int index; + + EightBitOffset(int r, int c, int8_t offset, int index): r(r), c(c), offset(offset), index(index) {} + }; + + int _quantization; + +public: + typedef Vector ByteArray; + typedef Vector ArrayBool2D; + typedef int16_t Array2DElementType; + typedef Vector Array2D; + + + Data2DCodec(int quantization = 4): _quantization(quantization) {} + + bool compress(const Array2D &in, const ArrayBool2D &invalidPixels, ByteArray &out); + bool decompress(const ByteArray &in, Array2D &out); + + bool writeGrayBMPImage(const String &fileName, const Array2D &a, const uint16_t rows, const uint16_t columns); + bool writeGrayBMPImage(const String &fileName, const Complex2D &c); + + virtual ~Data2DCodec() {} +}; + +/** + * @} + */ + + +} + +#endif \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DataPacket.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DataPacket.h new file mode 100755 index 0000000..b991a8f --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DataPacket.h @@ -0,0 +1,46 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_DATA_PACKET_H +#define VOXEL_DATA_PACKET_H + +#include "Common.h" +#include "SerializedObject.h" + +#include "Logger.h" + +namespace Voxel +{ + +struct VOXEL_EXPORT DataPacket +{ + char magic[6]; // supposed to be VOXEL + + uint8_t type; // PacketType + + uint32_t size; + + SerializedObject object; + + DataPacket() { strcpy(magic, "VOXEL"); } + + bool readHeader(SerializedObject &in); + bool readHeader(InputStream &in); + + bool read(SerializedObject &in); + bool read(InputStream &in); + + bool write(SerializedObject &out); + bool write(OutputStream &out); + + inline bool verifyMagic() { return magic[0] == 'V' && magic[1] == 'O' && magic[2] == 'X' && magic[3] == 'E' && magic[4] == 'L'; } +}; + + + +} + +#endif \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DepthCamera.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DepthCamera.h new file mode 100755 index 0000000..dbf2018 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DepthCamera.h @@ -0,0 +1,477 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_DEPTHCAMERA_H +#define VOXEL_DEPTHCAMERA_H + +#include +#include +#include +#include "VideoMode.h" +#include + +#include +#include + +#include + +#include +#include "FrameStream.h" +#include "FrameGenerator.h" +#include "PointCloudFrameGenerator.h" +#include "Configuration.h" + +#define CALIB_SECT_LENS "lens" +#define CALIB_SECT_LENS_ID 0 + +namespace Voxel +{ + +/** + * \ingroup CamSys + * + * \brief This is primary class which provides API for a depth camera. + * + * DepthCamera is an abstract class which needs to be derived and implemented + * for individual depth camera types. + */ +class VOXEL_EXPORT DepthCamera +{ +public: + enum FrameType + { + FRAME_RAW_FRAME_UNPROCESSED = 0, + FRAME_RAW_FRAME_PROCESSED = 1, + FRAME_DEPTH_FRAME = 2, + FRAME_XYZI_POINT_CLOUD_FRAME = 3, + FRAME_TYPE_COUNT = 4 // This is just used for number of callback types + }; + + typedef Function CallbackType; + +private: + mutable Mutex _accessMutex; // This is locked by getters and setters which are public + mutable Mutex _frameStreamWriterMutex; + +protected: + DevicePtr _device; + + String _name, _id, _chipset; + + Map _parameters; + + Ptr _programmer; + Ptr _streamer; + + // NOTE: Constructors of derived classes need to initialize the first two entries in this array + FrameGeneratorPtr _frameGenerators[3]; + + Ptr _pointCloudFrameGenerator; + + bool _parameterInit; + + FrameBufferManager _rawFrameBuffers; + FrameBufferManager _depthFrameBuffers; + FrameBufferManager _pointCloudBuffers; + + FilterSet _unprocessedFilters, _processedFilters; + + FilterSet _depthFilters; + + FrameStreamWriterPtr _frameStreamWriter; + + bool _addParameters(const Vector ¶ms); + + CallbackType _callback[FRAME_TYPE_COUNT]; + + uint32_t _callBackTypesRegistered = 0; + + ThreadPtr _captureThread; + + // Callback the registered function for 'type' if present and decide whether continue processing or not + virtual bool _callbackAndContinue(uint32_t &callBackTypesToBeCalled, FrameType type, const Frame &frame); + + virtual bool _start() = 0; + virtual bool _stop() = 0; + + virtual bool _captureRawUnprocessedFrame(RawFramePtr &rawFrame) = 0; + virtual bool _processRawFrame(const RawFramePtr &rawFrameInput, RawFramePtr &rawFrameOutput) = 0; // here output raw frame will have processed data, like ToF data for ToF cameras + virtual bool _convertToDepthFrame(const RawFramePtr &rawFrame, DepthFramePtr &depthFrame) = 0; + virtual bool _convertToPointCloudFrame(const DepthFramePtr &depthFrame, PointCloudFramePtr &pointCloudFrame); + + virtual void _captureLoop(); // the main capture loop + + void _captureThreadWrapper(); // this is non-virtual and simply calls _captureLoop + + bool _running, _isPaused; // is capture running? + + bool _writeToFrameStream(RawFramePtr &rawUnprocessed); + + // These protected getters and setters are not thread-safe. These are to be directly called only when nested calls are to be done from getter/setter to another. + // Otherwise use the public functions + template + bool _get(const String &name, T &value, bool refresh = false) const; + + template + bool _set(const String &name, const T &value); + + virtual bool _setFrameRate(const FrameRate &r) = 0; + virtual bool _getFrameRate(FrameRate &r) const = 0; + + virtual bool _setFrameSize(const FrameSize &s) = 0; + virtual bool _getFrameSize(FrameSize &s) const = 0; + virtual bool _getMaximumFrameSize(FrameSize &s) const = 0; + virtual bool _getMaximumFrameRate(FrameRate &frameRate, const FrameSize &forFrameSize) const = 0; + virtual bool _getSupportedVideoModes(Vector &supportedVideoModes) const = 0; + virtual bool _getMaximumVideoMode(VideoMode &videoMode) const = 0; + + virtual bool _getBytesPerPixel(uint &bpp) const = 0; + virtual bool _setBytesPerPixel(const uint &bpp) = 0; + + + virtual bool _getROI(RegionOfInterest &roi) const = 0; + virtual bool _setROI(const RegionOfInterest &roi) = 0; + virtual bool _allowedROI(String &message) = 0; + + virtual bool _getFieldOfView(float &fovHalfAngle) const = 0; + + inline void _makeID() { _id = _name + "(" + _device->id() + ")"; } + + virtual bool _reset() = 0; + virtual bool _onReset() = 0; + + virtual bool _applyConfigParams(const ConfigSet *params); + + virtual bool _saveCurrentProfileID(const int id) = 0; + virtual bool _getCurrentProfileID(int &id) = 0; + + bool _init(); + + inline Map &_getCalibrationInformationStructure() { return configFile._calibrationInformation; } + +public: + MainConfigurationFile configFile; // This corresponds to camera specific configuration file + + DepthCamera(const String &name, const String &chipset, DevicePtr device); + + virtual bool isInitialized() const + { + return _programmer && _programmer->isInitialized() && + _streamer && _streamer->isInitialized() && _parameterInit; + } + + + inline const String &name() const { return _name; } + + inline const String &id() const { return _id; } + + inline const String &chipset() const { return _chipset; } + + virtual bool getSerialNumber(String &serialNumber) const; + virtual bool setSerialNumber(const String &serialNumber); + + inline const DevicePtr &getDevice() const { return _device; } + + inline bool isRunning() const { return _running; } + + inline bool isPaused() const { return _isPaused; } + + bool pause(); + bool resume(); + + template + bool getStreamParam(const String &name, T &value) const; + + bool refreshParams(); + + template + bool get(const String &name, T &value, bool refresh = false) const; + + template + bool set(const String &name, const T &value); + + // WARNING: Avoid using get() and set() on ParameterPtr, obtained via getParam() or getParameters(). It is not thread-safe. Instead use get() and set() on DepthCamera + inline const ParameterPtr getParam(const String &name) const; + inline const Map &getParameters() const { return _parameters; } + + inline bool setFrameRate(const FrameRate &r); + inline bool getFrameRate(FrameRate &r) const; + + inline bool setFrameSize(const FrameSize &s); + inline bool getFrameSize(FrameSize &s) const; + inline bool getMaximumFrameSize(FrameSize &s) const; + inline bool getMaximumFrameRate(FrameRate &frameRate, const FrameSize &forFrameSize) const; + inline bool getSupportedVideoModes(Vector &supportedVideoModes) const; + inline bool getMaximumVideoMode(VideoMode &videoMode) const; + + inline bool getBytesPerPixel(uint &bpp) const; + inline bool setBytesPerPixel(const uint &bpp); + + inline bool getROI(RegionOfInterest &roi); + inline bool setROI(const RegionOfInterest &roi); + inline bool allowedROI(String &message); + + inline bool getFieldOfView(float &fovHalfAngle) const; + + virtual bool saveFrameStream(const String &fileName); + virtual bool isSavingFrameStream(); + virtual bool closeFrameStream(); + + virtual bool registerCallback(FrameType type, CallbackType f); + virtual bool clearAllCallbacks(); + virtual bool clearCallback(FrameType type); + + bool getFrameGeneratorConfig(FrameType type, SerializedObject &object) + { + // FRAME_RAW_FRAME_UNPROCESSED = 0, + // FRAME_RAW_FRAME_PROCESSED = 1, + // FRAME_DEPTH_FRAME = 2, + if(type==FRAME_RAW_FRAME_UNPROCESSED) + { + return this->_frameGenerators[0]->writeConfiguration(object); + } + else if(type==FRAME_RAW_FRAME_PROCESSED) + { + return this->_frameGenerators[1]->writeConfiguration(object); + } + else if(type==FRAME_DEPTH_FRAME) + { + return this->_frameGenerators[2]->writeConfiguration(object); + } + + + return false; + } + + // beforeFilterIndex = -1 => at the end, otherwise at location before the given filter index. + // Return value: + // >= 0 => add successfully with return value as filter ID. + // -1 => failed to add filter + virtual int addFilter(FilterPtr p, FrameType frameType, int beforeFilterID = -1); + virtual FilterPtr getFilter(int filterID, FrameType frameType) const; + virtual bool removeFilter(int filterID, FrameType frameType); + virtual bool removeAllFilters(FrameType frameType); + virtual void resetFilters(); + + inline const FilterSet &getUnprocessedRawFilterSet() { return _unprocessedFilters; } + inline const FilterSet &getProcessedRawFilterSet() { return _processedFilters; } + inline const FilterSet &getDepthFilterSet() { return _depthFilters; } + + bool start(); + bool stop(); + + void wait(); + + bool reset(); + + inline Ptr getProgrammer() { return _programmer; } // RegisterProgrammer is usually thread-safe to use outside directly + inline Ptr getStreamer() { return _streamer; } // Streamer may not be thread-safe + + inline bool reloadConfiguration() { return configFile.read(_name + ".conf"); } + inline const Map &getCameraProfileNames() { return configFile.getCameraProfileNames(); } + inline int getCurrentCameraProfileID() { return configFile.getCurrentProfileID(); } + + int addCameraProfile(const String &profileName, const int parentID); + bool setCameraProfile(const int id, bool softApply = false); + bool removeCameraProfile(const int id); + inline bool saveCameraProfileToHardware(int &id, bool saveParents = false, bool setAsDefault = false, const String &namePrefix = "") { return configFile.saveCameraProfileToHardware(id, saveParents, setAsDefault, namePrefix); } + + bool close(); + virtual ~DepthCamera(); +}; + +template +bool DepthCamera::get(const String &name, T &value, bool refresh) const +{ + Lock _(_accessMutex); + return _get(name, value, refresh); +} + +template +bool DepthCamera::set(const String &name, const T &value) +{ + Lock _(_accessMutex); + return _set(name, value); +} + +bool DepthCamera::getFieldOfView(float &fovHalfAngle) const +{ + Lock _(_accessMutex); + return _getFieldOfView(fovHalfAngle); +} + +bool DepthCamera::getFrameRate(FrameRate &r) const +{ + Lock _(_accessMutex); + return _getFrameRate(r); +} + +bool DepthCamera::setFrameRate(const FrameRate &r) +{ + Lock _(_accessMutex); + return _setFrameRate(r); +} + +bool DepthCamera::getFrameSize(FrameSize &s) const +{ + Lock _(_accessMutex); + return _getFrameSize(s); +} + +bool DepthCamera::setFrameSize(const FrameSize &s) +{ + Lock _(_accessMutex); + return _setFrameSize(s); +} + +bool DepthCamera::getMaximumFrameSize(FrameSize &s) const +{ + Lock _(_accessMutex); + return _getMaximumFrameSize(s); +} + +bool DepthCamera::getMaximumFrameRate(FrameRate &frameRate, const FrameSize &forFrameSize) const +{ + Lock _(_accessMutex); + return _getMaximumFrameRate(frameRate, forFrameSize); +} + + +bool DepthCamera::getSupportedVideoModes(Vector &supportedVideoModes) const +{ + Lock _(_accessMutex); + return _getSupportedVideoModes(supportedVideoModes); +} + +bool DepthCamera::getMaximumVideoMode(VideoMode &videoMode) const +{ + Lock _(_accessMutex); + return _getMaximumVideoMode(videoMode); +} + +bool DepthCamera::getBytesPerPixel(uint &bpp) const +{ + Lock _(_accessMutex); + return _getBytesPerPixel(bpp); +} + +bool DepthCamera::setBytesPerPixel(const uint &bpp) +{ + Lock _(_accessMutex); + return _setBytesPerPixel(bpp); +} + + +bool DepthCamera::allowedROI(String &message) +{ + Lock _(_accessMutex); + return _allowedROI(message); +} + +bool DepthCamera::getROI(RegionOfInterest &roi) +{ + Lock _(_accessMutex); + return _getROI(roi); +} + +bool DepthCamera::setROI(const RegionOfInterest &roi) +{ + Lock _(_accessMutex); + return _setROI(roi); +} + +template +bool DepthCamera::_get(const String &name, T &value, bool refresh) const +{ + auto p = _parameters.find(name); + + if(p != _parameters.end()) + { + ParameterTemplate *param = dynamic_cast *>(p->second.get()); + + if(param == 0) + { + logger(LOG_ERROR) << "DepthCamera: Invalid value type '" << typeid(value).name() << "' used to get parameter " << _id << "." << name << std::endl; + return false; + } + + if(!param->get(value, refresh)) + { + logger(LOG_ERROR) << "DepthCamera:Could not get value for parameter " << _id << "." << name << std::endl; + return false; + } + + return true; + } + else + { + //james mark following line + //logger(LOG_ERROR) << "DepthCamera: _get Unknown parameter " << _id << "." << name << std::endl; + return false; + } +} + +template +bool DepthCamera::_set(const String &name, const T &value) +{ + auto p = _parameters.find(name); + + if(p != _parameters.end()) + { + logger(LOG_DEBUG) << "DepthCamera: Setting parameter '" << name << "' = " << value << std::endl; + ParameterTemplate *param = dynamic_cast *>(p->second.get()); + + if(param == 0) + { + logger(LOG_ERROR) << "DepthCamera: Invalid value type '" << typeid(value).name() << "' used to set parameter " << this->name() << "(" << _device->id() << ")." << name << std::endl; + return false; + } + + if(!param->set(value)) + { + logger(LOG_ERROR) << "DepthCamera: Could not set value " << value << " for parameter " << this->name() << "(" << _device->id() << ")." << name << std::endl; + return false; + } + + return true; + } + else + { + //james mark following line + //logger(LOG_ERROR) << "DepthCamera:_set Unknown parameter " << _id << "." << name << std::endl; + return false; + } +} + +const ParameterPtr DepthCamera::getParam(const String &name) const +{ + auto p = _parameters.find(name); + + if(p != _parameters.end()) + return p->second; + else + { + //james mark following line + //logger(LOG_ERROR) << "DepthCamera: getParam Unknown parameter " << _id << "." << name << std::endl; + return 0; + } +} + +template +bool DepthCamera::getStreamParam(const String &name, T &value) const +{ + if(!_frameGenerators[0]->get(name, value) && !_frameGenerators[1]->get(name, value) && !_frameGenerators[2]->get(name, value)) + return false; + + return true; +} + + +typedef Ptr DepthCameraPtr; + +} + +#endif // DEPTHCAMERA_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DepthCameraFactory.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DepthCameraFactory.h new file mode 100755 index 0000000..94547fc --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DepthCameraFactory.h @@ -0,0 +1,75 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_DEPTHCAMERA_FACTORY_H +#define VOXEL_DEPTHCAMERA_FACTORY_H + +#include "DepthCamera.h" +#include "Common.h" +#include "Device.h" + +namespace Voxel +{ + +/** + * \addtogroup CamSys + * @{ + */ +class VOXEL_EXPORT DepthCameraFactory +{ +protected: + Vector _supportedDevices; + + inline void _addSupportedDevices(const Vector &devices); + + String _name; + +public: + DepthCameraFactory(const String &name): _name(name) {} + + inline const String &name() const { return _name; } + + inline const Vector &getSupportedDevices() const { return _supportedDevices; } + + // Get the list of channels supported by this device + virtual bool getChannels(Device &device, Vector &channels) = 0; + + // Instantiate a depth camera for the specified device + virtual DepthCameraPtr getDepthCamera(DevicePtr device) = 0; + + virtual bool getFrameGenerator(uint8_t frameType, GeneratorIDType generatorID, FrameGeneratorPtr &frameGenerator) = 0; + virtual Vector getSupportedGeneratorTypes() = 0; + + virtual ~DepthCameraFactory() {} +}; + +void DepthCameraFactory::_addSupportedDevices(const Vector &devices) +{ + _supportedDevices.reserve(_supportedDevices.size() + devices.size()); + _supportedDevices.insert(_supportedDevices.end(), devices.begin(), devices.end()); +} + + +// Implement this function in every device-specific voxel library + +typedef Ptr DepthCameraFactoryPtr; + +#ifndef SWIG +extern "C" void getDepthCameraFactory(DepthCameraFactoryPtr &depthCameraFactory); + +extern "C" int getABIVersion(); +#endif + +typedef void (*GetDepthCameraFactory)(DepthCameraFactoryPtr &depthCameraFactory); // Function type to return DepthCameraFactory + +typedef int(*GetABIVersion)(); // Function type to return ABI version + +/** + * @} + */ +} + +#endif // DEPTHCAMERA_FACTORY_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DepthCameraLibrary.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DepthCameraLibrary.h new file mode 100755 index 0000000..e7284ad --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DepthCameraLibrary.h @@ -0,0 +1,57 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_DEPTHCAMERALIBRARY_H +#define VOXEL_DEPTHCAMERALIBRARY_H + +#include +#include +#include +#include "DownloaderFactory.h" + +namespace Voxel +{ + +/** + * \addtogroup CamSys + * @{ + */ + +class VOXEL_NO_EXPORT DepthCameraLibraryPrivate; + +class VOXEL_EXPORT DepthCameraLibrary +{ +protected: + String _libName; + + Ptr _libraryPrivate; + +public: + DepthCameraLibrary(const String &libName); + + bool load(); + + inline bool isLoaded(); + + DepthCameraFactoryPtr getDepthCameraFactory(); + + FilterFactoryPtr getFilterFactory(); + + DownloaderFactoryPtr getDownloaderFactory(); + + int getABIVersion(); // Get DepthCameraLibrary's ABI version + + virtual ~DepthCameraLibrary(); +}; + +typedef Ptr DepthCameraLibraryPtr; + +/** + * @} + */ +} + +#endif // VOXEL_DEPTHCAMERALIBRARY_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Device.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Device.h new file mode 100755 index 0000000..0c1f0ea --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Device.h @@ -0,0 +1,127 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_DEVICE_H +#define VOXEL_DEVICE_H + +#include "Common.h" +#include + +namespace Voxel +{ + +/** + * \addtogroup CamSys + * @{ + */ +class VOXEL_EXPORT Device +{ +public: + enum Interface { + USB = 0, + LPT = 1, + SERIAL = 2, + I2C = 3 + }; +protected: + String _id; // in the format interface::device::serialnumber. "device" for USB devices is "vendorid:productid" + Interface _interfaceID; + String _deviceID; + String _serialNumber; + + String _serialIndex; + bool _showSerialIndex; + + String _description; + int _channelID; // Channel ID for multi-channel devices + + void _makeID() + { + std::ostringstream s; + s << _interfaceID << "::" << _deviceID << "::" << _serialNumber; + + if(_showSerialIndex) + s << ":" << _serialIndex; + + if(_channelID >= 0) + s << "::" << _channelID; + + _id = s.str(); + } + +public: + Device(Interface interfaceid, const String &deviceid, const String &serialnumber, int channelID = -1, const String &description = "", const String &serialIndex = "", bool showSerialIndex = false): _interfaceID(interfaceid), + _deviceID(deviceid), _serialNumber(serialnumber), _description(description), _channelID(channelID), _serialIndex(serialIndex), _showSerialIndex(showSerialIndex) + { + _makeID(); + } + + // Need to implement in all derived classes + virtual Vector> getDevices(const Vector &channels) const { return Vector>(); } + + inline const String &id() const { return _id; } + + inline Interface interfaceID() const { return _interfaceID; } + inline const String &deviceID() const { return _deviceID; } + inline const String &serialNumber() const { return _serialNumber; } + inline void setSerialNumber(const String &s) { _serialNumber = s; } + inline const String &serialIndex() const { return _serialIndex; } + inline void showSerialIndex() { _showSerialIndex = true; _makeID(); } + inline void dontShowSerialIndex() { _showSerialIndex = false; _makeID(); } + inline const int channelID() const { return _channelID; } + inline const String &description() const { return _description; } + virtual ~Device() {} +}; + +typedef Ptr DevicePtr; + +class VOXEL_EXPORT USBDevice : public Device +{ + uint16_t _vendorID, _productID; +public: + USBDevice(uint16_t vendorid, uint16_t productid, const String &serialnumber, int channelID = -1, const String &description = "", const String &serialIndex = "", bool showSerialIndex = false): + Device(Device::USB, getHex(vendorid) + ":" + getHex(productid), serialnumber, channelID, description, serialIndex, showSerialIndex), _vendorID(vendorid), _productID(productid) {} +#ifdef ANDROID + USBDevice(uint16_t vendorid, uint16_t productid, const String &serialnumber, int usbfd,int channelID = -1, const String &description = "", const String &serialIndex = "", bool showSerialIndex = false): + Device(Device::USB, getHex(vendorid) + ":" + getHex(productid), serialnumber, channelID, description, serialIndex, showSerialIndex), _vendorID(vendorid), _productID(productid),usbFd(usbfd) {} +#endif + virtual Vector getDevices(const Vector &channels) const; + + inline uint16_t vendorID() const { return _vendorID; } + inline uint16_t productID() const { return _productID; } +#ifdef ANDROID + int usbFd; +#endif + + virtual ~USBDevice() {} +}; + +class VOXEL_EXPORT DeviceScanner +{ +protected: + virtual Vector _scan() = 0; +public: + static Vector scan(); + + virtual ~DeviceScanner() {} +}; + +class VOXEL_EXPORT USBDeviceScanner : public DeviceScanner +{ +protected: + virtual Vector _scan(); + friend class DeviceScanner; + + virtual ~USBDeviceScanner() {} +}; + +/** + * @} + */ + +} + +#endif // DEVICE_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Downloader.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Downloader.h new file mode 100755 index 0000000..82b0938 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Downloader.h @@ -0,0 +1,92 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_DOWNLOADER_H +#define VOXEL_DOWNLOADER_H + +#include "Device.h" +#include +#include +#include "Logger.h" + +namespace Voxel +{ + +/** + * \defgroup IO I/O classes + * @{ + */ + +class VOXEL_EXPORT Downloader +{ +public: + typedef Function ProgressFunctionType; + +protected: + DevicePtr _device; + LoggerOutStream _outStream; + + ProgressFunctionType _progressFunction; + + virtual bool _locateFile(String &file); + + float _progress = 0; + inline void _setProgress(float progress /* percentage */) + { + _progress = (progress > 100?100:progress); + + if(_progress < 0) + _progress = 0; + + if(_progressFunction) + _progressFunction(progress); + } + + inline void _setProgressIncrement(float progress /* percentage */) + { + _setProgress(_progress + progress); + } + +public: + Downloader(DevicePtr device): _device(device) {} + + virtual bool download(const String &file) = 0; + + inline void setLogCallback(LoggerOutStream::LoggerOutStreamFunctionType f) { _outStream.setOutputFunction(f); } + inline void removeLogCallback() { _outStream.setOutputFunction(nullptr); } + + inline void setProgressFunction(ProgressFunctionType f) { _progressFunction = f; } + inline void removeProgressFunction() { _progressFunction = nullptr; } + inline float getProgress() { return _progress; } + + virtual ~Downloader() {} +}; + +typedef Ptr DownloaderPtr; + +class VOXEL_EXPORT USBDownloader: public Downloader +{ +protected: + USBIOPtr _usbIO; + + virtual bool _configureForDownload(); + virtual bool _download(InputFileStream &file, long unsigned int filesize); + +public: + USBDownloader(DevicePtr device); + + virtual bool download(const String &file); + + virtual ~USBDownloader() {} +}; + +/** + * @} + */ + +} + +#endif // VOXEL_DOWNLOADER_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DownloaderFactory.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DownloaderFactory.h new file mode 100755 index 0000000..d0f3117 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/DownloaderFactory.h @@ -0,0 +1,66 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_DOWNLOADER_FACTORY_H +#define VOXEL_DOWNLOADER_FACTORY_H + +#include "Downloader.h" +#include "Common.h" +#include "Device.h" + +namespace Voxel +{ + +/** + * \addtogroup CamSys + * @{ + */ + +class VOXEL_EXPORT DownloaderFactory +{ +protected: + Vector _supportedDevices; + + inline void _addSupportedDevices(const Vector &devices); + + String _name; + +public: + DownloaderFactory(const String &name): _name(name) {} + + inline const String &name() const { return _name; } + + inline const Vector &getSupportedDevices() const { return _supportedDevices; } + + // Instantiate a depth camera for the specified device + virtual DownloaderPtr getDownloader(DevicePtr device) = 0; + + virtual ~DownloaderFactory() {} +}; + +void DownloaderFactory::_addSupportedDevices(const Vector &devices) +{ + _supportedDevices.reserve(_supportedDevices.size() + devices.size()); + _supportedDevices.insert(_supportedDevices.end(), devices.begin(), devices.end()); +} + + +// Implement this function in every device-specific voxel library + +typedef Ptr DownloaderFactoryPtr; + +#ifndef SWIG +extern "C" void getDownloaderFactory(DownloaderFactoryPtr &downloaderFactory); +#endif + +typedef void (*GetDownloaderFactory)(DownloaderFactoryPtr &downloaderFactory); // Function type to return DownloaderFactory + +/** + * @} + */ +} + +#endif // DEPTHCAMERA_FACTORY_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/BilateralFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/BilateralFilter.h new file mode 100755 index 0000000..a00939a --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/BilateralFilter.h @@ -0,0 +1,52 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_BILATERAL_H +#define VOXEL_BILATERAL_H + +#include "Filter.h" + +#include "DiscreteGaussian.h" + + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class BilateralFilter: public Filter +{ +protected: + DiscreteGaussian _discreteGuassian; + + FrameSize _size; + + virtual void _onSet(const FilterParameterPtr &f); + + template + bool _filter(const T *in, const T2 *ref, T *out); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + +public: + BilateralFilter(float sigma = 0.5); + virtual ~BilateralFilter() {} + + virtual void reset(); + + +}; + +/** + * @} + */ + +} + +#endif // VOXEL_BILATERAL_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/DarkPixFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/DarkPixFilter.h new file mode 100755 index 0000000..8624e7a --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/DarkPixFilter.h @@ -0,0 +1,55 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_DARKPIX_H +#define VOXEL_DARKPIX_H + +#include "Filter.h" + +#include + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class VOXEL_EXPORT DarkPixFilter: public Filter +{ +protected: + float _aThrNear, _phThrNear; + float _aThrFar, _phThrFar; + float _ambThresh; + + Vector _current; + + FrameSize _size; + + template + bool _filter(const T *in, T *out); + + template + bool _filter2(const T *in, T2 *amp, uint8_t *amb, T *out); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + + virtual void _onSet(const FilterParameterPtr &f); + +public: + DarkPixFilter(float aThrNear = 1, float phThrNear = 4095, float aThrFar = 20, float phThrFar = 2000, float ambThresh = 1); + + virtual void reset(); + + virtual ~DarkPixFilter() {} +}; +/** + * @} + */ + +} +#endif // VOXEL_DARKPIX_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/DenoiseFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/DenoiseFilter.h new file mode 100755 index 0000000..f68c07f --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/DenoiseFilter.h @@ -0,0 +1,64 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_DENOISE_H +#define VOXEL_DENOISE_H + +#include "Filter.h" + +#include +#include + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class VOXEL_EXPORT DenoiseFilter: public Filter +{ +protected: + uint _order; + float _threshold; + + std::deque> _ampHistory; + std::deque> _phaseHistory; + std::deque> _ambHistory; + std::deque> _flagsHistory; + + FrameSize _size; + + template + bool _filter(const T *in, T *out); + + template + bool _filter2(const FramePtr &in_p, FramePtr &out_p); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + + virtual void _onSet(const FilterParameterPtr &f); + +public: + DenoiseFilter(uint order = 3, float threshold = 30/*10000*/); + + virtual void reset(); + + virtual ~DenoiseFilter() {} + +// liudao add in 2017.06.13 +public: + Vector m_frameIn; + Vector m_frameOut; + +}; +/** + * @} + */ + +} +#endif // VOXEL_DENOISE_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/DiscreteGaussian.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/DiscreteGaussian.h new file mode 100755 index 0000000..c7259d7 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/DiscreteGaussian.h @@ -0,0 +1,71 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_DISCRETE_GUASSIAN_H +#define VOXEL_DISCRETE_GUASSIAN_H + +#include "Common.h" + +#define _MATH_DEFINES +#include + + +namespace Voxel +{ + +class VOXEL_EXPORT DiscreteGaussian +{ + float _sigma, _squaredSigma; + + Vector _values; + + inline void _computeValues(); + +public: + DiscreteGaussian(float s) { setStandardDeviation(s); } + + inline void setStandardDeviation(float s) + { + _sigma = s; + _squaredSigma = _sigma*_sigma; + _computeValues(); + } + + inline float getStandardDeviation() const { return _sigma; } + inline float getSquaredStandardDeviation() const { return _squaredSigma; } + + inline float valueAt(int x) + { + int y = (x < 0)?-x:x; + + if(y >= _values.size()) + return 0.0f; + else + return _values[y]; + } +}; + +inline void DiscreteGaussian::_computeValues() +{ + int limit = sqrt(20)*_sigma + 1; // This would correspond to exp(-10) + + _values.resize(limit); + + if(!floatEquals(_sigma, 0)) + { + float d = _sigma*sqrt(2*M_PI); + + for(auto i = 0; i < limit; i++) + _values[i] = exp(-i*i/2.0f/_squaredSigma)/d; + } + else + _values[0] = 1; +} + + +} + +#endif diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/Filter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/Filter.h new file mode 100755 index 0000000..7901bfa --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/Filter.h @@ -0,0 +1,199 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_FILTER_H +#define VOXEL_FILTER_H + + +#include +#include +#include +#include + +#include + +#include "VoxelExports.h" + +namespace Voxel +{ + +class DepthCamera; + +typedef Ptr DepthCameraPtr; + +/** + * \defgroup Flt Filter related classes + * @{ + */ + +class VOXEL_EXPORT Filter +{ +protected: + String _name, _nameScope, _description; + String _id; + + inline void _makeID() + { + if(_nameScope.size()) + _id = _nameScope + "::" + _name; + else + _id = _name; + } + + mutable Mutex _accessMutex; + + DepthCameraPtr _depthCamera; + + Map _parameters; + + virtual bool _addParameters(const Vector ¶ms); + + virtual bool _prepareOutput(const FramePtr &in, FramePtr &out); + + // On setting of a parameter this is called + virtual void _onSet(const FilterParameterPtr &f) = 0; + + virtual bool _filter(const FramePtr &in, FramePtr &out) = 0; + + template + bool _get(const String &name, T &value); + + template + bool _set(const String &name, const T &value); + +public: + Filter(const String &name, const String &description = "", const String &nameScope = ""): _name(name), _nameScope(nameScope), _description(description) + { + _makeID(); + } + + inline void setDepthCamera(const DepthCameraPtr &d) + { + _depthCamera = d; + } + + inline const Map ¶meters() { return _parameters; } + + inline const String &name() { return _id; } + inline const String &description() { return _description; } + + inline void setNameScope(const String &scope) { _nameScope = scope; _makeID(); } + + inline bool filter(const FramePtr &in, FramePtr &out); + + virtual void reset() = 0; + + inline FilterParameterConstPtr getParam(const String &name) const; + + template + bool get(const String &name, T &value); + + template + bool set(const String &name, const T &value); + + + virtual ~Filter() {} +}; + +inline bool Filter::filter(const FramePtr &in, FramePtr &out) +{ + Lock _(_accessMutex); + return _filter(in, out); +} + + +FilterParameterConstPtr Filter::getParam(const String &name) const +{ + Lock _(_accessMutex); + + auto p = _parameters.find(name); + + if(p != _parameters.end()) + return std::const_pointer_cast(p->second); + else + return nullptr; +} + + +template +bool Filter::get(const String &name, T &value) +{ + Lock _(_accessMutex); + return _get(name, value); +} + +template +bool Filter::_get(const String &name, T &value) +{ + auto p = _parameters.find(name); + + if(p != _parameters.end()) + { + FilterParameterTemplate *f = dynamic_cast *>(p->second.get()); + + if(!f) + { + logger(LOG_ERROR) << "Filter: Invalid type '" << typeid(value).name() << "' to get parameter '" << name << "'" << std::endl; + return false; + } + + return f->get(value); + } + else + { + logger(LOG_ERROR) << "Filter: Unknown parameter name '" << name << "'" << std::endl; + return false; + } +} + +template +bool Filter::set(const String &name, const T &value) +{ + Lock _(_accessMutex); + return _set(name, value); +} + +template +bool Filter::_set(const String &name, const T &value) +{ + auto p = _parameters.find(name); + + if(p != _parameters.end()) + { + FilterParameterTemplate *f = dynamic_cast *>(p->second.get()); + + if(!f) + { + logger(LOG_ERROR) << "Filter: Invalid type '" << typeid(value).name() << "' to get parameter '" << name << "'" << std::endl; + return false; + } + + if(f->set(value)) + { + _onSet(p->second); + return true; + } + else + return false; + } + else + { + logger(LOG_ERROR) << "Filter: Unknown parameter name '" << name << "'" << std::endl; + return false; + } +} + +typedef Ptr FilterPtr; + +/** + * @} + */ + + +} + + +#endif //VOXEL_FILTER_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FilterFactory.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FilterFactory.h new file mode 100755 index 0000000..495fa37 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FilterFactory.h @@ -0,0 +1,79 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_FILTER_FACTORY_H +#define VOXEL_FILTER_FACTORY_H + +#include +#include + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class FilterDescription +{ + typedef Function _CreateFilter; +protected: + _CreateFilter _createFilter; +public: + String name; + uint frameTypes; // supported frame types (see #DepthCamera::FrameType) + + FilterDescription() {} + +#ifndef SWIG + FilterDescription(const String &n, uint f, _CreateFilter c): name(n), frameTypes(f), _createFilter(c) {} +#endif + + inline bool supports(DepthCamera::FrameType type) + { + return frameTypes & (1 << type); + } + + friend class FilterFactory; +}; + +class VOXEL_EXPORT FilterFactory +{ + +protected: + Map _supportedFilters; + bool _addSupportedFilters(const Vector &f); + + String _name; + +public: + FilterFactory(const String &name): _name(name) {} + + inline const String &name() const { return _name; } + + inline const Map &getSupportedFilters() const { return _supportedFilters; } + + virtual FilterPtr createFilter(const String &name, DepthCamera::FrameType type); +}; + +typedef Ptr FilterFactoryPtr; + +#ifndef SWIG +// Implement this function in support voxel library +extern "C" void getFilterFactory(FilterFactoryPtr &filterFactory); +#endif + +typedef void (*GetFilterFactory)(FilterFactoryPtr &filterFactory); // Function type to return DepthCameraFactory + +/** + * @} + */ + +} + + +#endif diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FilterParameter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FilterParameter.h new file mode 100755 index 0000000..0828a0f --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FilterParameter.h @@ -0,0 +1,199 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_FILTER_PARAMETER_H +#define VOXEL_FILTER_PARAMETER_H + +#include "Common.h" + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class FilterParameter +{ +protected: + String _name, _displayName, _description; + +public: + FilterParameter(const String &name, const String &displayName, const String &description): + _name(name), _displayName(displayName), _description(description) {} + + inline const String &name() const { return _name; } + inline const String &displayName() const { return _displayName; } + inline const String &description() const { return _description; } + + virtual ~FilterParameter() {} +}; + +typedef Ptr FilterParameterPtr; +typedef Ptr FilterParameterConstPtr; + +template +class FilterParameterTemplate: public FilterParameter +{ +protected: + T _value; + +public: + FilterParameterTemplate(const String &name, const String &displayName, const String &description, const T &defaultValue): + FilterParameter(name, displayName, description), _value(defaultValue) {} + + static Ptr> typeCast(const FilterParameterPtr &other) + { + return std::dynamic_pointer_cast>(other); + } + + virtual bool get(T &v) const { v = _value; return true; } + virtual bool set(const T &v) + { + if(validate(v)) + { + _value = v; + return true; + } + else + return false; + } + + virtual bool validate(const T &v) const = 0; + + virtual ~FilterParameterTemplate() {} +}; + +typedef FilterParameterTemplate BoolFilterParameterTemplate; +typedef FilterParameterTemplate IntegerFilterParameterTemplate; +typedef FilterParameterTemplate UnsignedIntegerFilterParameterTemplate; +typedef FilterParameterTemplate FloatFilterParameterTemplate; + +#ifdef SWIG +%template(BoolFilterParameterTemplate) FilterParameterTemplate; +%template(IntegerFilterParameterTemplate) FilterParameterTemplate; +%template(UnsignedIntegerFilterParameterTemplate) FilterParameterTemplate; +%template(FloatFilterParameterTemplate) FilterParameterTemplate; +#endif + + +template +class FilterParameterRangeTemplate: public FilterParameterTemplate +{ +protected: + T _lowerLimit, _upperLimit; + String _unit; +public: + FilterParameterRangeTemplate(const String &name, const String &displayName, const String &description, const T &defaultValue, + const String &unit, + const T &lowerLimit, const T &upperLimit): + FilterParameterTemplate(name, displayName, description, defaultValue), + _unit(unit), + _lowerLimit(lowerLimit), _upperLimit(upperLimit) {} + + static Ptr> typeCast(const FilterParameterPtr &other) + { + return std::dynamic_pointer_cast>(other); + } + + inline const T &lowerLimit() const { return _lowerLimit; } + inline const T &upperLimit() const { return _upperLimit; } + + inline const String &unit() const { return _unit; } + + virtual bool validate(const T &v) const + { + return (v >= _lowerLimit && v <= _upperLimit); + } + + virtual ~FilterParameterRangeTemplate() {} +}; + +typedef FilterParameterRangeTemplate UnsignedFilterParameter; +typedef FilterParameterRangeTemplate SignedFilterParameter; +typedef FilterParameterRangeTemplate FloatFilterParameter; + +#ifdef SWIG +%template(SignedFilterParameter) FilterParameterRangeTemplate; +%template(UnsignedFilterParameter) FilterParameterRangeTemplate; +%template(FloatFilterParameter) FilterParameterRangeTemplate; +#endif + + + +template +class FilterParameterEnumTemplate: public FilterParameterTemplate +{ +protected: + Vector _values; + Vector _valueMeaning, _valueDescription; + +public: + FilterParameterEnumTemplate(const String &name, const String &displayName, const String &description, const T &defaultValue, + const Vector &values, const Vector &valueMeaning, const Vector &valueDescription): + FilterParameterTemplate(name, displayName, description, defaultValue), + _values(values), _valueMeaning(valueMeaning), _valueDescription(valueDescription) {} + + static Ptr> typeCast(const FilterParameterPtr &other) + { + return std::dynamic_pointer_cast>(other); + } + + inline const Vector &valueMeaning() const { return _valueMeaning; } + inline const Vector &valueDescription() const { return _valueDescription; } + inline const Vector &values() const { return _values; } + + virtual bool validate(const T &v) const + { + for(auto t: _values) + { + if(t == v) + return true; + } + return false; + } + + virtual ~FilterParameterEnumTemplate() {} +}; + +typedef FilterParameterEnumTemplate EnumFilterParameter; + +typedef FilterParameterEnumTemplate BoolEnumFilterParameterTemplate; + +#ifdef SWIG +%template(BoolEnumFilterParameterTemplate) FilterParameterEnumTemplate; +%template(EnumFilterParameter) FilterParameterEnumTemplate; +#endif + + +class BoolFilterParameter: public FilterParameterEnumTemplate +{ +public: + BoolFilterParameter(const String &name, const String &displayName, const String &description, const bool &defaultValue, + const Vector &valueMeaning, const Vector &valueDescription): + FilterParameterEnumTemplate(name, displayName, description, defaultValue, {false, true}, + valueMeaning, valueDescription) {} + + + static Ptr typeCast(const FilterParameterPtr &other) + { + return std::dynamic_pointer_cast(other); + } + + + virtual ~BoolFilterParameter() {} +}; + +typedef BoolFilterParameter StrobeBoolFilterParameter; // Typedef StrobeBool to be same Bool parameter + +/** + * @} + */ + +} + +#endif // VOXEL_FILTER_PARAMETER_H \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FilterSet.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FilterSet.h new file mode 100755 index 0000000..284ee91 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FilterSet.h @@ -0,0 +1,278 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_FRAME_FILTER_SET_H +#define VOXEL_FRAME_FILTER_SET_H + +#include + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +template +class FilterSet; + +template +class FilterSetIterator +{ +public: + int i; + const FilterSet &s; + int index; + + FilterSetIterator(const FilterSet &s, int i = 0); + inline FilterSetIterator &operator++(int); + inline FilterSetIterator &operator++(); + inline const FilterPtr operator *(); + inline bool operator !=(const FilterSetIterator &other) const; + inline bool operator ==(const FilterSetIterator &other) const; +}; + +template +class FilterSet +{ +protected: + Vector _indices; + int _filterCounter; + Map _filters; + + mutable Mutex _accessMutex; + + FrameBufferManager &_frameBufferManager; + +public: + class FrameSequence: public List> + { + public: + ~FrameSequence() + { + while(this->size()) + this->pop_front(); + } + }; + + FilterSet(FrameBufferManager &m): _frameBufferManager(m), _filterCounter(0) { _indices.reserve(10); } + + // position = -1 => at the end, otherwise at zero-indexed 'position' + int addFilter(FilterPtr p, int beforeFilterIndex = -1); + FilterPtr getFilter(int index) const; + bool removeFilter(int index); + bool removeAllFilters(); + + inline SizeType size() const { return _indices.size(); } + + // Populate one entry in 'seq' before calling this function. That entry will be used + // as input to the first filter and then onwards till the last filter. Each filter will + // append one entry which contains the filter frame + bool applyFilter(FrameSequence &seq); + + void reset(); + + FilterSetIterator begin() const + { + return FilterSetIterator(*this, 0); + } + + FilterSetIterator end() const + { + return FilterSetIterator(*this, _indices.size()); + } + + friend class FilterSetIterator; +}; + +template +int FilterSet::addFilter(FilterPtr p, int beforeFilterIndex) +{ + Lock _(_accessMutex); + + if( beforeFilterIndex == -1) + _indices.push_back(_filterCounter); + else + { + auto found = -1; + for(auto i = 0; i < _indices.size(); i++) + if(_indices[i] == beforeFilterIndex) + found = i; + + if(found < 0) + return -1; // -1 => invalid filter index + + _indices.insert(_indices.begin() + found, _filterCounter); + } + + _filters[_filterCounter] = p; + + _frameBufferManager.setMinimumBufferCount(_frameBufferManager.getMinimumBufferCount() + 1); + + int i = _filterCounter; + + _filterCounter++; + + return i; +} + +template +FilterPtr FilterSet::getFilter(int index) const +{ + Lock _(_accessMutex); + + auto x = _filters.find(index); + + if(x != _filters.end()) + return x->second; + else + return nullptr; +} + + +template +bool FilterSet::removeFilter(int index) +{ + Lock _(_accessMutex); + + auto x = _filters.find(index); + + if(x != _filters.end()) + { + for(auto i = 0; i < _indices.size(); i++) + { + if(_indices[i] == index) + { + _indices.erase(_indices.begin() + i); + break; + } + } + _filters.erase(x); + _frameBufferManager.setMinimumBufferCount(_frameBufferManager.getMinimumBufferCount() - 1); + + return true; + } + + return false; +} + +template +bool FilterSet::removeAllFilters() +{ + Lock _(_accessMutex); + + _frameBufferManager.setMinimumBufferCount(_frameBufferManager.getMinimumBufferCount() - _filters.size()); + _filters.clear(); + _indices.clear(); + + return true; +} + +template +bool FilterSet::applyFilter(FrameSequence &seq) +{ + Lock _(_accessMutex); + + if(seq.size() < 1) + { + logger(LOG_ERROR) << "Require atleast one frame in the sequence, to apply filters" << std::endl; + return false; + } + + for(auto f: *this) + { + auto g = _frameBufferManager.get(); + + FramePtr p = std::dynamic_pointer_cast(*g); + + if(!f->filter(std::dynamic_pointer_cast(**seq.begin()), p)) + { + logger(LOG_ERROR) << "FilterSet: Could not apply filter '" << f->name() << "'" << std::endl; + return false; + } + + *g = std::dynamic_pointer_cast(p); + + if(!*g) + { + logger(LOG_ERROR) << "FilterSet: Got an invalid frame from filter '" << f->name() << "'" << std::endl; + return false; + } + + seq.push_front(g); + } + return true; +} + +template +void FilterSet::reset() +{ + for(auto f: *this) + f->reset(); +} + +template +FilterSetIterator::FilterSetIterator(const FilterSet &s, int i): s(s), i(i) +{ + if(i < s._indices.size()) + index = s._indices[i]; +} + +template +inline FilterSetIterator &FilterSetIterator::operator++(int) +{ + i++; + + if(i < s._indices.size()) + index = s._indices[i]; + + return *this; +} + +template +inline FilterSetIterator &FilterSetIterator::operator++() +{ + i++; + + if(i < s._indices.size()) + index = s._indices[i]; + + return *this; +} + +template +inline const FilterPtr FilterSetIterator::operator *() +{ + if(i < s._indices.size()) + { + return s._filters.at(index); + } + else + return nullptr; +} + +template +inline bool FilterSetIterator::operator !=(const FilterSetIterator &other) const +{ + return !operator==(other); +} + +template +inline bool FilterSetIterator::operator ==(const FilterSetIterator &other) const +{ + return (&s == &other.s) && (i == other.i); +} + + +/** + * @} + */ + + +} + +#endif //VOXEL_FRAME_FILTER_SET_H \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FlyingPixFilter2.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FlyingPixFilter2.h new file mode 100755 index 0000000..daa8ec9 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FlyingPixFilter2.h @@ -0,0 +1,53 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2017.6.1 by liudao + * method: remove jump point + */ + +#ifndef VOXEL_FLYINGPIX2_H +#define VOXEL_FLYINGPIX2_H + +#include "Filter.h" + +#include + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class VOXEL_EXPORT FlyingPixFilter2: public Filter +{ +protected: + uint _phaseDiffTh; // phase差值阈值 + uint _greaterNum; // 邻域内大于给定值的元素个数 + + FrameSize _size; + + template + bool _filter(const T *in, T *out); + + template + bool _filter2(const FramePtr &in_p, FramePtr &out_p); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + + virtual void _onSet(const FilterParameterPtr &f); + +public: + FlyingPixFilter2(uint nPhasediffth=10, uint nGreaterNum=4); + + virtual void reset(); + + virtual ~FlyingPixFilter2() {} +}; +/** + * @} + */ + +} +#endif // VOXEL_DARKPIX_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FlypixFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FlypixFilter.h new file mode 100755 index 0000000..97580c8 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/FlypixFilter.h @@ -0,0 +1,50 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2017 Texas Instruments Inc. + */ + +#ifndef VOXEL_FLYPIX_H +#define VOXEL_FLYPIX_H + +#include "Filter.h" + +#define _MATH_DEFINES +#include + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class VOXEL_EXPORT FlypixFilter: public Filter +{ +protected: + float _thr; + + FrameSize _size; + + virtual void _onSet(const FilterParameterPtr &f); + + template + bool _filter(const T *in, T *out); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + +public: + FlypixFilter(float thr = 500); + virtual ~FlypixFilter() {} + + virtual void reset(); +}; + + +/** + * @} + */ + +} +#endif // VOXEL_FLYPIX_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/HDRFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/HDRFilter.h new file mode 100755 index 0000000..4fd9e2f --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/HDRFilter.h @@ -0,0 +1,65 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_HDR_H +#define VOXEL_HDR_H + +#include "Filter.h" + +#include +#include + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class VOXEL_EXPORT HDRFilter: public Filter +{ +protected: + uint _order; + + std::deque> _ampHistory; + std::deque> _phaseHistory; + std::deque> _ambHistory; + std::deque> _flagsHistory; + + FrameSize _size; + + template + bool _filter(const T *in, T *out); + + template + bool _filter2(const FramePtr &in_p, FramePtr &out_p); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + + virtual void _onSet(const FilterParameterPtr &f); + +public: + HDRFilter(uint order = 2); + char *buffer; + char *processedbuffer; + + int newId; + int getId() + { + return newId++; + } + + virtual void reset(); + + virtual ~HDRFilter() {} +}; +/** + * @} + */ + +} +#endif // VOXEL_HDR_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/IIRFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/IIRFilter.h new file mode 100755 index 0000000..05371c2 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/IIRFilter.h @@ -0,0 +1,49 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_IIR_H +#define VOXEL_IIR_H + +#include "Filter.h" + +#include + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class VOXEL_EXPORT IIRFilter: public Filter +{ +protected: + float _gain; + Vector _current; + + FrameSize _size; + + template + bool _filter(const T *in, T *out); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + + virtual void _onSet(const FilterParameterPtr &f); + +public: + IIRFilter(float gain = 0.5); + + virtual void reset(); + + virtual ~IIRFilter() {} +}; +/** + * @} + */ + +} +#endif // VOXEL_IIR_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/MedianFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/MedianFilter.h new file mode 100755 index 0000000..f7e5272 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/MedianFilter.h @@ -0,0 +1,51 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_MEDIAN_FILTER_H +#define VOXEL_MEDIAN_FILTER_H + +#include +#include + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class MedianFilter: public Filter +{ +protected: + float _stability, _deadband, _deadbandStep; + uint _halfKernelSize; + + Vector _current, _hist; + + FrameSize _size; + + template + bool _filter(const T *in, T *out); + + virtual void _onSet(const FilterParameterPtr &f); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + +public: + MedianFilter(float stability = 0.1, float deadband = 0.05, float deadbandStep = 0.01, uint halfKernelSize = 1); + virtual ~MedianFilter() {} + + virtual void reset(); +}; + +/** + * @} + */ + + +} +#endif // VOXEL_MEDIAN_FILTER_H \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/NonlinearFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/NonlinearFilter.h new file mode 100755 index 0000000..8e92ca9 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/NonlinearFilter.h @@ -0,0 +1,54 @@ +// +// NonlinearFilter.hpp +// Voxel +// +// Created by 席齐 on 2017/7/26. +// +// + +#ifndef NonlinearFilter_hpp +#define NonlinearFilter_hpp +#include "Filter.h" +#include +#define LIGHT_SPEED 299792458.0 +namespace Voxel +{ + + /** + * \addtogroup Flt + * @{ + */ + + class VOXEL_EXPORT NonlinearFilter : public Filter + { + protected: + float _modFreq; + Vector _current; + + FrameSize _size; + + template + bool _filter(const T *in, T *out); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + + virtual void _onSet(const FilterParameterPtr &f); + + public: + NonlinearFilter(float frequce = 36); + + virtual void reset(); + + virtual ~NonlinearFilter() {} + float scaleFactor; + static float phase2distance[]; + static int *nonlinearPhase; + static int mapArraySize; + }; + /** + * @} + */ + +} + +#endif /* NonlinearFilter_hpp */ diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/SmoothFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/SmoothFilter.h new file mode 100755 index 0000000..46c30c2 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/SmoothFilter.h @@ -0,0 +1,51 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_SMOOTH_H +#define VOXEL_SMOOTH_H + +#include "Filter.h" +#include "DiscreteGaussian.h" + +#define _MATH_DEFINES +#include + +namespace Voxel +{ + +/** + * \addtogroup Flt + * @{ + */ + +class SmoothFilter: public Filter +{ +protected: + DiscreteGaussian _discreteGaussian; + + FrameSize _size; + + virtual void _onSet(const FilterParameterPtr &f); + + template + bool _filter(const T *in, T *out); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + +public: + SmoothFilter(float sigma = 0.5); + virtual ~SmoothFilter() {} + + virtual void reset(); +}; + + +/** + * @} + */ + +} +#endif // VOXEL_SMOOTH_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/TemporalMedianFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/TemporalMedianFilter.h new file mode 100755 index 0000000..15cc034 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Filter/TemporalMedianFilter.h @@ -0,0 +1,52 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TEMPORAL_MEDIAN_FILTER_H +#define VOXEL_TEMPORAL_MEDIAN_FILTER_H + +#include "Filter.h" + +#include + +namespace Voxel +{ +/** + * \addtogroup Flt + * @{ + */ +class TemporalMedianFilter: public Filter +{ +protected: + float _deadband; + uint _order; + + FrameSize _size; + List> _history; + Vector _current; + + virtual void _onSet(const FilterParameterPtr &f); + + template + void _getMedian(IndexType offset, T &value); + + template + bool _filter(const T *in, T *out); + + virtual bool _filter(const FramePtr &in, FramePtr &out); + +public: + TemporalMedianFilter(uint order = 3, float deadband = 0.05); + virtual ~TemporalMedianFilter() {} + + virtual void reset(); +}; + +/** + * @} + */ + +} +#endif // VOXEL_TEMPORAL_MEDIAN_FILTER_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Frame.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Frame.h new file mode 100755 index 0000000..0944a4e --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Frame.h @@ -0,0 +1,767 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_FRAME_H +#define VOXEL_FRAME_H + +#include +#include +#include "VideoMode.h" +#include "SerializedObject.h" + +#include + + +namespace Voxel +{ + +/** + * \defgroup Frm Frame related classes + * @{ + */ + +class VOXEL_EXPORT Frame +{ +public: + TimeStampType timestamp = 0; // Unix timestamp in micro-seconds + int id = -1; + + inline operator String() + { + std::ostringstream s; + s << id << "@" << timestamp; + return s.str(); + } + + virtual Ptr copy() const = 0; + virtual Ptr copyTo(Ptr &other) const = 0; + virtual Ptr newFrame() const = 0; + + virtual bool isSameType(const Frame &other) const = 0; + virtual bool isSameSize(const Frame &other) const = 0; + + virtual bool serialize(SerializedObject &object) const = 0; + + virtual bool deserialize(SerializedObject &object) = 0; + + virtual ~Frame() {} +}; + +typedef Ptr FramePtr; + +class VOXEL_EXPORT DepthFrame: public Frame +{ +public: + Vector depth; // depth frame row-wise. Unit: meters + Vector amplitude; // amplitude of each depth pixel normalized to value between 0 and 1 + FrameSize size; + + virtual Ptr copy() const + { + Ptr f(new DepthFrame()); + return copyTo(f); + } + + virtual Ptr copyTo(Ptr &other) const + { + if(!other || !isSameType(*other)) + other = Ptr(new DepthFrame()); + + DepthFrame *d = dynamic_cast(other.get()); + + d->id = id; + d->timestamp = timestamp; + d->depth = depth; + d->amplitude = amplitude; + d->size = size; + return other; + } + + virtual bool serialize(SerializedObject &object) const + { + size_t s = sizeof(id) + sizeof(timestamp) + depth.size()*sizeof(float)*2 + sizeof(size_t)*2; + + object.resize(s); + + object.put((const char *)&id, sizeof(id)); + object.put((const char *)×tamp, sizeof(timestamp)); + + object.put((const char *)&size.width, sizeof(size.width)); + object.put((const char *)&size.height, sizeof(size.height)); + + object.put((const char *)depth.data(), sizeof(float)*depth.size()); + object.put((const char *)amplitude.data(), sizeof(float)*amplitude.size()); + return true; + } + + virtual bool deserialize(SerializedObject &object) + { + if(!object.get((char *)&id, sizeof(id)) || + !object.get((char *)×tamp, sizeof(timestamp)) || + !object.get((char *)&size.width, sizeof(size.width)) || + !object.get((char *)&size.height, sizeof(size.height))) + return false; + + depth.resize(size.width*size.height); + amplitude.resize(size.width*size.height); + + if(!object.get((char *)depth.data(), sizeof(float)*depth.size()) || + !object.get((char *)amplitude.data(), sizeof(float)*amplitude.size())) + return false; + + return true; + } + + virtual bool isSameType(const Frame &other) const + { + const DepthFrame *f = dynamic_cast(&other); + return f; + } + + virtual bool isSameSize(const Frame &other) const + { + const DepthFrame *f = dynamic_cast(&other); + return (f && size == f->size); + } + + virtual Ptr newFrame() const + { + DepthFrame *d = new DepthFrame(); + d->depth.resize(depth.size()); + d->amplitude.resize(amplitude.size()); + d->size = size; + return FramePtr(d); + } + + static Ptr typeCast(FramePtr ptr) + { + return std::dynamic_pointer_cast(ptr); + } + + virtual ~DepthFrame() {} +}; + +typedef Ptr DepthFramePtr; + +class VOXEL_EXPORT RawFrame: public Frame +{ +public: + static Ptr typeCast(FramePtr ptr) + { + return std::dynamic_pointer_cast(ptr); + } + + virtual ~RawFrame() {} +}; + +typedef Ptr RawFramePtr; + +enum ToFFrameType { + ToF_PHASE_AMPLITUDE, + ToF_I_Q, + ToF_QUAD +}; + +class VOXEL_EXPORT ToFRawFrame : public RawFrame +{ +public: + virtual const uint8_t *phase() const = 0; + virtual uint8_t *phase() = 0; + virtual SizeType phaseWordWidth() const = 0; // in bytes + + virtual const uint8_t *amplitude() const = 0; + virtual uint8_t *amplitude() = 0; + virtual SizeType amplitudeWordWidth() const = 0; // in bytes + + virtual const uint8_t *flags() const = 0; + virtual uint8_t *flags() = 0; + virtual SizeType flagsWordWidth() const = 0; // in bytes + + virtual const uint8_t *ambient() const = 0; + virtual uint8_t *ambient() = 0; + virtual SizeType ambientWordWidth() const = 0; // in bytes + + virtual const uint16_t *histogram() const = 0; + virtual uint16_t *histogram() = 0; + virtual SizeType histogramSize() const = 0; // number of elements in the histogram + + FrameSize size; + + static Ptr typeCast(FramePtr ptr) + { + return std::dynamic_pointer_cast(ptr); + } + + virtual ~ToFRawFrame() {} +}; + +typedef Ptr ToFRawFramePtr; + +template +class VOXEL_EXPORT ToFRawFrameTemplate : public ToFRawFrame +{ +public: + typedef PhaseByteType AmplitudeByteType; + typedef AmbientByteType FlagsByteType; + + Vector _phase; + Vector _amplitude; + + Vector _ambient; + Vector _flags; + + Vector _histogram; + + virtual const uint8_t *ambient() const + { + return (const uint8_t *)_ambient.data(); + } + + virtual uint8_t *ambient() + { + return (uint8_t *)_ambient.data(); + } + + virtual SizeType ambientWordWidth() const + { + return sizeof(AmbientByteType); + } + + virtual const uint8_t *amplitude() const + { + return (const uint8_t *)_amplitude.data(); + } + + virtual uint8_t *amplitude() + { + return (uint8_t *)_amplitude.data(); + } + + virtual SizeType amplitudeWordWidth() const + { + return sizeof(AmplitudeByteType); + } + + virtual const uint8_t *phase() const + { + return (const uint8_t *)_phase.data(); + } + + virtual uint8_t *phase() + { + return (uint8_t *)_phase.data(); + } + + virtual SizeType phaseWordWidth() const + { + return sizeof(PhaseByteType); + } + + virtual const uint8_t *flags() const + { + return (const uint8_t *)_flags.data(); + } + + virtual uint8_t *flags() + { + return (uint8_t *)_flags.data(); + } + + virtual SizeType flagsWordWidth() const + { + return sizeof(FlagsByteType); + } + + virtual const uint16_t *histogram() const + { + return _histogram.data(); + } + + virtual uint16_t *histogram() + { + return _histogram.data(); + } + + virtual SizeType histogramSize() const + { + return _histogram.size(); + } + + virtual Ptr copy() const + { + Ptr f(new ToFRawFrameTemplate()); + return copyTo(f); + } + + virtual Ptr copyTo(Ptr &other) const + { + if(!other || !isSameType(*other)) + other = Ptr(new ToFRawFrameTemplate()); + + auto *t = dynamic_cast *>(other.get()); + + t->id = id; + t->timestamp = timestamp; + t->_phase = _phase; + t->_amplitude = _amplitude; + t->_ambient = _ambient; + t->_flags = _flags; + t->_histogram = _histogram; + t->size = size; + return other; + } + + virtual Ptr newFrame() const + { + ToFRawFrameTemplate *t = new ToFRawFrameTemplate(); + t->_phase.resize(_phase.size()); + t->_amplitude.resize(_amplitude.size()); + t->_ambient.resize(_ambient.size()); + t->_flags.resize(_flags.size()); + t->_histogram.resize(_histogram.size()); + t->size = size; + return FramePtr(t); + } + + virtual bool isSameType(const Frame &other) const + { + const ToFRawFrameTemplate *f = dynamic_cast *>(&other); + return f; + } + + static Ptr> typeCast(FramePtr ptr) + { + return std::dynamic_pointer_cast>(ptr); + } + + virtual bool isSameSize(const Frame &other) const + { + const ToFRawFrameTemplate *f = dynamic_cast *>(&other); + return (f && size == f->size); + } + + virtual bool serialize(SerializedObject &object) const + { + size_t s = sizeof(id) + sizeof(timestamp) + + _phase.size()*sizeof(PhaseByteType) + + _amplitude.size()*sizeof(AmplitudeByteType) + + _ambient.size()*sizeof(AmbientByteType) + + _flags.size()*sizeof(FlagsByteType) + + _histogram.size()*sizeof(uint16_t) + + sizeof(size_t)*2; + + object.resize(s); + + object.put((const char *)&id, sizeof(id)); + object.put((const char *)×tamp, sizeof(timestamp)); + + size_t histogramSize = _histogram.size(); + object.put((const char *)&size.width, sizeof(size.width)); + object.put((const char *)&size.height, sizeof(size.height)); + object.put((const char *)&histogramSize, sizeof(histogramSize)); + + object.put((const char *)_phase.data(), sizeof(PhaseByteType)*_phase.size()); + object.put((const char *)_amplitude.data(), sizeof(AmplitudeByteType)*_amplitude.size()); + object.put((const char *)_ambient.data(), sizeof(AmbientByteType)*_ambient.size()); + object.put((const char *)_flags.data(), sizeof(FlagsByteType)*_flags.size()); + + if(histogramSize) + object.put((const char *)_histogram.data(), sizeof(uint16_t)*_histogram.size()); + return true; + } + + virtual bool deserialize(SerializedObject &object) + { + object.get((char *)&id, sizeof(id)); + object.get((char *)×tamp, sizeof(timestamp)); + + size_t histogramSize; + object.get((char *)&size.width, sizeof(size.width)); + object.get((char *)&size.height, sizeof(size.height)); + object.get((char *)&histogramSize, sizeof(histogramSize)); + + unsigned int frameSize = size.width*size.height; + _phase.resize(frameSize); + _amplitude.resize(frameSize); + _ambient.resize(frameSize); + _flags.resize(frameSize); + + object.get((char *)_phase.data(), sizeof(PhaseByteType)*_phase.size()); + object.get((char *)_amplitude.data(), sizeof(AmplitudeByteType)*_amplitude.size()); + object.get((char *)_ambient.data(), sizeof(AmbientByteType)*_ambient.size()); + object.get((char *)_flags.data(), sizeof(FlagsByteType)*_flags.size()); + + if(histogramSize) + { + _histogram.resize(histogramSize); + object.get((char *)_histogram.data(), sizeof(uint16_t)*_histogram.size()); + } + else + _histogram.clear(); + + return true; + } + + virtual ~ToFRawFrameTemplate() {} +}; + +class VOXEL_EXPORT ToFRawIQFrame: public RawFrame +{ +public: + virtual const uint8_t *i() const = 0; + virtual uint8_t *i() = 0; + virtual const uint8_t *q() const = 0; + virtual uint8_t *q() = 0; + virtual SizeType wordWidth() const = 0; // in bytes + + FrameSize size; + + static Ptr typeCast(FramePtr ptr) + { + return std::dynamic_pointer_cast(ptr); + } + + virtual ~ToFRawIQFrame() {} +}; + +typedef Ptr ToFRawIQFramePtr; + +template +class VOXEL_EXPORT ToFRawIQFrameTemplate : public ToFRawIQFrame +{ +public: + Vector _i; + Vector _q; + + virtual const uint8_t *i() const + { + return (const uint8_t *)_i.data(); + } + + virtual uint8_t *i() + { + return (uint8_t *)_i.data(); + } + + virtual const uint8_t *q() const + { + return (const uint8_t *)_q.data(); + } + + virtual uint8_t *q() + { + return (uint8_t *)_q.data(); + } + + virtual SizeType wordWidth() const + { + return sizeof(ByteType); + } + + virtual Ptr copy() const + { + Ptr f(new ToFRawIQFrameTemplate()); + return copyTo(f); + } + + virtual Ptr copyTo(Ptr &other) const + { + if(!other || !isSameType(*other)) + other = Ptr(new ToFRawIQFrameTemplate()); + + auto *t = dynamic_cast *>(other.get()); + t->id = id; + t->timestamp = timestamp; + t->_i = _i; + t->_q = _q; + t->size = size; + return other; + } + + virtual Ptr newFrame() const + { + ToFRawIQFrameTemplate *t = new ToFRawIQFrameTemplate(); + t->_i.resize(_i.size()); + t->_q.resize(_q.size()); + t->size = size; + return FramePtr(t); + } + + virtual bool isSameType(const Frame &other) const + { + const ToFRawIQFrameTemplate *f = dynamic_cast *>(&other); + return f; + } + + static Ptr> typeCast(FramePtr ptr) + { + return std::dynamic_pointer_cast>(ptr); + } + + virtual bool isSameSize(const Frame &other) const + { + const ToFRawIQFrameTemplate *f = dynamic_cast *>(&other); + return (f && size == f->size); + } + + virtual bool serialize(SerializedObject &object) const + { + size_t s = sizeof(id) + sizeof(timestamp) + + _i.size()*sizeof(ByteType) + + _q.size()*sizeof(ByteType) + + sizeof(uint32_t)*2; + + object.resize(s); + + object.put((const char *)&id, sizeof(id)); + object.put((const char *)×tamp, sizeof(timestamp)); + + uint32_t x; + x = sizeof(ByteType); + object.put((const char *)&x, sizeof(x)); + + x = size.width; + object.put((const char *)&x, sizeof(x)); + x = size.height; + object.put((const char *)&x, sizeof(x)); + + object.put((const char *)_i.data(), sizeof(ByteType)*_i.size()); + object.put((const char *)_q.data(), sizeof(ByteType)*_q.size()); + return true; + } + + virtual bool deserialize(SerializedObject &object) + { + object.get((char *)&id, sizeof(id)); + object.get((char *)×tamp, sizeof(timestamp)); + + uint32_t x; + object.get((char *)&x, sizeof(x)); + + if(x != sizeof(ByteType)) + return false; + + object.get((char *)&x, sizeof(x)); + size.width = x; + object.get((char *)&x, sizeof(x)); + size.height = x; + + _i.resize(size.width*size.height); + _q.resize(size.width*size.height); + + object.get((char *)_i.data(), sizeof(ByteType)*_i.size()); + object.get((char *)_q.data(), sizeof(ByteType)*_q.size()); + + return true; + } + + virtual ~ToFRawIQFrameTemplate() {} +}; + +class VOXEL_EXPORT RawDataFrame : public RawFrame +{ +public: + Vector data; + + virtual Ptr copy() const + { + Ptr f(new RawDataFrame()); + return copyTo(f); + } + + virtual Ptr copyTo(Ptr &other) const + { + if(!other || !isSameType(*other)) + other = Ptr(new RawDataFrame()); + + auto *r = dynamic_cast(other.get()); + r->id = id; + r->timestamp = timestamp; + r->data = data; + return other; + } + + virtual Ptr newFrame() const + { + RawDataFrame *r = new RawDataFrame(); + r->data.resize(data.size()); + return FramePtr(r); + } + + virtual bool isSameType(const Frame &other) const + { + const RawDataFrame *f = dynamic_cast(&other); + return f; + } + + virtual bool isSameSize(const Frame &other) const + { + const RawDataFrame *f = dynamic_cast(&other); + return f && data.size() == f->data.size(); + } + + static Ptr typeCast(FramePtr ptr) + { + return std::dynamic_pointer_cast(ptr); + } + + virtual bool serialize(SerializedObject &object) const + { + size_t s = sizeof(id) + sizeof(timestamp) + data.size()*sizeof(ByteType) + sizeof(size_t); + + object.resize(s); + + object.put((const char *)&id, sizeof(id)); + object.put((const char *)×tamp, sizeof(timestamp)); + + s = data.size(); + object.put((const char *)&s, sizeof(s)); + + object.put((const char *)data.data(), sizeof(ByteType)*data.size()); + return true; + } + + virtual bool deserialize(SerializedObject &object) + { + size_t s; + if(!object.get((char *)&id, sizeof(id)) || + !object.get((char *)×tamp, sizeof(timestamp)) || + !object.get((char *)&s, sizeof(s))) + return false; + + data.resize(s); + + return object.get((char *)data.data(), sizeof(ByteType)*data.size()); + } + + virtual ~RawDataFrame() {} +}; + +typedef Ptr RawDataFramePtr; + + +class VOXEL_EXPORT PointCloudFrame : public Frame +{ +public: + virtual SizeType size() const = 0; + virtual Point *operator [](IndexType index) = 0; + + static Ptr typeCast(FramePtr ptr) + { + return std::dynamic_pointer_cast(ptr); + } + + virtual ~PointCloudFrame() {} +}; + +typedef Ptr PointCloudFramePtr; + +template +class VOXEL_EXPORT PointCloudFrameTemplate : public PointCloudFrame +{ +public: + Vector points; + + virtual SizeType size() const + { + return points.size(); + } + + virtual Point *operator[] (IndexType index) + { + if(index < points.size() && index >= 0) + return &points[index]; + else + return 0; + } + + virtual Ptr copy() const + { + Ptr f(new PointCloudFrameTemplate()); + return copyTo(f); + } + + virtual Ptr copyTo(Ptr &other) const + { + if(!other || !isSameType(*other)) + other = Ptr(new PointCloudFrameTemplate()); + + auto *p = dynamic_cast *>(other.get()); + p->id = id; + p->timestamp = timestamp; + p->points = points; + return other; + } + + virtual Ptr newFrame() const + { + PointCloudFrameTemplate *p = new PointCloudFrameTemplate(); + p->points.resize(points.size()); + return FramePtr(p); + } + + virtual bool isSameType(const Frame &other) const + { + const PointCloudFrameTemplate *f = dynamic_cast *>(&other); + return f; + } + + virtual bool isSameSize(const Frame &other) const + { + const PointCloudFrameTemplate *f = dynamic_cast *>(&other); + return f && f->size() == size(); + } + + virtual bool serialize(SerializedObject &object) const + { + size_t s = sizeof(id) + sizeof(timestamp) + points.size()*sizeof(PointType) + sizeof(size_t); + + object.resize(s); + + object.put((const char *)&id, sizeof(id)); + object.put((const char *)×tamp, sizeof(timestamp)); + + s = points.size(); + object.put((const char *)&s, sizeof(s)); + + object.put((const char *)points.data(), sizeof(PointType)*points.size()); + return true; + } + + virtual bool deserialize(SerializedObject &object) + { + object.get((char *)&id, sizeof(id)); + object.get((char *)×tamp, sizeof(timestamp)); + + size_t s; + object.get((char *)&s, sizeof(s)); + + points.resize(s); + + object.get((char *)points.data(), sizeof(ByteType)*points.size()); + return true; + } + + static Ptr> typeCast(FramePtr ptr) + { + return std::dynamic_pointer_cast>(ptr); + } + + virtual ~PointCloudFrameTemplate() {} +}; + +typedef PointCloudFrameTemplate XYZPointCloudFrame; +typedef PointCloudFrameTemplate XYZIPointCloudFrame; + +typedef Ptr XYZPointCloudFramePtr; + +/** + * @} + */ + +} + +#endif // VOXEL_POINT_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/FrameBuffer.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/FrameBuffer.h new file mode 100755 index 0000000..8d5f8bc --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/FrameBuffer.h @@ -0,0 +1,123 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_FRAMEBUFFER_H +#define VOXEL_FRAMEBUFFER_H + +#include +#include + +#include + +#define MAX_FRAME_BUFFERS 2 + +namespace Voxel +{ + +/** + * \addtogroup Frm + * @{ + */ + + +template +class FrameBufferManager; + +// Auto-releases the obtained buffer when FrameBuffer<> instance is terminated +template +class FrameBuffer: public Ptr +{ +public: + typedef Ptr BufferPtr; + +protected: + BufferPtr &_buffer; + + FrameBufferManager &_manager; + +public: + FrameBuffer(BufferPtr &buffer, FrameBufferManager &manager): _buffer(buffer), _manager(manager), + Ptr(nullptr, [&manager, &buffer](BufferType *) { manager.release(buffer); }) // The deleter gets called when FrameBuffer<> goes out of scope. Deleter releases the held buffer + {} + + inline BufferPtr &operator *() { return _buffer; } + + virtual ~FrameBuffer() {} +}; + +// This maintains a minimum number of buffers for use and re-use. +// Call to release() on unused buffers is important for it be either freed or reused +template +class FrameBufferManager +{ +public: + typedef Ptr BufferPtr; + typedef FrameBuffer FrameBufferType; + +protected: + List _inUse; + List _available; + + SizeType _minimumBufferCount; + +public: + FrameBufferManager(SizeType minBufferCount): _minimumBufferCount(minBufferCount) + { + for(auto i = 0; i < minBufferCount; i++) + _available.push_back(BufferPtr()); + } + + inline void setMinimumBufferCount(SizeType minBufferCount) + { + _minimumBufferCount = (minBufferCount > 0)?minBufferCount:MAX_FRAME_BUFFERS; + } + + inline SizeType getMinimumBufferCount() const + { + return _minimumBufferCount; + } + + FrameBufferType get() + { + if(_available.size() > 0) + _inUse.splice(_inUse.begin(), _available, _available.begin()); + else + _inUse.push_front(BufferPtr()); + + return FrameBufferType(*_inUse.begin(), *this); + } + + bool release(BufferPtr &p) + { + auto f = std::find(_inUse.begin(), _inUse.end(), p); + + if(f == _inUse.end()) + return false; + + if(_available.size() < _minimumBufferCount) + _available.splice(_available.begin(), _inUse, f); + else + _inUse.erase(f); + + return true; + } + + void clear() + { + _inUse.clear(); + _available.clear(); + } + + virtual ~FrameBufferManager() { clear(); } +}; + +/** + * @} + */ + +} + +#endif // FRAMEBUFFER_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/FrameGenerator.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/FrameGenerator.h new file mode 100755 index 0000000..6a21ef2 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/FrameGenerator.h @@ -0,0 +1,178 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_FRAME_GENERATOR_H +#define VOXEL_FRAME_GENERATOR_H + +#include +#include + +#include + +namespace Voxel +{ + +class FrameStreamWriter; + +class VOXEL_EXPORT FrameGenerator +{ +protected: + GeneratorIDType _id; + int _frameType; // Generated frame type. Value as in Voxel::DepthCamera::FrameType + Ptr _frameStreamWriter; + + StringKeySerializableMap _frameGeneratorParameters; // Primarily for the purpose of serializing/deserializing these parameters + + uint8_t _majorVersion, _minorVersion; // Used for storing/reading configuration + + virtual bool _onReadConfiguration() = 0; // On read configuration + virtual bool _onWriteConfiguration() = 0; // On write configuration + + inline bool _getParam(const String &name, SerializablePtr ¶m) const; + + template + inline bool _set(const String &name, const T &value); // Only for internal use + +public: + FrameGenerator(GeneratorIDType id, int frameType, uint8_t majorVersion, uint8_t minorVersion): _id(id), _frameType(frameType), + _majorVersion(majorVersion), _minorVersion(minorVersion) + { + _frameGeneratorParameters["version"] = + SerializablePtr(new SerializableUnsignedInt((majorVersion << 8) + minorVersion)); + } + + inline const GeneratorIDType &id() const { return _id; } + + inline void setFrameStreamWriter(Ptr &writer) { _frameStreamWriter = writer; } + inline void removeFrameStreamWriter() { _frameStreamWriter = nullptr; } + + virtual bool readConfiguration(SerializedObject &object); // Read configuration from serialized data object + virtual bool writeConfiguration(); // Write configuration to FrameStreamWriter + virtual bool writeConfiguration(SerializedObject &object) // Write configuration to serialized data object + { + object.resize(_frameGeneratorParameters.serializedSize()); + if(!_frameGeneratorParameters.write(object)) + { + return false; + } + + if(!_onWriteConfiguration()){ + return false; + } + + return true; + } + + + virtual bool generate(const FramePtr &in, FramePtr &out) = 0; + + template + inline bool get(const String &name, T &value) const; + + virtual ~FrameGenerator() {} +}; + +typedef Ptr FrameGeneratorPtr; +inline bool FrameGenerator::_getParam(const String &name, SerializablePtr ¶m) const +{ + auto x = _frameGeneratorParameters.find(name); + + if(x != _frameGeneratorParameters.end()) + { + param = x->second; + return true; + } + + return false; +} + +template +inline bool FrameGenerator::_set(const String &name, const T &value) +{ + SerializablePtr param; + + if(!_getParam(name, param)) + return false; + + BasicSerializable *p = dynamic_cast *>(param.get()); + + if(p) + { + p->value = value; + return true; + } + return false; +} + +template <> +inline bool FrameGenerator::_set(const String &name, const String &value) +{ + SerializablePtr param; + + if(!_getParam(name, param)) + return false; + + SerializableString *p = dynamic_cast(param.get()); + + if(p) + { + *p = value; + return true; + } + return false; +} + +template +inline bool FrameGenerator::get(const String &name, T &value) const +{ + SerializablePtr param; + + if(!_getParam(name, param)) + return false; + + const BasicSerializable *p = dynamic_cast *>(param.get()); + + if(p) + { + value = p->value; + return true; + } + return false; +} + +template <> +inline bool FrameGenerator::get(const String &name, String &value) const +{ + SerializablePtr param; + + if(!_getParam(name, param)) + return false; + + SerializableString *p = dynamic_cast(param.get()); + + if(p) + { + value = *p; + return true; + } + return false; +} + + +class VOXEL_EXPORT DepthFrameGenerator: public FrameGenerator +{ +public: + DepthFrameGenerator(GeneratorIDType id, int frameType, uint8_t majorVersion, uint8_t minorVersion): FrameGenerator(id, frameType, majorVersion, minorVersion) {} + virtual bool setProcessedFrameGenerator(FrameGeneratorPtr &p) = 0; + + virtual ~DepthFrameGenerator() {} +}; + +typedef Ptr DepthFrameGeneratorPtr; + +} + +#endif diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/FrameStream.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/FrameStream.h new file mode 100755 index 0000000..0d1bf66 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/FrameStream.h @@ -0,0 +1,187 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_FRAME_STREAM_H +#define VOXEL_FRAME_STREAM_H + +#include +#include +#include +#include "DataPacket.h" + +namespace Voxel +{ + + class CameraSystem; + + struct VOXEL_EXPORT FrameStreamHeader + { + char version[2]; // 0 -> major, 1 -> minor + GeneratorIDType generatorIDs[3]; // For raw (processed), depth and point cloud, in that order + }; + + struct VOXEL_EXPORT FrameStreamPacket: public DataPacket + { + enum PacketType + { + PACKET_DATA = 0, + PACKET_GENERATOR_CONFIG = 1 + }; + + FrameStreamPacket(): DataPacket() {} + }; + + struct VOXEL_EXPORT GeneratorConfigurationSubPacket + { + uint8_t frameType; + uint32_t size; + SerializedObject config; + + bool read(SerializedObject &object); + bool write(SerializedObject &object); + }; + + class VOXEL_EXPORT FrameStreamWriter + { + OutputFileStream &_stream; + OutputFileStream _internalStream; + + Mutex _mutex; + + bool _isPaused = false; + + size_t _frameCount; + FrameStreamHeader _header; + FrameStreamPacket _rawpacket, _configPacket; + GeneratorConfigurationSubPacket _generatorConfigSubPacket; + + bool _writeHeader(); + + bool _init(GeneratorIDType processedRawFrameGeneratorID, GeneratorIDType depthFrameGeneratorID, GeneratorIDType pointCloudFrameGeneratorID); + + public: + FrameStreamWriter(const String &filename, GeneratorIDType processedRawFrameGeneratorID, GeneratorIDType depthFrameGeneratorID, GeneratorIDType pointCloudFrameGeneratorID); + FrameStreamWriter(OutputFileStream &stream, GeneratorIDType processedRawFrameGeneratorID, GeneratorIDType depthFrameGeneratorID, GeneratorIDType pointCloudFrameGeneratorID); + + inline bool isStreamGood() { return _stream.good(); } + + bool pause(); + bool resume(); + inline bool isPaused() { return _isPaused; } + + bool write(FramePtr rawUnprocessed); + + inline SerializedObject &getConfigObject() { return _generatorConfigSubPacket.config; } + bool writeGeneratorConfiguration(uint frameType); + // Assumes the config sub-packet has been populated by using getConfigObject() + + bool close(); + + virtual ~FrameStreamWriter() { close(); } + + + }; + + typedef Ptr FrameStreamWriterPtr; + + class VOXEL_EXPORT FrameStreamReader + { + InputFileStream &_stream; + InputFileStream _internalStream; + + Vector _allPacketOffsets; + + Vector _dataPacketLocation, _configPacketLocation; + + FrameStreamHeader _header; + + size_t _currentPacketIndex; // index on _allPacketOffsets + size_t _currentFrameIndex; // index on _dataPacketLocation + + CameraSystem &_sys; + + Ptr _frameGenerator[3]; // for processed raw, depth and point cloud + + FrameStreamPacket _dataPacket, _configPacket; + GeneratorConfigurationSubPacket _configSubPacket; + + bool _init(); + + bool _getPacket(size_t packetIndex, FrameStreamPacket &packet); + bool _readConfigPacket(size_t packetIndex); + + public: + + FrameStreamReader(const String &fileName, CameraSystem &sys); + FrameStreamReader(InputFileStream &stream, CameraSystem &sys); + + inline bool isStreamGood() { return _stream.good(); } + + Vector frames; // 4 entries - raw (2 types), depth and point cloud corresponding to currently read frame index + + bool readNext(); + bool seekTo(size_t position); + + inline size_t currentPosition() { return _currentFrameIndex; } + inline size_t size() { return _dataPacketLocation.size(); } + + template + bool getStreamParam(const String &name, T &value) const; + + bool close(); + + virtual ~FrameStreamReader() {} + }; + + typedef Ptr FrameStreamReaderPtr; + + template + bool FrameStreamReader::getStreamParam(const String &name, T &value) const + { + if(!_frameGenerator[0]->get(name, value) && !_frameGenerator[1]->get(name, value) && !_frameGenerator[2]->get(name, value)) + return false; + + return true; + } + + + class VOXEL_EXPORT SocketStreamReader + { + CameraSystem &_sys; + Ptr _frameGenerator[3]; // for processed raw, depth and point cloud + FrameStreamPacket _dataPacket; + bool _init(); + uint _id1; + uint _id2; + uint _id3; + SerializedObject object; + Voxel::String _config1; + Voxel::String _config2; + Voxel::String _config3; + public: + SocketStreamReader(CameraSystem &sys,uint id1,uint id2,uint id3,char *config1,int len1,char *config2,int len2,char *config3,int len3); + + bool readNext(char *ptr,int tsize); + + template + bool getStreamParam(const String &name, T &value) const; + Vector frames; + virtual ~SocketStreamReader() {} + }; + + typedef Ptr SocketStreamReaderPtr; + + template + bool SocketStreamReader::getStreamParam(const String &name, T &value) const + { + if(!_frameGenerator[0]->get(name, value) && !_frameGenerator[1]->get(name, value) && !_frameGenerator[2]->get(name, value)) + return false; + + return true; + } +} + +#endif diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/HardwareSerializer.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/HardwareSerializer.h new file mode 100755 index 0000000..83d8e1f --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/HardwareSerializer.h @@ -0,0 +1,70 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2016 Texas Instruments Inc. + */ + +#include "Common.h" +#include "USBIO.h" +#include "SerializedObject.h" + +/** + * \ingroup Util + */ + +namespace Voxel +{ + +class VOXEL_EXPORT HardwareSerializer +{ + uint8_t _ioRequestCode, _sizeRequestCode; + USBIOPtr _usbIO; +public: + HardwareSerializer() {} + + /** + * + * @param usbIO -- Pointer to USBIO class object which supports control transfers + * @param ioRequestCode -- request code to read/write serialized data from/to hardware + * @param sizeRequestCode -- request code to read size of serialized data in hardware + * + */ + HardwareSerializer(USBIOPtr &usbIO, uint8_t ioRequestCode, uint8_t sizeRequestCode): + _usbIO(usbIO), _ioRequestCode(ioRequestCode), _sizeRequestCode(sizeRequestCode) {} + + /** + * @param version is the version info of format of 'so' + * @param knownTimestamp is the last known timestamp of data written. This is used to see whether an exist local copy of the + * serialized data is same as that in hardware or not. If same, then nothing is read from hardware improving run-time performance. + * @param so is the object to hold serialized data to read from hardware + */ + bool read(Version &version, TimeStampType &knownTimestamp, SerializedObject &so); + + /** + * @param version is the version info of format of 'so' + * @param timestamp is the timestamp of data to be written. This is used by read() to see whether an exist local copy of the + * serialized data is same as that in hardware or not. + * @param so is the object holding serialized data to write to hardware + */ + bool write(Version &version, TimeStampType ×tamp, SerializedObject &so); + + /** + * Save to local file 'filename' + */ + bool writeToFile(const String &filename, Version &version, TimeStampType ×tamp, SerializedObject &so); + + inline void setUSBIO(USBIOPtr &usbIO) { _usbIO = usbIO; } + + inline operator bool () { return _usbIO.get() != nullptr; } + + /** + * Serialized size in hardware is assumed to be 4 bytes long in big endian format + */ + bool getSize(uint32_t &size); + + virtual ~HardwareSerializer() {} +}; + +typedef Ptr HardwareSerializerPtr; + +} \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Logger.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Logger.h new file mode 100755 index 0000000..d276630 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Logger.h @@ -0,0 +1,208 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_LOGGER_H +#define VOXEL_LOGGER_H + +#include +#include +#include + +#include "Common.h" + +namespace Voxel +{ + +/** + * \addtogroup Util + * @{ + */ + +enum LogLevel +{ + LOG_CRITICAL, + LOG_ERROR, + LOG_WARNING, + LOG_INFO, + LOG_DEBUG +}; + +typedef OutputStream &(*OStreamManipulator)(OutputStream &); + +class VOXEL_EXPORT LoggerOutStream +{ +public: + typedef Function LoggerOutStreamFunctionType; +protected: + LoggerOutStreamFunctionType _outputFunction; + + OutputStringStream _s; + +public: + LoggerOutStream() {} + + void setOutputFunction(LoggerOutStreamFunctionType o) { _outputFunction = o; } + + template + LoggerOutStream &operator <<(const T &value) + { + if(!_outputFunction) + return *this; + + _s << value; + + if(_s.tellp() > 0) // Something written? + { + _outputFunction(_s.str()); + _s.clear(); + _s.str(""); + } + return *this; + } + + inline LoggerOutStream &operator <<(OStreamManipulator manip) + { + (*manip)(_s); + return *this; + } +}; + +class VOXEL_EXPORT Logger +{ +protected: + OutputStream &_out = std::cerr; + + mutable Mutex _mutex; + + LogLevel _logLevel, // Allow log statements equal to or below _logLevel + _currentLogLevel; // This holds log level for current statements + + static const String _logLevelNames[5]; + + Map _outputStreams; + IndexType _outputStreamCount = 0; + +public: + Logger(LogLevel loglevel = LOG_ERROR): _logLevel(loglevel), _currentLogLevel(loglevel) + {} + + Logger &operator =(const Logger &other) { _logLevel = other._logLevel; _currentLogLevel = other._currentLogLevel; return *this; } + + inline Logger &operator()(LogLevel loglevel) + { + _currentLogLevel = loglevel; + return *this << _logLevelNames[loglevel] << ": "; + } + + inline LogLevel getDefaultLogLevel() + { + return _logLevel; + } + + inline LogLevel getCurrentLogLevel() + { + return _currentLogLevel; + } + + inline void setDefaultLogLevel(LogLevel loglevel) + { + _logLevel = loglevel; + } + + inline OutputStream &getStream() + { + return _out; + } + + inline IndexType addOutputStream(LoggerOutStream::LoggerOutStreamFunctionType f) + { + IndexType i = _outputStreamCount; + _outputStreams[i].setOutputFunction(f); + _outputStreamCount++; + return i; + } + + inline bool removeOutputStream(IndexType index) + { + auto x = _outputStreams.find(index); + + if(x != _outputStreams.end()) + { + _outputStreams.erase(x); + return true; + } + return false; + } + + template + Logger &operator <<(const T &value) + { + if(_currentLogLevel <= _logLevel) + { + _out << value; + + for(auto &x: _outputStreams) + x.second << value; + } + return *this; + } + + typedef Logger &(*LoggerManipulator)(Logger &); + + inline Logger &operator <<(LoggerManipulator manip) + { + if(_currentLogLevel <= _logLevel) + return (*manip)(*this); + else + return *this; + } + + inline Logger &operator <<(OStreamManipulator manip) + { + if(_currentLogLevel <= _logLevel) + { + (*manip)(_out); + + for(auto &x: _outputStreams) + x.second << manip; + } + return *this; + } + + virtual ~Logger() + { + } +}; + +extern Logger VOXEL_EXPORT logger; + +//VOXEL_EXPORT Logger & endl(Logger &l); + +class VOXEL_EXPORT LogLevelChanger +{ + LogLevel _currentLogLevel; + LogLevel _desiredLogLevel; +public: + LogLevelChanger(LogLevel desired): _desiredLogLevel(desired) + { + _currentLogLevel = logger.getDefaultLogLevel(); + logger.setDefaultLogLevel(_desiredLogLevel); + } + + ~LogLevelChanger() + { + logger.setDefaultLogLevel(_currentLogLevel); + } +}; + +/** + * @} + */ + + +} + +#endif // VOXEL_LOGGER_H \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Parameter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Parameter.h new file mode 100755 index 0000000..95e228f --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Parameter.h @@ -0,0 +1,455 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_PARAMETER_H +#define VOXEL_PARAMETER_H + +#include + +#include "Common.h" + +#include "RegisterProgrammer.h" +#include "Logger.h" + +#include + +namespace Voxel +{ + +/** + * \defgroup Param Parameter related classes + * @{ + */ + + +class ParameterDMLParser; + +class VOXEL_EXPORT Parameter +{ +public: + enum IOType + { + IO_READ_ONLY = 0, + IO_READ_WRITE, + IO_WRITE_ONLY + }; + +protected: + uint32_t _address, _mask; + uint8_t _msb, _lsb, _registerLength; + // This is to do @_address <- (@_address & _mask) | (_value << _lsb) + + IOType _ioType; + + String _name; + String _displayName; + String _description; + + Vector _dependencies; // Parameter values on which this parameter depends on + + RegisterProgrammer &_programmer; + + void _computeMask(); + +public: + Parameter(RegisterProgrammer &programmer, const String &name, uint32_t address, uint8_t registerLength, uint8_t msb, uint8_t lsb, + const String &displayName, const String &description, IOType ioType = IO_READ_WRITE, const Vector &dependencies = {}) + : _programmer(programmer), _name(name), _displayName(displayName), _description(description), + _address(address), _msb(msb), _registerLength(registerLength), _lsb(lsb), _ioType(ioType), _dependencies(dependencies) + { + _computeMask(); + } + + inline const String &name() const { return _name; } + inline const String &displayName() const { return _displayName; } + inline const String &description() const { return _description; } + inline uint32_t address() const { return _address; } + inline uint8_t msb() const { return _msb; } + inline uint32_t mask() const { return _mask; } + inline uint8_t lsb() const { return _lsb; } + + inline IOType ioType() const { return _ioType; } + + inline void setName(const String &n) { _name = n; } + inline void setAddress(uint32_t a) { _address = a; } + + virtual bool refresh() = 0; + + virtual ~Parameter() {} + + friend class ParameterDMLParser; +}; + +typedef Ptr ParameterPtr; + +// NOTE: _value is initialized to defaultValue and not read from H/W. It needs to be manually done from outside via set() or get(true) +template +class VOXEL_EXPORT ParameterTemplate: public Parameter +{ +protected: + T _value; + + virtual uint32_t _toRawValue(T value) const + { + return (uint32_t)value; + } + + virtual T _fromRawValue(uint32_t value) const + { + return (T)(value); + } + +public: + ParameterTemplate(RegisterProgrammer &programmer, const String &name, uint32_t address, uint8_t registerLength, uint8_t msb, uint8_t lsb, + const T &defaultValue, + const String &displayName, const String &description, Parameter::IOType ioType = Parameter::IO_READ_WRITE, const Vector &dependencies = {}): + Parameter(programmer, name, address, registerLength, msb, lsb, displayName, description, ioType, dependencies), _value(defaultValue) + { + } + + static Ptr> typeCast(const ParameterPtr &other) + { + return std::dynamic_pointer_cast>(other); + } + + virtual bool set(const T &value) + { + if(_ioType == IO_READ_ONLY || !validate(value)) + { + return false; + } + + if(_programmer.setValue(*this, _toRawValue(value), _ioType == IO_WRITE_ONLY)) + { + _value = value; + return true; + } + else + return false; + } + + virtual bool validate(const T &value) const = 0; + + virtual bool refresh() + { + T v; + return get(v, true); + } + + virtual bool get(T &value, bool refresh = false) + { + if(!refresh || _ioType == IO_WRITE_ONLY) + { + value = _value; + return true; + } + + uint32_t v; + T val; + if(_address == 0 && _registerLength == 0) // dummy register? + { + value = _value; + return true; + } + else if(!_programmer.getValue(*this, v)) + { + value = _value; + return false; + } + else + { + val = _fromRawValue(v); + if(validate(val)) + { + value = val; + _value = val; + return true; + } + else + { + value = _value; + return false; + } + } + } + + virtual ~ParameterTemplate() {} +}; + +typedef ParameterTemplate BoolParameterTemplate; +typedef ParameterTemplate IntegerParameterTemplate; +typedef ParameterTemplate UnsignedIntegerParameterTemplate; +typedef ParameterTemplate FloatParameterTemplate; + +#ifdef SWIG +%template(BoolParameterTemplate) ParameterTemplate; +%template(IntegerParameterTemplate) ParameterTemplate; +%template(UnsignedIntegerParameterTemplate) ParameterTemplate; +%template(FloatParameterTemplate) ParameterTemplate; +#endif + +template +class VOXEL_EXPORT EnumParameterTemplate: public ParameterTemplate +{ +protected: + Vector _valueMeaning; + Vector _valueDescription; + +public: + EnumParameterTemplate(RegisterProgrammer &programmer, const String &name, uint32_t address, uint8_t registerLength, uint8_t msb, uint8_t lsb, + const Vector &valueDescription, const Vector &valueMeaning, const T &defaultValue, + const String &displayName, const String &description, Parameter::IOType ioType = Parameter::IO_READ_WRITE, const Vector &dependencies = {}): + ParameterTemplate(programmer, name, address, registerLength, msb, lsb, defaultValue, displayName, description, ioType, dependencies), _valueDescription(valueDescription), _valueMeaning(valueMeaning) + { + } + + static Ptr> typeCast(const ParameterPtr &other) + { + return std::dynamic_pointer_cast>(other); + } + + inline const Vector &valueDescription() const { return _valueDescription; } + inline const Vector &valueMeaning() const { return _valueMeaning; } + + virtual ~EnumParameterTemplate() {} +}; + +typedef EnumParameterTemplate BoolEnumParameterTemplate; +typedef EnumParameterTemplate IntegerEnumParameterTemplate; + + +#ifdef SWIG +%template(BoolEnumParameterTemplate) EnumParameterTemplate; +%template(IntegerEnumParameterTemplate) EnumParameterTemplate; +#endif + +class VOXEL_EXPORT BoolParameter : public EnumParameterTemplate +{ + virtual bool _fromRawValue(uint32_t value) const + { + return (value?true:false); + } + + virtual uint32_t _toRawValue(bool value) const + { + return (uint32_t)value?1:0; + } +public: + BoolParameter(RegisterProgrammer &programmer, const String &name, uint32_t address, uint8_t registerLength, uint8_t lsb, + const Vector &valueDescription, const Vector &valueMeaning, const bool &defaultValue, + const String &displayName, const String &description, Parameter::IOType ioType = Parameter::IO_READ_WRITE, const Vector &dependencies = {}): + EnumParameterTemplate(programmer, name, address, registerLength, lsb, lsb, valueDescription, valueMeaning, defaultValue, displayName, description, ioType, dependencies) + { + } + + static Ptr typeCast(const ParameterPtr &other) + { + return std::dynamic_pointer_cast(other); + } + + virtual bool validate(const bool &value) const + { + return true; + } + + virtual ~BoolParameter() {} +}; + +class VOXEL_EXPORT StrobeBoolParameter : public BoolParameter +{ +public: + StrobeBoolParameter(RegisterProgrammer &programmer, const String &name, uint32_t address, uint8_t registerLength, uint8_t lsb, + const Vector &valueDescription, const Vector &valueMeaning, const bool &defaultValue, + const String &displayName, const String &description, Parameter::IOType ioType = Parameter::IO_READ_WRITE, const Vector &dependencies = {}): + BoolParameter(programmer, name, address, registerLength, lsb, valueDescription, valueMeaning, defaultValue, displayName, description, ioType, dependencies) + { + } + + static Ptr typeCast(const ParameterPtr &other) + { + return std::dynamic_pointer_cast(other); + } + + virtual bool get(bool &value, bool refresh = true) + { + return BoolParameter::get(value, true); // ignore the refresh set by user and force it to true + } + + virtual ~StrobeBoolParameter() {} +}; + +class VOXEL_EXPORT EnumParameter : public EnumParameterTemplate +{ +protected: + Vector _allowedValues; + +public: + EnumParameter(RegisterProgrammer &programmer, const String &name, uint32_t address, uint8_t registerLength, uint8_t msb, uint8_t lsb, + const Vector &allowedValues, const Vector valueDescription, const Vector &valueMeaning, const int &defaultValue, + const String &displayName, const String &description, Parameter::IOType ioType = Parameter::IO_READ_WRITE, const Vector &dependencies = {}): + EnumParameterTemplate(programmer, name, address, registerLength, msb, lsb, valueDescription, valueMeaning, defaultValue, displayName, description, ioType, dependencies), + _allowedValues(allowedValues) + { + } + + static Ptr typeCast(const ParameterPtr &other) + { + return std::dynamic_pointer_cast(other); + } + + inline const Vector &allowedValues() const { return _allowedValues; } + + virtual bool validate(const int &value) const + { + bool allowed = false; + for(auto a : _allowedValues) + if(value == a) + { + allowed = true; + break; + } + + return allowed; + } + + virtual ~EnumParameter() {} +}; + + + +template +class VOXEL_EXPORT RangeParameterTemplate : public ParameterTemplate +{ +protected: + T _lowerLimit, _upperLimit; + + String _unit; + +public: + RangeParameterTemplate(RegisterProgrammer &programmer, const String &name, const String &unit, uint32_t address, uint8_t registerLength, uint8_t msb, uint8_t lsb, + const T &lowerLimit, const T &upperLimit, const T &defaultValue, + const String &displayName, const String &description, Parameter::IOType ioType = Parameter::IO_READ_WRITE, const Vector &dependencies = {}): + ParameterTemplate(programmer, name, address, registerLength, msb, lsb, defaultValue, displayName, description, ioType, dependencies), + _lowerLimit(lowerLimit), _upperLimit(upperLimit), _unit(unit) + { + } + + static Ptr> typeCast(const ParameterPtr &other) + { + return std::dynamic_pointer_cast>(other); + } + + const String &unit() const { return _unit; } + + virtual const T lowerLimit() const { return _lowerLimit; } + virtual const T upperLimit() const { return _upperLimit; } + + virtual void setLowerLimit(T lowerLimit) { _lowerLimit = lowerLimit; } + virtual void setUpperLimit(T upperLimit) { _upperLimit = upperLimit; } + + virtual bool validate(const T &value) const + { + return !(value < _lowerLimit || value > _upperLimit); + } + + virtual ~RangeParameterTemplate() {} +}; + +typedef RangeParameterTemplate IntegerRangeParameterTemplate; +typedef RangeParameterTemplate FloatRangeParameterTemplate; + + +#ifdef SWIG +%template(IntegerRangeParameterTemplate) RangeParameterTemplate; +%template(UnsignedIntegerParameter) RangeParameterTemplate; +%template(FloatRangeParameterTemplate) RangeParameterTemplate; +#endif + +class VOXEL_EXPORT IntegerParameter : public RangeParameterTemplate +{ +protected: + virtual uint32_t _toRawValue(int value) const + { + if(value < 0) // negative? + { + return ((uint32_t)value & ((1 << (_msb - _lsb + 1)) - 1)); // remove sign extension + } + else + return (uint32_t)value; + } + + virtual int _fromRawValue(uint32_t value) const + { + if(value & (1 << (_msb - _lsb))) // negative? + return (value | ((uint32_t)(-1) - ((1 << (_msb - _lsb + 1)) - 1))); // extend sign + else + return (int)value; + } + +public: + IntegerParameter(RegisterProgrammer &programmer, const String &name, const String &unit, uint32_t address, uint8_t registerLength, uint8_t msb, uint8_t lsb, + int lowerLimit, int upperLimit, const int &defaultValue, + const String &displayName, const String &description, Parameter::IOType ioType = Parameter::IO_READ_WRITE, const Vector &dependencies = {}): + RangeParameterTemplate(programmer, name, unit, address, registerLength, msb, lsb, lowerLimit, upperLimit, defaultValue, displayName, description, ioType, dependencies) + { + } + + static Ptr typeCast(const ParameterPtr &other) + { + return std::dynamic_pointer_cast(other); + } + + virtual ~IntegerParameter() {} +}; + +typedef RangeParameterTemplate UnsignedIntegerParameter; + +class VOXEL_EXPORT FloatParameter : public RangeParameterTemplate +{ +protected: + virtual float _fromRawValue(uint32_t value) const + { + float v; + v = (float)value/(1 << (msb() - lsb() + 1)); // normalized value + + if(v > 1.0f) v = 1.0f; + if(v < 0.0f) v = 0.0f; + return v; + } + + virtual uint32_t _toRawValue(float value) const + { + uint32_t maxValue = (1 << (msb() - lsb() + 1)); + uint32_t v = (uint32_t)value*maxValue; // normalized value + + if(v > maxValue) v = maxValue; + if(v < 0) v = 0; + return v; + } + + +public: + FloatParameter(RegisterProgrammer &programmer, const String &name, const String &unit, uint32_t address, uint8_t registerLength, uint8_t msb, uint8_t lsb, + float lowerLimit, float upperLimit, const float &defaultValue, + const String &displayName, const String &description, Parameter::IOType ioType = Parameter::IO_READ_WRITE, const Vector &dependencies = {}): + RangeParameterTemplate(programmer, name, unit, address, registerLength, msb, lsb, lowerLimit, upperLimit, defaultValue, displayName, description, ioType, dependencies) + { + } + + static Ptr typeCast(const ParameterPtr &other) + { + return std::dynamic_pointer_cast(other); + } + + virtual ~FloatParameter() {} +}; + +/** + * @} + */ +} + +#endif // PARAMETER_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ParameterDMLParser.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ParameterDMLParser.h new file mode 100755 index 0000000..acd5625 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ParameterDMLParser.h @@ -0,0 +1,59 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_PARAMETERDMLPARSER_H +#define VOXEL_PARAMETERDMLPARSER_H + +#include "TinyXML2.h" +#include "Common.h" +#include "Parameter.h" + +namespace Voxel +{ +/** + * \addtogroup Param + * @{ + */ + + +class VOXEL_EXPORT ParameterDMLParser +{ +protected: + TinyXML2::XMLDocument _doc; + + TinyXML2::XMLElement *_regMap, *_propertyList, *_sectionList; + + uint8_t _wordLength; + + String _xmlFileName; + + RegisterProgrammer &_registerProgrammer; + + bool _initialized = false; + + bool _prepare(); + + TinyXML2::XMLElement *_goTo(TinyXML2::XMLElement *current, const Vector &nodeNameList, bool report = true); // by default report error + + ParameterPtr _getParameter(TinyXML2::XMLElement *property, String &id, bool &skipIfNull); // Get parameter and ID + +public: + ParameterDMLParser(RegisterProgrammer ®isterProgrammer, const String &xmlFileName); + + inline bool isInitialized() { return _initialized; } + + bool getParameters(Vector ¶meters); + + virtual ~ParameterDMLParser() {} +}; + +/** + * @} + */ + +} + +#endif // PARAMETERDMLPARSER_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Point.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Point.h new file mode 100755 index 0000000..9129c3b --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Point.h @@ -0,0 +1,135 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_POINT_H +#define VOXEL_POINT_H + +#define _USE_MATH_DEFINES +#include + +#include + +#include "Common.h" + +namespace Voxel +{ +/** + * \addtogroup Frm + * @{ + */ + + +class Point +{ +public: + float x, y, z; // in meters + + Point(): x(0), y(0), z(0) {} + Point(float x, float y): x(x), y(y), z(0) {} + Point(float x, float y, float z): x(x), y(y), z(z) {} + + inline float angle(const Point &other) const; + inline float norm() const; + + inline float dot(const Point &other) const; + inline Point cross(const Point &other) const; + + inline Point &operator -(); + inline Point operator +(const Point &other) const; + inline Point operator *(const Point &other) const; + inline Point operator *(const float &other) const; +}; + +float Point::dot(const Point &other) const +{ + return (x*other.x + y*other.y + z*other.z); +} + +Point Point::cross(const Point &other) const +{ + Point p; + p.x = y*other.z - z*other.y; + p.y = z*other.x - x*other.z; + p.z = x*other.y - y*other.x; + + return p; +} + + +float Point::angle(const Point &other) const +{ + float n1 = norm(), n2 = other.norm(); + + if(floatEquals(n1, 0) || floatEquals(n2, 0)) + return 0; + + return acos(dot(other)/n1/n2); +} + +float Point::norm() const +{ + return sqrt(x*x + y*y + z*z); +} + +inline Point &Point::operator -() +{ + x = -x; + y = -y; + z = -z; + return *this; +} + +Point Point::operator*(const Point &other) const +{ + return Point(x*other.x, y*other.y, z*other.z); +} + +Point Point::operator*(const float &other) const +{ + return Point(x*other, y*other, z*other); +} + +Point Point::operator +(const Point &other) const +{ + return Point(x + other.x, y + other.y, z + other.z); +} + + + +class VOXEL_EXPORT IntensityPoint: public Point +{ +public: + float i; // normalized 0-1 + + static IntensityPoint *typeCast(Point *ptr) + { + return (IntensityPoint *)(ptr); + } +}; + +class RGBPoint: public Point +{ +public: + float r, g, b; // normalized 0-1 + + static RGBPoint *typeCast(Point *ptr) + { + return (RGBPoint *)(ptr); + } +}; + +class Orientation // in radial co-ordinates +{ +public: + float theta, phi; // in radians +}; +/** + * @} + */ + +} + +#endif // VOXEL_POINT_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/PointCloudFrameGenerator.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/PointCloudFrameGenerator.h new file mode 100755 index 0000000..d635a13 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/PointCloudFrameGenerator.h @@ -0,0 +1,38 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_POINT_CLOUD_FRAME_GENERATOR_H +#define VOXEL_POINT_CLOUD_FRAME_GENERATOR_H + +#include +#include + +namespace Voxel +{ + +class VOXEL_EXPORT PointCloudFrameGenerator: public FrameGenerator +{ +protected: + PointCloudTransformPtr _pointCloudTransform; + + virtual bool _onReadConfiguration(); + virtual bool _onWriteConfiguration(); +public: + PointCloudFrameGenerator(); + + bool setParameters(uint32_t left, uint32_t top, uint32_t width, uint32_t height, + uint32_t rowsToMerge, uint32_t columnsToMerge, + float fx, float fy, float cx, float cy, float k1, float k2, float k3, float p1, float p2); + + bool generate(const FramePtr &in, FramePtr &out); + + virtual ~PointCloudFrameGenerator() {} +}; + + +} + +#endif \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/PointCloudTransform.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/PointCloudTransform.h new file mode 100755 index 0000000..1efdc73 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/PointCloudTransform.h @@ -0,0 +1,98 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_POINTCLOUD_TRANSFORM_H +#define VOXEL_POINTCLOUD_TRANSFORM_H + +#include "Point.h" +#include "Common.h" +#include "Frame.h" + +#include "VoxelExports.h" + +#include + +#define POINT_INVALID FLT_MAX + +namespace Voxel +{ +/** + * \addtogroup Frm + * @{ + */ + +class VOXEL_EXPORT PointCloudTransform +{ +public: + uint32_t left, top; // Image top-left corner + uint32_t width, height; // sensor width and height + uint32_t rowsToMerge, columnsToMerge; // Binning + float fx, fy; // x- and y- focal distance + float cx, cy; // image center + float k1, k2, k3; // radial distortion parameters + float p1, p2; // tangential distortion parameters + + Vector directions; // Directional array + + // Clippings + Point leftClippingNormal; + Point rightClippingNormal; + Point topClippingNormal; + Point bottomClippingNormal; + + // Estimation errors + float fxError, fyError; + float cxError, cyError; + float k1Error, k2Error, k3Error; + float p1Error, p2Error; + float pixelErrorX, pixelErrorY; + + // Checkerboard information + int nCornersPerImages; + int nImages; + + Point &getDirection(int row, int col); + +public: + PointCloudTransform(uint32_t left, uint32_t top, uint32_t width, uint32_t height, + uint32_t rowsToMerge, uint32_t columnsToMerge, + float fx, float fy, float cx, float cy, + float k1, float k2, float k3, float p1, float p2); + + void calcAperatureAngleRadians(int &horizontalAperatureAngle, float &verticalAperatureAngle); + void rescaleParameters(int width, int height); + Point worldToImage(const Point &p); + Point imageToWorld(const Point &p, float depth); + + bool depthToPointCloud(const Vector &distances, PointCloudFrame &pointCloudFrame); + +private: + Point _screenToNormalizedScreen(const Point &screen, bool verify); + Point _normalizedScreenToScreen(const Point &normalizedScreen); + Point _lensCorrection(const Point &normalizedScreen); + bool _computeConcaveMirrorBorders(int width, int height, double &minx, double &maxX, + double &minY, double &maxY); + bool _computeConcaveMirrorBordersOuter(int width, int height, double &minX, double &maxX, + double &minY, double &maxY); + void _computeConcaveMirror(int width, int height, + Vector &leftArr, Vector &rightArr, + Vector &topArr, Vector &bottomArr); + + void _init(); + + Point _normalizedScreenToUnitWorld(const Point &normalizedScreen); + void _computeClippingPlanes(); +}; + +typedef Ptr PointCloudTransformPtr; + +/** + * @} + */ + +} + +#endif // VOXEL_POINTCLOUD_TRANSFORM_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Ptr.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Ptr.h new file mode 100755 index 0000000..d76e7b9 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Ptr.h @@ -0,0 +1,65 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_PTR_H +#define VOXEL_PTR_H + +#include + +namespace Voxel +{ + +/** + * \addtogroup Util + * @{ + */ + + +template +void deleter(T *data) +{ + delete data; +} + + +/** + * NOTE: This is a simple way to ensure that matching new/delete are used. + * WARNING: + * 1. DO NOT CREATE the pointer "data" in some other library (so/dll) context and pass it to Ptr<> created in another library (so/dll). + * Always. create Ptr<> and allocate "data" in the same so/dll. + * 2. DO NOT USE THIS CLASS FOR array data, that is, allocated with new[] + */ +template +class Ptr: public std::shared_ptr +{ +public: + Ptr(T *data): std::shared_ptr(data, deleter) {} + + template + Ptr(T *data, _Deleter d): std::shared_ptr(data, d) {} + + Ptr(): std::shared_ptr() {} + + Ptr(const std::shared_ptr &p): std::shared_ptr(p) {} + +#ifdef SWIG + T *operator ->() { return this->std::shared_ptr::operator->(); } + + const T *operator ->() const { return this->std::shared_ptr::operator->(); } +#endif + + virtual ~Ptr() {} +}; + +/** + * @} + */ + + +} + + +#endif // VOXEL_PTR_H \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/RegisterProgrammer.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/RegisterProgrammer.h new file mode 100755 index 0000000..e4b8e2e --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/RegisterProgrammer.h @@ -0,0 +1,48 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + + +#ifndef VOXEL_REGISTER_PROGRAMMER_H +#define VOXEL_REGISTER_PROGRAMMER_H + +#include "Common.h" +#include + +namespace Voxel +{ +/** + * \addtogroup IO + * @{ + */ + + +class VOXEL_EXPORT Parameter; + +class VOXEL_EXPORT RegisterProgrammer +{ +public: + virtual bool isInitialized() const = 0; + + // NOTE: Make these thread-safe when implementing + virtual bool setValue(const Parameter ¶m, uint32_t value, bool writeOnly = false) = 0; + virtual bool getValue(const Parameter ¶m, uint32_t &value) const = 0; + + virtual bool readRegister(uint32_t address, uint32_t &value) const = 0; + virtual bool writeRegister(uint32_t address, uint32_t value) = 0; + + virtual bool reset() = 0; + + virtual ~RegisterProgrammer() {} +}; + +/** + * @} + */ + + +} + +#endif \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Serializable.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Serializable.h new file mode 100755 index 0000000..ec7d2b3 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Serializable.h @@ -0,0 +1,202 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_SERIALIZABLE_H +#define VOXEL_SERIALIZABLE_H + +#include "Common.h" +#include "SerializedObject.h" + +#include "Logger.h" + +namespace Voxel +{ + +class Serializable +{ +public: + virtual size_t serializedSize() const = 0; + virtual bool read(SerializedObject &object) = 0; + virtual bool write(SerializedObject &object) const = 0; + + virtual ~Serializable() {} +}; + +typedef Ptr SerializablePtr; + +template +class BasicSerializable: public Serializable +{ +public: + T value; + + BasicSerializable() {} + BasicSerializable(const T &v) { value = v; } + + size_t serializedSize() const { return sizeof(T); } + + bool read(SerializedObject &object) + { + return object.get((char *)&value, sizeof(T)) == sizeof(T); + } + + bool write(SerializedObject &object) const + { + return object.put((const char *)&value, sizeof(T)) == sizeof(T); + } + + virtual ~BasicSerializable() {} +}; + +typedef BasicSerializable SerializableUnsignedInt; +typedef BasicSerializable SerializableSignedInt; +typedef BasicSerializable SerializableFloat; +typedef Ptr SerializableUnsignedIntPtr; +typedef Ptr SerializableSignedIntPtr; +typedef Ptr SerializableFloatPtr; + +class SerializableString: public Serializable, public String +{ +public: + SerializableString() {} + SerializableString(const String &other): String(other) {} + + size_t serializedSize() const { return sizeof(uint32_t) + size(); } + + bool read(SerializedObject &object) + { + uint32_t size; + if(object.get((char *)&size, sizeof(uint32_t)) != sizeof(uint32_t)) + return false; + + resize(size); + + if(object.get((char *)data(), sizeof(char)*size) != sizeof(char)*size) + return false; + + return true; + } + + bool write(SerializedObject &object) const + { + uint32_t size = this->size(); + if(object.put((const char *)&size, sizeof(uint32_t)) != sizeof(uint32_t)) + return false; + + if(object.put((const char *)data(), sizeof(char)*size) != sizeof(char)*size) + return false; + + return true; + } + + virtual ~SerializableString() {} +}; + +typedef Ptr SerializableStringPtr; + +} + +namespace std { + template <> + struct hash { + std::size_t operator()(const Voxel::SerializableString &k) const + { + return hash()(k); + } + }; +} + +namespace Voxel { + +// NOTE: Key is expected to be derived from Serializable +template +class SerializableMap: public Map, Serializable +{ +public: + SerializableMap(Map &other): Map(other) {} + SerializableMap(SerializableMap &other): Map(other) {} + SerializableMap() {} + + virtual size_t serializedSize() const + { + uint32_t size = sizeof(uint32_t); + + for(auto &x: *this) + { + size += x.first.serializedSize(); + size += x.second->serializedSize(); + } + + return size; + } + + virtual bool write(SerializedObject &object) const + { + uint32_t size = serializedSize() - sizeof(uint32_t); + + if(object.size() - object.currentPutOffset() < size) + return false; + + if(object.put((const char *)&size, sizeof(uint32_t)) != sizeof(uint32_t)) + return false; + + + for(auto &x: *this) + { + if(!x.first.write(object) || !x.second->write(object)) + return false; + } + return true; + } + + virtual bool read(SerializedObject &object) + { + uint32_t size; + if(object.get((char *)&size, sizeof(uint32_t)) != sizeof(uint32_t)) + return false; + + uint32_t g = object.currentGetOffset(); + + Key k; + + while(object.currentGetOffset() - g < size) + { + if(!k.read(object)) + return false; + + auto x = this->find(k); + + if(x == this->end()) + { + logger(LOG_WARNING) << "SerializableMap: Found unknown key '" << k << "'" << std::endl; + continue; + } + + if(!x->second->read(object)) + return false; + } + + return object.currentGetOffset() == (g + size); + } + + virtual ~SerializableMap() {} +}; + +class StringKeySerializableMap: public SerializableMap +{ +public: + SerializablePtr &operator [](const String &key) + { + return SerializableMap::operator[](SerializableString(key)); + } + + virtual ~StringKeySerializableMap() {} +}; + +typedef Ptr StringKeySerializableMapPtr; + +} +#endif diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/SerializedObject.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/SerializedObject.h new file mode 100755 index 0000000..60daa1b --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/SerializedObject.h @@ -0,0 +1,86 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_SERIALIZED_OBJECT_H +#define VOXEL_SERIALIZED_OBJECT_H + +#include "Common.h" + +#include + +#include + +namespace Voxel +{ + +class VOXEL_EXPORT SerializedObject +{ +protected: + Vector _bytes; + uint _getOffset, _putOffset; + +public: + SerializedObject(size_t size): _bytes(size), _getOffset(0), _putOffset(0) {} + SerializedObject(): _getOffset(0), _putOffset(0) {} + + uint currentGetOffset() const { return _getOffset; } + uint currentPutOffset() const { return _putOffset; } + + const Vector &getBytes() const { return _bytes; } + Vector &getBytes() { return _bytes; } + + inline void resize(size_t size) + { + if(size > 0) + _bytes.resize(size); + else + _bytes.clear(); + rewind(); + } + + inline size_t size() const { return _bytes.size(); } + + inline void rewind() { _getOffset = 0; _putOffset = 0; } + + inline size_t get(char *bytes, size_t size); + inline size_t put(const char *bytes, size_t size); + + virtual ~SerializedObject() {} +}; + +size_t SerializedObject::get(char *bytes, size_t size) +{ + size = std::min(size, _bytes.size() - _getOffset); + + if(size == 0) + return 0; + + memcpy(bytes, _bytes.data() + _getOffset, size); + + _getOffset += size; + + return size; +} + +size_t SerializedObject::put(const char *bytes, size_t size) +{ + size = std::min(size, _bytes.size() - _putOffset); + + if(size == 0) + return 0; + + memcpy(_bytes.data() + _putOffset, bytes, size); + + _putOffset += size; + + return size; +} + + +} + + +#endif diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Streamer.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Streamer.h new file mode 100755 index 0000000..a939bb7 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Streamer.h @@ -0,0 +1,62 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_STREAMER_H +#define VOXEL_STREAMER_H + +#include "Device.h" +#include "Frame.h" +#include "VideoMode.h" +#include "Timer.h" + +namespace Voxel +{ +/** + * \addtogroup IO + * @{ + */ + + +class VOXEL_EXPORT Streamer +{ +protected: + DevicePtr _device; + + Timer _time; + + int _currentID = -1; + TimeStampType _currentTimeStamp = 0; + + bool _isRunning = false; + + virtual bool _start() = 0; + virtual bool _capture(RawDataFramePtr &p) = 0; + virtual bool _stop() = 0; + +public: + Streamer(DevicePtr device): _device(device) {} + + virtual ~Streamer(); + + virtual bool isInitialized() = 0; + virtual bool isRunning() { return _isRunning; } + + virtual bool start(); + virtual bool capture(RawDataFramePtr &p); + virtual bool stop(); + + virtual bool getSupportedVideoModes(Vector &videoModes) = 0; + + virtual bool getCurrentVideoMode(VideoMode &videoMode) = 0; + virtual bool setVideoMode(const VideoMode &videoMode) = 0; +}; +/** + * @} + */ + +} + +#endif // STREAMER_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Timer.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Timer.h new file mode 100755 index 0000000..13a3d8e --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/Timer.h @@ -0,0 +1,49 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TIME_H +#define VOXEL_TIME_H + +#include "Common.h" + +namespace Voxel +{ + +/** + * \addtogroup Util + * @{ + */ + + +class VOXEL_EXPORT Timer +{ + TimeStampType _realTimeStart = 0, _monoticStart = 0; + + bool _initialized = false; + +public: + Timer() + { + init(); + } + + inline bool isInitialized() { return _initialized; } + + bool init(); + + // Assumption: MONOTIC clock's epoch began recently while REALTIME's epoch began a long time ago (~44 years ago) + TimeStampType convertToRealTime(TimeStampType l); + + TimeStampType getCurrentRealTime(); +}; + +/** + * @} + */ + +} + +#endif // VOXEL_TIME_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/TinyXML2.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/TinyXML2.h new file mode 100755 index 0000000..d2a72f1 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/TinyXML2.h @@ -0,0 +1,2120 @@ +/* + +This is exactly same as the original, except that the namespace has been renamed to "TinyXML2" from "tinyxml2". +Also, the .h and .cpp files have been renamed to TinyXML2.* from tinyxml2.*. This would avoid any conflicts +with system installed version of tinyxml2 (In Ubuntu 14.04 LTS, there are packages libtinyxml2* available). + +Copyright (c) 2014 Texas Instruments Inc. + +----------------------------------------- + +Original code by Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#ifndef TINYXML2_INCLUDED +#define TINYXML2_INCLUDED + +#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) +# include +# include +# include +# include +# include +# include +#else +# include +# include +# include +# include +# include +# include +#endif + +#include "VoxelExports.h" + +/* + TODO: intern strings instead of allocation. +*/ +/* + gcc: + g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe + + Formatting, Artistic Style: + AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h +*/ + +#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) +# ifndef DEBUG +# define DEBUG +# endif +#endif + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4251) +#endif + +#ifdef _WIN32 +# ifdef TINYXML2_EXPORT +# define TINYXML2_LIB __declspec(dllexport) +# elif defined(TINYXML2_IMPORT) +# define TINYXML2_LIB __declspec(dllimport) +# else +# define TINYXML2_LIB +# endif +#else +# define TINYXML2_LIB +#endif + + +#if defined(DEBUG) +# if defined(_MSC_VER) +# define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak() +# elif defined (ANDROID_NDK) +# include +# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } +# else +# include +# define TIXMLASSERT assert +# endif +# else +# define TIXMLASSERT( x ) {} +#endif + + +#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE) +// Microsoft visual studio, version 2005 and higher. +/*int _snprintf_s( + char *buffer, + size_t sizeOfBuffer, + size_t count, + const char *format [, + argument] ... +);*/ +inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) +{ + va_list va; + va_start( va, format ); + int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); + va_end( va ); + return result; +} +#define TIXML_SSCANF sscanf_s +#elif defined WINCE +#define TIXML_SNPRINTF _snprintf +#define TIXML_SSCANF sscanf +#else +// GCC version 3 and higher +//#warning( "Using sn* functions." ) +#define TIXML_SNPRINTF snprintf +#define TIXML_SSCANF sscanf +#endif + +/* Versioning, past 1.0.14: + http://semver.org/ +*/ +static const int TIXML2_MAJOR_VERSION = 2; +static const int TIXML2_MINOR_VERSION = 2; +static const int TIXML2_PATCH_VERSION = 0; + +namespace TinyXML2 +{ + +/** + * \addtogroup Util + * @{ + */ + +class XMLDocument; +class XMLElement; +class XMLAttribute; +class XMLComment; +class XMLText; +class XMLDeclaration; +class XMLUnknown; +class XMLPrinter; + +/* + A class that wraps strings. Normally stores the start and end + pointers into the XML file itself, and will apply normalization + and entity translation if actually read. Can also store (and memory + manage) a traditional char[] +*/ +class StrPair +{ +public: + enum { + NEEDS_ENTITY_PROCESSING = 0x01, + NEEDS_NEWLINE_NORMALIZATION = 0x02, + COLLAPSE_WHITESPACE = 0x04, + + TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, + TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, + ATTRIBUTE_NAME = 0, + ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, + ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, + COMMENT = NEEDS_NEWLINE_NORMALIZATION + }; + + StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} + ~StrPair(); + + void Set( char* start, char* end, int flags ) { + Reset(); + _start = start; + _end = end; + _flags = flags | NEEDS_FLUSH; + } + + const char* GetStr(); + + bool Empty() const { + return _start == _end; + } + + void SetInternedStr( const char* str ) { + Reset(); + _start = const_cast(str); + } + + void SetStr( const char* str, int flags=0 ); + + char* ParseText( char* in, const char* endTag, int strFlags ); + char* ParseName( char* in ); + + void TransferTo( StrPair* other ); + +private: + void Reset(); + void CollapseWhitespace(); + + enum { + NEEDS_FLUSH = 0x100, + NEEDS_DELETE = 0x200 + }; + + // After parsing, if *_end != 0, it can be set to zero. + int _flags; + char* _start; + char* _end; + + StrPair( const StrPair& other ); // not supported + void operator=( StrPair& other ); // not supported, use TransferTo() +}; + + +/* + A dynamic array of Plain Old Data. Doesn't support constructors, etc. + Has a small initial memory pool, so that low or no usage will not + cause a call to new/delete +*/ +template +class DynArray +{ +public: + DynArray< T, INIT >() { + _mem = _pool; + _allocated = INIT; + _size = 0; + } + + ~DynArray() { + if ( _mem != _pool ) { + delete [] _mem; + } + } + + void Clear() { + _size = 0; + } + + void Push( T t ) { + EnsureCapacity( _size+1 ); + _mem[_size++] = t; + } + + T* PushArr( int count ) { + EnsureCapacity( _size+count ); + T* ret = &_mem[_size]; + _size += count; + return ret; + } + + T Pop() { + return _mem[--_size]; + } + + void PopArr( int count ) { + TIXMLASSERT( _size >= count ); + _size -= count; + } + + bool Empty() const { + return _size == 0; + } + + T& operator[](int i) { + TIXMLASSERT( i>= 0 && i < _size ); + return _mem[i]; + } + + const T& operator[](int i) const { + TIXMLASSERT( i>= 0 && i < _size ); + return _mem[i]; + } + + const T& PeekTop() const { + TIXMLASSERT( _size > 0 ); + return _mem[ _size - 1]; + } + + int Size() const { + return _size; + } + + int Capacity() const { + return _allocated; + } + + const T* Mem() const { + return _mem; + } + + T* Mem() { + return _mem; + } + +private: + void EnsureCapacity( int cap ) { + if ( cap > _allocated ) { + int newAllocated = cap * 2; + T* newMem = new T[newAllocated]; + memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs + if ( _mem != _pool ) { + delete [] _mem; + } + _mem = newMem; + _allocated = newAllocated; + } + } + + T* _mem; + T _pool[INIT]; + int _allocated; // objects allocated + int _size; // number objects in use +}; + + +/* + Parent virtual class of a pool for fast allocation + and deallocation of objects. +*/ +class MemPool +{ +public: + MemPool() {} + virtual ~MemPool() {} + + virtual int ItemSize() const = 0; + virtual void* Alloc() = 0; + virtual void Free( void* ) = 0; + virtual void SetTracked() = 0; + virtual void Clear() = 0; +}; + + +/* + Template child class to create pools of the correct type. +*/ +template< int SIZE > +class MemPoolT : public MemPool +{ +public: + MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} + ~MemPoolT() { + Clear(); + } + + void Clear() { + // Delete the blocks. + while( !_blockPtrs.Empty()) { + Block* b = _blockPtrs.Pop(); + delete b; + } + _root = 0; + _currentAllocs = 0; + _nAllocs = 0; + _maxAllocs = 0; + _nUntracked = 0; + } + + virtual int ItemSize() const { + return SIZE; + } + int CurrentAllocs() const { + return _currentAllocs; + } + + virtual void* Alloc() { + if ( !_root ) { + // Need a new block. + Block* block = new Block(); + _blockPtrs.Push( block ); + + for( int i=0; ichunk[i].next = &block->chunk[i+1]; + } + block->chunk[COUNT-1].next = 0; + _root = block->chunk; + } + void* result = _root; + _root = _root->next; + + ++_currentAllocs; + if ( _currentAllocs > _maxAllocs ) { + _maxAllocs = _currentAllocs; + } + _nAllocs++; + _nUntracked++; + return result; + } + + virtual void Free( void* mem ) { + if ( !mem ) { + return; + } + --_currentAllocs; + Chunk* chunk = static_cast( mem ); +#ifdef DEBUG + memset( chunk, 0xfe, sizeof(Chunk) ); +#endif + chunk->next = _root; + _root = chunk; + } + void Trace( const char* name ) { + printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", + name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() ); + } + + void SetTracked() { + _nUntracked--; + } + + int Untracked() const { + return _nUntracked; + } + + // This number is perf sensitive. 4k seems like a good tradeoff on my machine. + // The test file is large, 170k. + // Release: VS2010 gcc(no opt) + // 1k: 4000 + // 2k: 4000 + // 4k: 3900 21000 + // 16k: 5200 + // 32k: 4300 + // 64k: 4000 21000 + enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private + +private: + union Chunk { + Chunk* next; + char mem[SIZE]; + }; + struct Block { + Chunk chunk[COUNT]; + }; + DynArray< Block*, 10 > _blockPtrs; + Chunk* _root; + + int _currentAllocs; + int _nAllocs; + int _maxAllocs; + int _nUntracked; +}; + + + +/** + Implements the interface to the "Visitor pattern" (see the Accept() method.) + If you call the Accept() method, it requires being passed a XMLVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs + are simply called with Visit(). + + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, no children of this node or its siblings will be visited. + + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. + + Generally Accept() is called on the XMLDocument, although all nodes support visiting. + + You should never change the document from a callback. + + @sa XMLNode::Accept() +*/ +class VOXEL_EXPORT XMLVisitor +{ +public: + virtual ~XMLVisitor() {} + + /// Visit a document. + virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { + return true; + } + /// Visit a document. + virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + return true; + } + + /// Visit an element. + virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { + return true; + } + /// Visit an element. + virtual bool VisitExit( const XMLElement& /*element*/ ) { + return true; + } + + /// Visit a declaration. + virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { + return true; + } + /// Visit a text node. + virtual bool Visit( const XMLText& /*text*/ ) { + return true; + } + /// Visit a comment node. + virtual bool Visit( const XMLComment& /*comment*/ ) { + return true; + } + /// Visit an unknown node. + virtual bool Visit( const XMLUnknown& /*unknown*/ ) { + return true; + } +}; + +// WARNING: must match XMLDocument::_errorNames[] +enum XMLError { + XML_SUCCESS = 0, + XML_NO_ERROR = 0, + XML_NO_ATTRIBUTE, + XML_WRONG_ATTRIBUTE_TYPE, + XML_ERROR_FILE_NOT_FOUND, + XML_ERROR_FILE_COULD_NOT_BE_OPENED, + XML_ERROR_FILE_READ_ERROR, + XML_ERROR_ELEMENT_MISMATCH, + XML_ERROR_PARSING_ELEMENT, + XML_ERROR_PARSING_ATTRIBUTE, + XML_ERROR_IDENTIFYING_TAG, + XML_ERROR_PARSING_TEXT, + XML_ERROR_PARSING_CDATA, + XML_ERROR_PARSING_COMMENT, + XML_ERROR_PARSING_DECLARATION, + XML_ERROR_PARSING_UNKNOWN, + XML_ERROR_EMPTY_DOCUMENT, + XML_ERROR_MISMATCHED_ELEMENT, + XML_ERROR_PARSING, + XML_CAN_NOT_CONVERT_TEXT, + XML_NO_TEXT_NODE, + + XML_ERROR_COUNT +}; + + +/* + Utility functionality. +*/ +class XMLUtil +{ +public: + static const char* SkipWhiteSpace( const char* p ) { + while( IsWhiteSpace(*p) ) { + ++p; + } + return p; + } + static char* SkipWhiteSpace( char* p ) { + return const_cast( SkipWhiteSpace( const_cast(p) ) ); + } + + // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't + // correct, but simple, and usually works. + static bool IsWhiteSpace( char p ) { + return !IsUTF8Continuation(p) && isspace( static_cast(p) ); + } + + inline static bool IsNameStartChar( unsigned char ch ) { + return ( ( ch < 128 ) ? isalpha( ch ) : 1 ) + || ch == ':' + || ch == '_'; + } + + inline static bool IsNameChar( unsigned char ch ) { + return IsNameStartChar( ch ) + || isdigit( ch ) + || ch == '.' + || ch == '-'; + } + + inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { + int n = 0; + if ( p == q ) { + return true; + } + while( *p && *q && *p == *q && n(const_cast(this)->FirstChildElement( value )); + } + + /// Get the last child node, or null if none exists. + const XMLNode* LastChild() const { + return _lastChild; + } + + XMLNode* LastChild() { + return const_cast(const_cast(this)->LastChild() ); + } + + /** Get the last child element or optionally the last child + element with the specified name. + */ + const XMLElement* LastChildElement( const char* value=0 ) const; + + XMLElement* LastChildElement( const char* value=0 ) { + return const_cast(const_cast(this)->LastChildElement(value) ); + } + + /// Get the previous (left) sibling node of this node. + const XMLNode* PreviousSibling() const { + return _prev; + } + + XMLNode* PreviousSibling() { + return _prev; + } + + /// Get the previous (left) sibling element of this node, with an optionally supplied name. + const XMLElement* PreviousSiblingElement( const char* value=0 ) const ; + + XMLElement* PreviousSiblingElement( const char* value=0 ) { + return const_cast(const_cast(this)->PreviousSiblingElement( value ) ); + } + + /// Get the next (right) sibling node of this node. + const XMLNode* NextSibling() const { + return _next; + } + + XMLNode* NextSibling() { + return _next; + } + + /// Get the next (right) sibling element of this node, with an optionally supplied name. + const XMLElement* NextSiblingElement( const char* value=0 ) const; + + XMLElement* NextSiblingElement( const char* value=0 ) { + return const_cast(const_cast(this)->NextSiblingElement( value ) ); + } + + /** + Add a child node as the last (right) child. + If the child node is already part of the document, + it is moved from its old location to the new location. + Returns the addThis argument or 0 if the node does not + belong to the same document. + */ + XMLNode* InsertEndChild( XMLNode* addThis ); + + XMLNode* LinkEndChild( XMLNode* addThis ) { + return InsertEndChild( addThis ); + } + /** + Add a child node as the first (left) child. + If the child node is already part of the document, + it is moved from its old location to the new location. + Returns the addThis argument or 0 if the node does not + belong to the same document. + */ + XMLNode* InsertFirstChild( XMLNode* addThis ); + /** + Add a node after the specified child node. + If the child node is already part of the document, + it is moved from its old location to the new location. + Returns the addThis argument or 0 if the afterThis node + is not a child of this node, or if the node does not + belong to the same document. + */ + XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ); + + /** + Delete all the children of this node. + */ + void DeleteChildren(); + + /** + Delete a child of this node. + */ + void DeleteChild( XMLNode* node ); + + /** + Make a copy of this node, but not its children. + You may pass in a Document pointer that will be + the owner of the new Node. If the 'document' is + null, then the node returned will be allocated + from the current Document. (this->GetDocument()) + + Note: if called on a XMLDocument, this will return null. + */ + virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0; + + /** + Test if 2 nodes are the same, but don't test children. + The 2 nodes do not need to be in the same Document. + + Note: if called on a XMLDocument, this will return false. + */ + virtual bool ShallowEqual( const XMLNode* compare ) const = 0; + + /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the + XML tree will be conditionally visited and the host will be called back + via the XMLVisitor interface. + + This is essentially a SAX interface for TinyXML-2. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML-2 is unchanged by using this + interface versus any other.) + + The interface has been based on ideas from: + + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + + Which are both good references for "visiting". + + An example of using Accept(): + @verbatim + XMLPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ + virtual bool Accept( XMLVisitor* visitor ) const = 0; + + // internal + virtual char* ParseDeep( char*, StrPair* ); + +protected: + XMLNode( XMLDocument* ); + virtual ~XMLNode(); + XMLNode( const XMLNode& ); // not supported + XMLNode& operator=( const XMLNode& ); // not supported + + XMLDocument* _document; + XMLNode* _parent; + mutable StrPair _value; + + XMLNode* _firstChild; + XMLNode* _lastChild; + + XMLNode* _prev; + XMLNode* _next; + +private: + MemPool* _memPool; + void Unlink( XMLNode* child ); + static void DeleteNode( XMLNode* node ); +}; + + +/** XML text. + + Note that a text node can have child element nodes, for example: + @verbatim + This is bold + @endverbatim + + A text node can have 2 ways to output the next. "normal" output + and CDATA. It will default to the mode it was parsed from the XML file and + you generally want to leave it alone, but you can change the output mode with + SetCData() and query it with CData(). +*/ +class VOXEL_EXPORT XMLText : public XMLNode +{ + friend class XMLBase; + friend class XMLDocument; +public: + virtual bool Accept( XMLVisitor* visitor ) const; + + virtual XMLText* ToText() { + return this; + } + virtual const XMLText* ToText() const { + return this; + } + + /// Declare whether this should be CDATA or standard text. + void SetCData( bool isCData ) { + _isCData = isCData; + } + /// Returns true if this is a CDATA text element. + bool CData() const { + return _isCData; + } + + char* ParseDeep( char*, StrPair* endTag ); + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {} + virtual ~XMLText() {} + XMLText( const XMLText& ); // not supported + XMLText& operator=( const XMLText& ); // not supported + +private: + bool _isCData; +}; + + +/** An XML Comment. */ +class VOXEL_EXPORT XMLComment : public XMLNode +{ + friend class XMLDocument; +public: + virtual XMLComment* ToComment() { + return this; + } + virtual const XMLComment* ToComment() const { + return this; + } + + virtual bool Accept( XMLVisitor* visitor ) const; + + char* ParseDeep( char*, StrPair* endTag ); + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLComment( XMLDocument* doc ); + virtual ~XMLComment(); + XMLComment( const XMLComment& ); // not supported + XMLComment& operator=( const XMLComment& ); // not supported + +private: +}; + + +/** In correct XML the declaration is the first entry in the file. + @verbatim + + @endverbatim + + TinyXML-2 will happily read or write files without a declaration, + however. + + The text of the declaration isn't interpreted. It is parsed + and written as a string. +*/ +class VOXEL_EXPORT XMLDeclaration : public XMLNode +{ + friend class XMLDocument; +public: + virtual XMLDeclaration* ToDeclaration() { + return this; + } + virtual const XMLDeclaration* ToDeclaration() const { + return this; + } + + virtual bool Accept( XMLVisitor* visitor ) const; + + char* ParseDeep( char*, StrPair* endTag ); + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLDeclaration( XMLDocument* doc ); + virtual ~XMLDeclaration(); + XMLDeclaration( const XMLDeclaration& ); // not supported + XMLDeclaration& operator=( const XMLDeclaration& ); // not supported +}; + + +/** Any tag that TinyXML-2 doesn't recognize is saved as an + unknown. It is a tag of text, but should not be modified. + It will be written back to the XML, unchanged, when the file + is saved. + + DTD tags get thrown into XMLUnknowns. +*/ +class VOXEL_EXPORT XMLUnknown : public XMLNode +{ + friend class XMLDocument; +public: + virtual XMLUnknown* ToUnknown() { + return this; + } + virtual const XMLUnknown* ToUnknown() const { + return this; + } + + virtual bool Accept( XMLVisitor* visitor ) const; + + char* ParseDeep( char*, StrPair* endTag ); + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLUnknown( XMLDocument* doc ); + virtual ~XMLUnknown(); + XMLUnknown( const XMLUnknown& ); // not supported + XMLUnknown& operator=( const XMLUnknown& ); // not supported +}; + + + +/** An attribute is a name-value pair. Elements have an arbitrary + number of attributes, each with a unique name. + + @note The attributes are not XMLNodes. You may only query the + Next() attribute in a list. +*/ +class VOXEL_EXPORT XMLAttribute +{ + friend class XMLElement; +public: + /// The name of the attribute. + const char* Name() const; + + /// The value of the attribute. + const char* Value() const; + + /// The next attribute in the list. + const XMLAttribute* Next() const { + return _next; + } + + /** IntValue interprets the attribute as an integer, and returns the value. + If the value isn't an integer, 0 will be returned. There is no error checking; + use QueryIntValue() if you need error checking. + */ + int IntValue() const { + int i=0; + QueryIntValue( &i ); + return i; + } + /// Query as an unsigned integer. See IntValue() + unsigned UnsignedValue() const { + unsigned i=0; + QueryUnsignedValue( &i ); + return i; + } + /// Query as a boolean. See IntValue() + bool BoolValue() const { + bool b=false; + QueryBoolValue( &b ); + return b; + } + /// Query as a double. See IntValue() + double DoubleValue() const { + double d=0; + QueryDoubleValue( &d ); + return d; + } + /// Query as a float. See IntValue() + float FloatValue() const { + float f=0; + QueryFloatValue( &f ); + return f; + } + + /** QueryIntValue interprets the attribute as an integer, and returns the value + in the provided parameter. The function will return XML_NO_ERROR on success, + and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. + */ + XMLError QueryIntValue( int* value ) const; + /// See QueryIntValue + XMLError QueryUnsignedValue( unsigned int* value ) const; + /// See QueryIntValue + XMLError QueryBoolValue( bool* value ) const; + /// See QueryIntValue + XMLError QueryDoubleValue( double* value ) const; + /// See QueryIntValue + XMLError QueryFloatValue( float* value ) const; + + /// Set the attribute to a string value. + void SetAttribute( const char* value ); + /// Set the attribute to value. + void SetAttribute( int value ); + /// Set the attribute to value. + void SetAttribute( unsigned value ); + /// Set the attribute to value. + void SetAttribute( bool value ); + /// Set the attribute to value. + void SetAttribute( double value ); + /// Set the attribute to value. + void SetAttribute( float value ); + +private: + enum { BUF_SIZE = 200 }; + + XMLAttribute() : _next( 0 ), _memPool( 0 ) {} + virtual ~XMLAttribute() {} + + XMLAttribute( const XMLAttribute& ); // not supported + void operator=( const XMLAttribute& ); // not supported + void SetName( const char* name ); + + char* ParseDeep( char* p, bool processEntities ); + + mutable StrPair _name; + mutable StrPair _value; + XMLAttribute* _next; + MemPool* _memPool; +}; + + +/** The element is a container class. It has a value, the element name, + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. +*/ +class VOXEL_EXPORT XMLElement : public XMLNode +{ + friend class XMLBase; + friend class XMLDocument; +public: + /// Get the name of an element (which is the Value() of the node.) + const char* Name() const { + return Value(); + } + /// Set the name of the element. + void SetName( const char* str, bool staticMem=false ) { + SetValue( str, staticMem ); + } + + virtual XMLElement* ToElement() { + return this; + } + virtual const XMLElement* ToElement() const { + return this; + } + virtual bool Accept( XMLVisitor* visitor ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none + exists. For example: + + @verbatim + const char* value = ele->Attribute( "foo" ); + @endverbatim + + The 'value' parameter is normally null. However, if specified, + the attribute will only be returned if the 'name' and 'value' + match. This allow you to write code: + + @verbatim + if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar(); + @endverbatim + + rather than: + @verbatim + if ( ele->Attribute( "foo" ) ) { + if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar(); + } + @endverbatim + */ + const char* Attribute( const char* name, const char* value=0 ) const; + + /** Given an attribute name, IntAttribute() returns the value + of the attribute interpreted as an integer. 0 will be + returned if there is an error. For a method with error + checking, see QueryIntAttribute() + */ + int IntAttribute( const char* name ) const { + int i=0; + QueryIntAttribute( name, &i ); + return i; + } + /// See IntAttribute() + unsigned UnsignedAttribute( const char* name ) const { + unsigned i=0; + QueryUnsignedAttribute( name, &i ); + return i; + } + /// See IntAttribute() + bool BoolAttribute( const char* name ) const { + bool b=false; + QueryBoolAttribute( name, &b ); + return b; + } + /// See IntAttribute() + double DoubleAttribute( const char* name ) const { + double d=0; + QueryDoubleAttribute( name, &d ); + return d; + } + /// See IntAttribute() + float FloatAttribute( const char* name ) const { + float f=0; + QueryFloatAttribute( name, &f ); + return f; + } + + /** Given an attribute name, QueryIntAttribute() returns + XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion + can't be performed, or XML_NO_ATTRIBUTE if the attribute + doesn't exist. If successful, the result of the conversion + will be written to 'value'. If not successful, nothing will + be written to 'value'. This allows you to provide default + value: + + @verbatim + int value = 10; + QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 + @endverbatim + */ + XMLError QueryIntAttribute( const char* name, int* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryIntValue( value ); + } + /// See QueryIntAttribute() + XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryUnsignedValue( value ); + } + /// See QueryIntAttribute() + XMLError QueryBoolAttribute( const char* name, bool* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryBoolValue( value ); + } + /// See QueryIntAttribute() + XMLError QueryDoubleAttribute( const char* name, double* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryDoubleValue( value ); + } + /// See QueryIntAttribute() + XMLError QueryFloatAttribute( const char* name, float* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryFloatValue( value ); + } + + + /** Given an attribute name, QueryAttribute() returns + XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion + can't be performed, or XML_NO_ATTRIBUTE if the attribute + doesn't exist. It is overloaded for the primitive types, + and is a generally more convenient replacement of + QueryIntAttribute() and related functions. + + If successful, the result of the conversion + will be written to 'value'. If not successful, nothing will + be written to 'value'. This allows you to provide default + value: + + @verbatim + int value = 10; + QueryAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 + @endverbatim + */ + int QueryAttribute( const char* name, int* value ) const { + return QueryIntAttribute( name, value ); + } + + int QueryAttribute( const char* name, unsigned int* value ) const { + return QueryUnsignedAttribute( name, value ); + } + + int QueryAttribute( const char* name, bool* value ) const { + return QueryBoolAttribute( name, value ); + } + + int QueryAttribute( const char* name, double* value ) const { + return QueryDoubleAttribute( name, value ); + } + + int QueryAttribute( const char* name, float* value ) const { + return QueryFloatAttribute( name, value ); + } + + /// Sets the named attribute to value. + void SetAttribute( const char* name, const char* value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, int value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, unsigned value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, bool value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, double value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, float value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + + /** + Delete an attribute. + */ + void DeleteAttribute( const char* name ); + + /// Return the first attribute in the list. + const XMLAttribute* FirstAttribute() const { + return _rootAttribute; + } + /// Query a specific attribute in the list. + const XMLAttribute* FindAttribute( const char* name ) const; + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, GetText() is limited compared to getting the XMLText child + and accessing it directly. + + If the first child of 'this' is a XMLText, the GetText() + returns the character string of the Text node, else null is returned. + + This is a convenient method for getting the text of simple contained text: + @verbatim + This is text + const char* str = fooElement->GetText(); + @endverbatim + + 'str' will be a pointer to "This is text". + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + This is text + @endverbatim + + then the value of str would be null. The first child node isn't a text node, it is + another element. From this XML: + @verbatim + This is text + @endverbatim + GetText() will return "This is ". + */ + const char* GetText() const; + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, SetText() is limited compared to creating an XMLText child + and mutating it directly. + + If the first child of 'this' is a XMLText, SetText() sets its value to + the given string, otherwise it will create a first child that is an XMLText. + + This is a convenient method for setting the text of simple contained text: + @verbatim + This is text + fooElement->SetText( "Hullaballoo!" ); + Hullaballoo! + @endverbatim + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + This is text + @endverbatim + + then it will not change "This is text", but rather prefix it with a text element: + @verbatim + Hullaballoo!This is text + @endverbatim + + For this XML: + @verbatim + + @endverbatim + SetText() will generate + @verbatim + Hullaballoo! + @endverbatim + */ + void SetText( const char* inText ); + /// Convenience method for setting text inside and element. See SetText() for important limitations. + void SetText( int value ); + /// Convenience method for setting text inside and element. See SetText() for important limitations. + void SetText( unsigned value ); + /// Convenience method for setting text inside and element. See SetText() for important limitations. + void SetText( bool value ); + /// Convenience method for setting text inside and element. See SetText() for important limitations. + void SetText( double value ); + /// Convenience method for setting text inside and element. See SetText() for important limitations. + void SetText( float value ); + + /** + Convenience method to query the value of a child text node. This is probably best + shown by example. Given you have a document is this form: + @verbatim + + 1 + 1.4 + + @endverbatim + + The QueryIntText() and similar functions provide a safe and easier way to get to the + "value" of x and y. + + @verbatim + int x = 0; + float y = 0; // types of x and y are contrived for example + const XMLElement* xElement = pointElement->FirstChildElement( "x" ); + const XMLElement* yElement = pointElement->FirstChildElement( "y" ); + xElement->QueryIntText( &x ); + yElement->QueryFloatText( &y ); + @endverbatim + + @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted + to the requested type, and XML_NO_TEXT_NODE if there is no child text to query. + + */ + XMLError QueryIntText( int* ival ) const; + /// See QueryIntText() + XMLError QueryUnsignedText( unsigned* uval ) const; + /// See QueryIntText() + XMLError QueryBoolText( bool* bval ) const; + /// See QueryIntText() + XMLError QueryDoubleText( double* dval ) const; + /// See QueryIntText() + XMLError QueryFloatText( float* fval ) const; + + // internal: + enum { + OPEN, // + CLOSED, // + CLOSING // + }; + int ClosingType() const { + return _closingType; + } + char* ParseDeep( char* p, StrPair* endTag ); + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +private: + XMLElement( XMLDocument* doc ); + virtual ~XMLElement(); + XMLElement( const XMLElement& ); // not supported + void operator=( const XMLElement& ); // not supported + + XMLAttribute* FindAttribute( const char* name ) { + return const_cast(const_cast(this)->FindAttribute( name )); + } + XMLAttribute* FindOrCreateAttribute( const char* name ); + //void LinkAttribute( XMLAttribute* attrib ); + char* ParseAttributes( char* p ); + static void DeleteAttribute( XMLAttribute* attribute ); + + enum { BUF_SIZE = 200 }; + int _closingType; + // The attribute list is ordered; there is no 'lastAttribute' + // because the list needs to be scanned for dupes before adding + // a new attribute. + XMLAttribute* _rootAttribute; +}; + + +enum Whitespace { + PRESERVE_WHITESPACE, + COLLAPSE_WHITESPACE +}; + + +/** A Document binds together all the functionality. + It can be saved, loaded, and printed to the screen. + All Nodes are connected and allocated to a Document. + If the Document is deleted, all its Nodes are also deleted. +*/ +class VOXEL_EXPORT XMLDocument : public XMLNode +{ + friend class XMLElement; +public: + /// constructor + XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE ); + ~XMLDocument(); + + virtual XMLDocument* ToDocument() { + return this; + } + virtual const XMLDocument* ToDocument() const { + return this; + } + + /** + Parse an XML file from a character string. + Returns XML_NO_ERROR (0) on success, or + an errorID. + + You may optionally pass in the 'nBytes', which is + the number of bytes which will be parsed. If not + specified, TinyXML-2 will assume 'xml' points to a + null terminated string. + */ + XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) ); + + /** + Load an XML file from disk. + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError LoadFile( const char* filename ); + + /** + Load an XML file from disk. You are responsible + for providing and closing the FILE*. + + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError LoadFile( FILE* ); + + /** + Save the XML file to disk. + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError SaveFile( const char* filename, bool compact = false ); + + /** + Save the XML file to disk. You are responsible + for providing and closing the FILE*. + + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError SaveFile( FILE* fp, bool compact = false ); + + bool ProcessEntities() const { + return _processEntities; + } + Whitespace WhitespaceMode() const { + return _whitespace; + } + + /** + Returns true if this document has a leading Byte Order Mark of UTF8. + */ + bool HasBOM() const { + return _writeBOM; + } + /** Sets whether to write the BOM when writing the file. + */ + void SetBOM( bool useBOM ) { + _writeBOM = useBOM; + } + + /** Return the root element of DOM. Equivalent to FirstChildElement(). + To get the first node, use FirstChild(). + */ + XMLElement* RootElement() { + return FirstChildElement(); + } + const XMLElement* RootElement() const { + return FirstChildElement(); + } + + /** Print the Document. If the Printer is not provided, it will + print to stdout. If you provide Printer, this can print to a file: + @verbatim + XMLPrinter printer( fp ); + doc.Print( &printer ); + @endverbatim + + Or you can use a printer to print to memory: + @verbatim + XMLPrinter printer; + doc.Print( &printer ); + // printer.CStr() has a const char* to the XML + @endverbatim + */ + void Print( XMLPrinter* streamer=0 ) const; + virtual bool Accept( XMLVisitor* visitor ) const; + + /** + Create a new Element associated with + this Document. The memory for the Element + is managed by the Document. + */ + XMLElement* NewElement( const char* name ); + /** + Create a new Comment associated with + this Document. The memory for the Comment + is managed by the Document. + */ + XMLComment* NewComment( const char* comment ); + /** + Create a new Text associated with + this Document. The memory for the Text + is managed by the Document. + */ + XMLText* NewText( const char* text ); + /** + Create a new Declaration associated with + this Document. The memory for the object + is managed by the Document. + + If the 'text' param is null, the standard + declaration is used.: + @verbatim + + @endverbatim + */ + XMLDeclaration* NewDeclaration( const char* text=0 ); + /** + Create a new Unknown associated with + this Document. The memory for the object + is managed by the Document. + */ + XMLUnknown* NewUnknown( const char* text ); + + /** + Delete a node associated with this document. + It will be unlinked from the DOM. + */ + void DeleteNode( XMLNode* node ) { + TIXMLASSERT( node ); + TIXMLASSERT( node->_parent ); + node->_parent->DeleteChild( node ); + } + + void SetError( XMLError error, const char* str1, const char* str2 ); + + /// Return true if there was an error parsing the document. + bool Error() const { + return _errorID != XML_NO_ERROR; + } + /// Return the errorID. + XMLError ErrorID() const { + return _errorID; + } + const char* ErrorName() const; + + /// Return a possibly helpful diagnostic location or string. + const char* GetErrorStr1() const { + return _errorStr1; + } + /// Return a possibly helpful secondary diagnostic location or string. + const char* GetErrorStr2() const { + return _errorStr2; + } + /// If there is an error, print it to stdout. + void PrintError() const; + + /// Clear the document, resetting it to the initial state. + void Clear(); + + // internal + char* Identify( char* p, XMLNode** node ); + + virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { + return 0; + } + virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { + return false; + } + +private: + XMLDocument( const XMLDocument& ); // not supported + void operator=( const XMLDocument& ); // not supported + + bool _writeBOM; + bool _processEntities; + XMLError _errorID; + Whitespace _whitespace; + const char* _errorStr1; + const char* _errorStr2; + char* _charBuffer; + + MemPoolT< sizeof(XMLElement) > _elementPool; + MemPoolT< sizeof(XMLAttribute) > _attributePool; + MemPoolT< sizeof(XMLText) > _textPool; + MemPoolT< sizeof(XMLComment) > _commentPool; + + static const char* _errorNames[XML_ERROR_COUNT]; +}; + + +/** + A XMLHandle is a class that wraps a node pointer with null checks; this is + an incredibly useful thing. Note that XMLHandle is not part of the TinyXML-2 + DOM structure. It is a separate utility class. + + Take an example: + @verbatim + + + + + + + @endverbatim + + Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very + easy to write a *lot* of code that looks like: + + @verbatim + XMLElement* root = document.FirstChildElement( "Document" ); + if ( root ) + { + XMLElement* element = root->FirstChildElement( "Element" ); + if ( element ) + { + XMLElement* child = element->FirstChildElement( "Child" ); + if ( child ) + { + XMLElement* child2 = child->NextSiblingElement( "Child" ); + if ( child2 ) + { + // Finally do something useful. + @endverbatim + + And that doesn't even cover "else" cases. XMLHandle addresses the verbosity + of such code. A XMLHandle checks for null pointers so it is perfectly safe + and correct to use: + + @verbatim + XMLHandle docHandle( &document ); + XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement(); + if ( child2 ) + { + // do something useful + @endverbatim + + Which is MUCH more concise and useful. + + It is also safe to copy handles - internally they are nothing more than node pointers. + @verbatim + XMLHandle handleCopy = handle; + @endverbatim + + See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects. +*/ +class VOXEL_EXPORT XMLHandle +{ +public: + /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. + XMLHandle( XMLNode* node ) { + _node = node; + } + /// Create a handle from a node. + XMLHandle( XMLNode& node ) { + _node = &node; + } + /// Copy constructor + XMLHandle( const XMLHandle& ref ) { + _node = ref._node; + } + /// Assignment + XMLHandle& operator=( const XMLHandle& ref ) { + _node = ref._node; + return *this; + } + + /// Get the first child of this handle. + XMLHandle FirstChild() { + return XMLHandle( _node ? _node->FirstChild() : 0 ); + } + /// Get the first child element of this handle. + XMLHandle FirstChildElement( const char* value=0 ) { + return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 ); + } + /// Get the last child of this handle. + XMLHandle LastChild() { + return XMLHandle( _node ? _node->LastChild() : 0 ); + } + /// Get the last child element of this handle. + XMLHandle LastChildElement( const char* _value=0 ) { + return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 ); + } + /// Get the previous sibling of this handle. + XMLHandle PreviousSibling() { + return XMLHandle( _node ? _node->PreviousSibling() : 0 ); + } + /// Get the previous sibling element of this handle. + XMLHandle PreviousSiblingElement( const char* _value=0 ) { + return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 ); + } + /// Get the next sibling of this handle. + XMLHandle NextSibling() { + return XMLHandle( _node ? _node->NextSibling() : 0 ); + } + /// Get the next sibling element of this handle. + XMLHandle NextSiblingElement( const char* _value=0 ) { + return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 ); + } + + /// Safe cast to XMLNode. This can return null. + XMLNode* ToNode() { + return _node; + } + /// Safe cast to XMLElement. This can return null. + XMLElement* ToElement() { + return ( ( _node == 0 ) ? 0 : _node->ToElement() ); + } + /// Safe cast to XMLText. This can return null. + XMLText* ToText() { + return ( ( _node == 0 ) ? 0 : _node->ToText() ); + } + /// Safe cast to XMLUnknown. This can return null. + XMLUnknown* ToUnknown() { + return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); + } + /// Safe cast to XMLDeclaration. This can return null. + XMLDeclaration* ToDeclaration() { + return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); + } + +private: + XMLNode* _node; +}; + + +/** + A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the + same in all regards, except for the 'const' qualifiers. See XMLHandle for API. +*/ +class VOXEL_EXPORT XMLConstHandle +{ +public: + XMLConstHandle( const XMLNode* node ) { + _node = node; + } + XMLConstHandle( const XMLNode& node ) { + _node = &node; + } + XMLConstHandle( const XMLConstHandle& ref ) { + _node = ref._node; + } + + XMLConstHandle& operator=( const XMLConstHandle& ref ) { + _node = ref._node; + return *this; + } + + const XMLConstHandle FirstChild() const { + return XMLConstHandle( _node ? _node->FirstChild() : 0 ); + } + const XMLConstHandle FirstChildElement( const char* value=0 ) const { + return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 ); + } + const XMLConstHandle LastChild() const { + return XMLConstHandle( _node ? _node->LastChild() : 0 ); + } + const XMLConstHandle LastChildElement( const char* _value=0 ) const { + return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 ); + } + const XMLConstHandle PreviousSibling() const { + return XMLConstHandle( _node ? _node->PreviousSibling() : 0 ); + } + const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const { + return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 ); + } + const XMLConstHandle NextSibling() const { + return XMLConstHandle( _node ? _node->NextSibling() : 0 ); + } + const XMLConstHandle NextSiblingElement( const char* _value=0 ) const { + return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 ); + } + + + const XMLNode* ToNode() const { + return _node; + } + const XMLElement* ToElement() const { + return ( ( _node == 0 ) ? 0 : _node->ToElement() ); + } + const XMLText* ToText() const { + return ( ( _node == 0 ) ? 0 : _node->ToText() ); + } + const XMLUnknown* ToUnknown() const { + return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); + } + const XMLDeclaration* ToDeclaration() const { + return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); + } + +private: + const XMLNode* _node; +}; + + +/** + Printing functionality. The XMLPrinter gives you more + options than the XMLDocument::Print() method. + + It can: + -# Print to memory. + -# Print to a file you provide. + -# Print XML without a XMLDocument. + + Print to Memory + + @verbatim + XMLPrinter printer; + doc.Print( &printer ); + SomeFunction( printer.CStr() ); + @endverbatim + + Print to a File + + You provide the file pointer. + @verbatim + XMLPrinter printer( fp ); + doc.Print( &printer ); + @endverbatim + + Print without a XMLDocument + + When loading, an XML parser is very useful. However, sometimes + when saving, it just gets in the way. The code is often set up + for streaming, and constructing the DOM is just overhead. + + The Printer supports the streaming case. The following code + prints out a trivially simple XML file without ever creating + an XML document. + + @verbatim + XMLPrinter printer( fp ); + printer.OpenElement( "foo" ); + printer.PushAttribute( "foo", "bar" ); + printer.CloseElement(); + @endverbatim +*/ +class VOXEL_EXPORT XMLPrinter : public XMLVisitor +{ +public: + /** Construct the printer. If the FILE* is specified, + this will print to the FILE. Else it will print + to memory, and the result is available in CStr(). + If 'compact' is set to true, then output is created + with only required whitespace and newlines. + */ + XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 ); + virtual ~XMLPrinter() {} + + /** If streaming, write the BOM and declaration. */ + void PushHeader( bool writeBOM, bool writeDeclaration ); + /** If streaming, start writing an element. + The element must be closed with CloseElement() + */ + void OpenElement( const char* name, bool compactMode=false ); + /// If streaming, add an attribute to an open element. + void PushAttribute( const char* name, const char* value ); + void PushAttribute( const char* name, int value ); + void PushAttribute( const char* name, unsigned value ); + void PushAttribute( const char* name, bool value ); + void PushAttribute( const char* name, double value ); + /// If streaming, close the Element. + virtual void CloseElement( bool compactMode=false ); + + /// Add a text node. + void PushText( const char* text, bool cdata=false ); + /// Add a text node from an integer. + void PushText( int value ); + /// Add a text node from an unsigned. + void PushText( unsigned value ); + /// Add a text node from a bool. + void PushText( bool value ); + /// Add a text node from a float. + void PushText( float value ); + /// Add a text node from a double. + void PushText( double value ); + + /// Add a comment + void PushComment( const char* comment ); + + void PushDeclaration( const char* value ); + void PushUnknown( const char* value ); + + virtual bool VisitEnter( const XMLDocument& /*doc*/ ); + virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + return true; + } + + virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ); + virtual bool VisitExit( const XMLElement& element ); + + virtual bool Visit( const XMLText& text ); + virtual bool Visit( const XMLComment& comment ); + virtual bool Visit( const XMLDeclaration& declaration ); + virtual bool Visit( const XMLUnknown& unknown ); + + /** + If in print to memory mode, return a pointer to + the XML file in memory. + */ + const char* CStr() const { + return _buffer.Mem(); + } + /** + If in print to memory mode, return the size + of the XML file in memory. (Note the size returned + includes the terminating null.) + */ + int CStrSize() const { + return _buffer.Size(); + } + /** + If in print to memory mode, reset the buffer to the + beginning. + */ + void ClearBuffer() { + _buffer.Clear(); + _buffer.Push(0); + } + +protected: + virtual bool CompactMode( const XMLElement& ) { return _compactMode; } + + /** Prints out the space before an element. You may override to change + the space and tabs used. A PrintSpace() override should call Print(). + */ + virtual void PrintSpace( int depth ); + void Print( const char* format, ... ); + + void SealElement(); + bool _elementJustOpened; + DynArray< const char*, 10 > _stack; + +private: + void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities. + + bool _firstElement; + FILE* _fp; + int _depth; + int _textDepth; + bool _processEntities; + bool _compactMode; + + enum { + ENTITY_RANGE = 64, + BUF_SIZE = 200 + }; + bool _entityFlag[ENTITY_RANGE]; + bool _restrictedEntityFlag[ENTITY_RANGE]; + + DynArray< char, 20 > _buffer; +}; + +/** + * @} + */ + +} // TinyXML2 + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif + +#endif // TINYXML2_INCLUDED diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/USBBulkStreamer.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/USBBulkStreamer.h new file mode 100755 index 0000000..575fbca --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/USBBulkStreamer.h @@ -0,0 +1,52 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef USB_BULK_STREAMER_H +#define USB_BULK_STREAMER_H + +#include +#include "USBIO.h" + +namespace Voxel +{ +/** + * \addtogroup IO + * @{ + */ + + +class VOXEL_EXPORT USBBulkStreamer : public Streamer +{ +protected: + class USBBulkStreamerPrivate; + Ptr _usbBulkStreamerPrivate; + + virtual bool _start(); + virtual bool _capture(RawDataFramePtr &p); + virtual bool _stop(); + +public: + USBBulkStreamer(USBIOPtr &usbIO, DevicePtr device, uint8_t endpoint); + + virtual ~USBBulkStreamer(); + + virtual bool isInitialized(); + + virtual bool setBufferSize(size_t bufferSize); + + // All these three are dummy + virtual bool getSupportedVideoModes(Vector &videoModes); + virtual bool getCurrentVideoMode(VideoMode &videoMode); + virtual bool setVideoMode(const VideoMode &videoMode); + +}; +/** + * @} + */ + +} + +#endif // USB_BULK_STREAMER_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/USBIO.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/USBIO.h new file mode 100755 index 0000000..ad95819 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/USBIO.h @@ -0,0 +1,66 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_USBIO_H +#define VOXEL_USBIO_H + +#include "Device.h" +#include "USBSystem.h" +#include "Logger.h" + +namespace Voxel +{ + +class VOXEL_EXPORT USBIO +{ +protected: + class USBIOPrivate; + Ptr _usbIOPrivate; + +public: + USBIO(DevicePtr device); + + enum Direction + { + TO_DEVICE = 0, + FROM_DEVICE = 1 + }; + + enum RequestType + { + REQUEST_STANDARD = 0, + REQUEST_CLASS = 1, + REQUEST_VENDOR = 2, + REQUEST_RESERVED = 3, + }; + + enum RecipientType + { + RECIPIENT_DEVICE = 0x00, + RECIPIENT_INTERFACE = 0x01, + RECIPIENT_ENDPOINT = 0x02, + RECIPIENT_OTHER = 0x03, + }; + + bool controlTransfer(Direction direction, RequestType requestType, RecipientType recipientType, uint8_t request, uint16_t value, uint16_t index, + uint8_t *data, uint16_t &length, bool needFullLength = true, long timeout = 1000); + + bool bulkTransfer(uint8_t endpoint, uint8_t *data, long toTransferLength, long &transferredLength, long timeout = 1000); + + bool resetBulkEndPoint(uint8_t endpoint); + + USBSystem &getUSBSystem(); + + bool isInitialized(); + + virtual ~USBIO() {} +}; + +typedef Ptr USBIOPtr; + +} + +#endif \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/USBSystem.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/USBSystem.h new file mode 100755 index 0000000..31a9069 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/USBSystem.h @@ -0,0 +1,48 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_USBSYSTEM_H +#define VOXEL_USBSYSTEM_H + +#include "Common.h" +#include "Device.h" + +namespace Voxel +{ + +/** + * \addtogroup IO + * @{ + */ + + +class VOXEL_NO_EXPORT USBSystemPrivate; + +// This facilitates getting device handle corresponding a particular vid:pid:serial +class VOXEL_EXPORT USBSystem +{ +protected: + Ptr _usbPrivate; + +public: + USBSystem(); + + Vector getDevices(); + + bool isInitialized(); + + inline USBSystemPrivate &getUSBSystemPrivate() { return *_usbPrivate; } + + String getDeviceNode(const USBDevice &usbd); + + virtual ~USBSystem() {} +}; +/** + * @} + */ + +} +#endif // VOXEL_USBSYSTEM_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/UVC.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/UVC.h new file mode 100755 index 0000000..618cf27 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/UVC.h @@ -0,0 +1,54 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_UVC_H +#define VOXEL_UVC_H + +#include "Device.h" + +namespace Voxel +{ + +/** + * \addtogroup IO + * @{ + */ + + +class VOXEL_EXPORT UVCRawData +{ +public: + Ptr data; + std::size_t size; +}; + + +class VOXEL_NO_EXPORT UVCPrivate; + +class VOXEL_EXPORT UVC +{ +protected: + DevicePtr _usb; + + Ptr _uvcPrivate; + +public: + UVC(DevicePtr usb); + + virtual bool isInitialized(); + + inline UVCPrivate &getUVCPrivate() { return *_uvcPrivate; } + + bool read(uint8_t *buffer, std::size_t size); + + virtual ~UVC(); +}; +/** + * @} + */ + +} +#endif // UVC_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/UVCStreamer.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/UVCStreamer.h new file mode 100755 index 0000000..83e5b83 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/UVCStreamer.h @@ -0,0 +1,58 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_UVCSTREAMER_H +#define VOXEL_UVCSTREAMER_H + +#include "Streamer.h" +#include "UVC.h" + +namespace Voxel +{ + +/** + * \addtogroup IO + * @{ + */ + + +// Parts of this class are borrowed from http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html +// TODO This currently seeks only YUYV as pixel format +class VOXEL_EXPORT UVCStreamer : public Streamer +{ +protected: + class UVCStreamerPrivate; + Ptr _uvcStreamerPrivate; + + Ptr _currentVideoMode; + void _storeCurrentVideoMode(const VideoMode &videoMode); + + bool _uvcInit(); + bool _initForCapture(); + + virtual bool _start(); + virtual bool _capture(RawDataFramePtr &p); + virtual bool _stop(); + +public: + UVCStreamer(DevicePtr device); + + virtual bool isInitialized(); + + virtual bool getSupportedVideoModes(Vector &videoModes); + + virtual bool getCurrentVideoMode(VideoMode &videoMode); + virtual bool setVideoMode(const VideoMode &videoMode); + + virtual ~UVCStreamer(); +}; +/** + * @} + */ + +} + +#endif // VOXEL_UVCSTREAMER_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/UVCXU.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/UVCXU.h new file mode 100755 index 0000000..3d36990 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/UVCXU.h @@ -0,0 +1,45 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_UVCXU_H +#define VOXEL_UVCXU_H + +#include "UVC.h" + +namespace Voxel +{ +/** + * \addtogroup IO + * @{ + */ + + +class VOXEL_EXPORT UVCXU : public UVC +{ +protected: + int _xuID; + + class VOXEL_NO_EXPORT UVCXUPrivate; + Ptr _uvcXUPrivate; + +public: + UVCXU(DevicePtr usb, int xuID); + + bool isInitialized(); + + virtual ~UVCXU(); + + bool setControl(int controlnumber, int size, uint8_t *value); + bool getControl(int controlnumber, int size, uint8_t *value); +}; + +typedef Ptr UVCXUPtr; +/** + * @} + */ + +} +#endif // UVCXU_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/VideoMode.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/VideoMode.h new file mode 100755 index 0000000..208f6f6 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/VideoMode.h @@ -0,0 +1,95 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_VIDEO_MODE_H +#define VOXEL_VIDEO_MODE_H + +#include + +namespace Voxel +{ +/** + * \addtogroup Frm + * @{ + */ + +class FrameSize +{ +public: + uint32_t width, height; + + inline bool operator ==(const FrameSize &other) const + { + return width == other.width && height == other.height; + } + + inline bool operator !=(const FrameSize &other) const + { + return !operator==(other); + } +}; + +class RegionOfInterest: public FrameSize +{ +public: + uint32_t x, y; + + inline bool operator ==(const RegionOfInterest &other) const + { + return width == other.width && height == other.height && x == other.x && y == other.y; + } + + inline bool operator !=(const RegionOfInterest &other) const + { + return !operator==(other); + } +}; + +class FrameRate +{ +public: + uint32_t numerator, denominator; + + inline float getFrameRate() const { return (denominator == 0)?0:(((float)numerator)/denominator); } +}; + +class VideoMode +{ +public: + FrameSize frameSize; + FrameRate frameRate; + + inline float getFrameRate() const { return frameRate.getFrameRate(); } +}; + +class SupportedVideoMode: public VideoMode +{ +public: + uint8_t bytesPerPixel; + + SupportedVideoMode(): bytesPerPixel(0) + { + frameSize.width = frameSize.height = 0; + frameRate.numerator = 0; + frameRate.denominator = 1; + } + + SupportedVideoMode(uint32_t width, uint32_t height, uint32_t rateNumerator, uint32_t rateDenominator, uint8_t bytesPerPixel) + { + frameSize.width = width; + frameSize.height = height; + frameRate.numerator = rateNumerator; + frameRate.denominator = rateDenominator; + this->bytesPerPixel = bytesPerPixel; + } +}; +/** + * @} + */ + +} + +#endif // VOXEL_POINT_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/VoxelConfig.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/VoxelConfig.h new file mode 100755 index 0000000..7380469 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/VoxelConfig.h @@ -0,0 +1,16 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_VOXELCONFIG_H +#define VOXEL_VOXELCONFIG_H + +#define VOXEL_ABI_VERSION 34 +#define VOXEL_MAJOR_VERSION 0 +#define VOXEL_MINOR_VERSION 6 +#define VOXEL_PATCH_VERSION 7 +#define VOXEL_CONF_VERSION 1 + +#endif diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/VoxelExports.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/VoxelExports.h new file mode 100755 index 0000000..79e6e97 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/VoxelExports.h @@ -0,0 +1,41 @@ + +#ifndef VOXEL_EXPORT_H +#define VOXEL_EXPORT_H + +#ifdef VOXEL_STATIC_DEFINE +# define VOXEL_EXPORT +# define VOXEL_NO_EXPORT +#else +# ifndef VOXEL_EXPORT +# ifdef voxel_EXPORTS + /* We are building this library */ +# define VOXEL_EXPORT __attribute__((visibility("default"))) +# else + /* We are using this library */ +# define VOXEL_EXPORT __attribute__((visibility("default"))) +# endif +# endif + +# ifndef VOXEL_NO_EXPORT +# define VOXEL_NO_EXPORT __attribute__((visibility("hidden"))) +# endif +#endif + +#ifndef VOXEL_DEPRECATED +# define VOXEL_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef VOXEL_DEPRECATED_EXPORT +# define VOXEL_DEPRECATED_EXPORT VOXEL_EXPORT VOXEL_DEPRECATED +#endif + +#ifndef VOXEL_DEPRECATED_NO_EXPORT +# define VOXEL_DEPRECATED_NO_EXPORT VOXEL_NO_EXPORT VOXEL_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define VOXEL_NO_DEPRECATED +#endif + +#endif diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/pcl/PCLGrabber.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/pcl/PCLGrabber.h new file mode 100755 index 0000000..ae3de75 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/pcl/PCLGrabber.h @@ -0,0 +1,83 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_PCLGRABBER_H +#define VOXEL_PCLGRABBER_H + +#include +#include +#include +#include + +#include "VoxelPCLExports.h" + +namespace Voxel +{ + +class VOXELPCL_EXPORT PCLGrabber: public pcl::Grabber +{ +public: + typedef void (PointCloudCallBack) (const pcl::PointCloud &); + typedef void (PointCloudFrameCallBack) (const Voxel::PointCloudFrame &); + typedef void (DepthImageCallBack) (const Voxel::DepthFrame &); + typedef void (RawImageCallBack) (const Voxel::RawFrame &, const Voxel::DepthCamera::FrameType type); + // For ToF type depth cameras, this could return reference to Voxel::ToFRawFrame or Voxel::RawDataFrame base on the 'type' + +protected: + DepthCamera &_depthCamera; + + FrameBufferManager> _pointCloudBuffer; + + boost::signals2::signal* _pointCloudFrameSignal; + boost::signals2::signal* _pointCloudSignal; + boost::signals2::signal* _depthImageSignal; + boost::signals2::signal* _rawImageSignal; + + void _callback(DepthCamera &depthCamera, const Frame &frame, DepthCamera::FrameType type); + +public: + PCLGrabber(DepthCamera &depthCamera); + + virtual float getFramesPerSecond() const + { + FrameRate r; + if(!_depthCamera.getFrameRate(r)) + return 0; + else + return r.getFrameRate(); + } + + virtual std::string getName() const { return _depthCamera.id(); } + + virtual bool isRunning() const { return _depthCamera.isRunning(); } + + virtual void start() { _depthCamera.start(); } + + virtual void stop() { _depthCamera.stop(); _depthCamera.wait(); } + + virtual ~PCLGrabber() + { + if(isRunning()) + stop(); + } +}; + +/// Support for std::shared_ptr <-> boost::shared_ptr +template +boost::shared_ptr make_shared_ptr(std::shared_ptr& ptr) +{ + return boost::shared_ptr(ptr.get(), [ptr](T*) mutable {ptr.reset();}); +} + +template +std::shared_ptr make_shared_ptr(boost::shared_ptr& ptr) +{ + return std::shared_ptr(ptr.get(), [ptr](T*) mutable {ptr.reset();}); +} + +} + +#endif // PCLGRABBER_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/pcl/VoxelPCLExports.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/pcl/VoxelPCLExports.h new file mode 100755 index 0000000..d80eb08 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/pcl/VoxelPCLExports.h @@ -0,0 +1,41 @@ + +#ifndef VOXELPCL_EXPORT_H +#define VOXELPCL_EXPORT_H + +#ifdef VOXELPCL_STATIC_DEFINE +# define VOXELPCL_EXPORT +# define VOXELPCL_NO_EXPORT +#else +# ifndef VOXELPCL_EXPORT +# ifdef voxelpcl_EXPORTS + /* We are building this library */ +# define VOXELPCL_EXPORT __attribute__((visibility("default"))) +# else + /* We are using this library */ +# define VOXELPCL_EXPORT __attribute__((visibility("default"))) +# endif +# endif + +# ifndef VOXELPCL_NO_EXPORT +# define VOXELPCL_NO_EXPORT __attribute__((visibility("hidden"))) +# endif +#endif + +#ifndef VOXELPCL_DEPRECATED +# define VOXELPCL_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef VOXELPCL_DEPRECATED_EXPORT +# define VOXELPCL_DEPRECATED_EXPORT VOXELPCL_EXPORT VOXELPCL_DEPRECATED +#endif + +#ifndef VOXELPCL_DEPRECATED_NO_EXPORT +# define VOXELPCL_DEPRECATED_NO_EXPORT VOXELPCL_NO_EXPORT VOXELPCL_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define VOXELPCL_NO_DEPRECATED +#endif + +#endif diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/TI3DToFExports.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/TI3DToFExports.h new file mode 100755 index 0000000..d25087f --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/TI3DToFExports.h @@ -0,0 +1,41 @@ + +#ifndef TI3DTOF_EXPORT_H +#define TI3DTOF_EXPORT_H + +#ifdef TI3DTOF_STATIC_DEFINE +# define TI3DTOF_EXPORT +# define TI3DTOF_NO_EXPORT +#else +# ifndef TI3DTOF_EXPORT +# ifdef ti3dtof_EXPORTS + /* We are building this library */ +# define TI3DTOF_EXPORT __attribute__((visibility("default"))) +# else + /* We are using this library */ +# define TI3DTOF_EXPORT __attribute__((visibility("default"))) +# endif +# endif + +# ifndef TI3DTOF_NO_EXPORT +# define TI3DTOF_NO_EXPORT __attribute__((visibility("hidden"))) +# endif +#endif + +#ifndef TI3DTOF_DEPRECATED +# define TI3DTOF_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef TI3DTOF_DEPRECATED_EXPORT +# define TI3DTOF_DEPRECATED_EXPORT TI3DTOF_EXPORT TI3DTOF_DEPRECATED +#endif + +#ifndef TI3DTOF_DEPRECATED_NO_EXPORT +# define TI3DTOF_DEPRECATED_NO_EXPORT TI3DTOF_NO_EXPORT TI3DTOF_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define TI3DTOF_NO_DEPRECATED +#endif + +#endif diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCalculusCamera.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCalculusCamera.h new file mode 100755 index 0000000..f19c8e3 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCalculusCamera.h @@ -0,0 +1,158 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TI_TOFCALCULUSCAMERA_H +#define VOXEL_TI_TOFCALCULUSCAMERA_H + +#include + +#define MOD_M_FRAC "mod_m_frac" +#undef MOD_PS1 +#define MOD_PS "mod_ps" +#undef MOD_PS2 +#undef MOD_FREQ1 +#undef MOD_FREQ2 +#define MOD_F "mod_freq1" + +#undef DEALIAS_16BIT_OP_ENABLE +#undef DEALIASED_PHASE_MASK + +#define ALT_FRM_EN "alt_frm_en" +#define ALT_FREQ_SEL "alt_freq_sel" +#define SUP_FRM_INTG_SCALE "sup_frm_intg_scale" + +#define STANDBY "standby" +#define DIS_SDMOD "dis_sdmod" +#define INIT_0 "init_0" +#define INIT_1 "init_1" +#define INIT_2 "init_2" +#define INIT_3 "init_3" +#define INIT_4 "init_4" +#define INIT_5 "init_5" +#define INIT_6 "init_6" +#define INIT_7 "init_7" +#define INIT_8 "init_8" +#define UPDATE_SEL "update_sel" +#define OP_DATA_ARRANGE_MODE "op_data_arrange_mode" +#define MOD_CDRIV_EN "mod_cdriv_en" +#define MOD_CDRIV_CURR "mod_cdriv_curr" +#define SHUTTER_EN "shutter_en" +#define LUMPED_DEAD_TIME "lumped_dead_time" + +#undef CONFIDENCE_THRESHOLD +#define CONFIDENCE_THRESHOLD "amplitude_threshold" + +#undef SUBFRAME_CNT_MAX +#define SUBFRAME_CNT_MAX1 "sub_frame_cnt_max1" +#define SUBFRAME_CNT_MAX2 "sub_frame_cnt_max2" + +#define COEFF_ILLUM "coeff_illum" +#define COEFF_SENSOR "coeff_sensor" + +#define NONLINEARITY_PHASE_PERIOD "phase_lin_corr_period" +#define NONLINEARITY_COEFF "phase_lin_coeff" +#define NONLINEARITY_DISABLE "phase_lin_corr_dis" + +// For unambigous range +#define SCRATCH2 "scratch2" + +namespace Voxel +{ + +namespace TI +{ + +class TI3DTOF_EXPORT ToFCalculusCamera: public ToFCamera +{ +protected: + bool _init(); + + virtual bool _initStartParams(); + + virtual bool _getIlluminationFrequency(float& frequency) const; + bool _getMaximumFrameSize(FrameSize &s) const; + + virtual bool _getFrameSize(Voxel::FrameSize &s) const; + virtual bool _getBytesPerPixel(uint &bpp) const; + virtual bool _getOpDataArrangeMode(int &dataArrangeMode) const; + virtual bool _getSystemClockFrequency(uint &frequency) const; + + virtual bool _getToFFrameType(ToFFrameType &frameType) const; + virtual bool _allowedROI(String &message); + virtual bool _getROI(RegionOfInterest &roi) const; + virtual bool _setROI(const RegionOfInterest &roi); + virtual bool _getBinning(uint &rowsToMerge, uint &columnsToMerge) const; + virtual bool _setBinning(uint rowsToMerge, uint columnsToMerge, const FrameSize &frameSize); + + virtual bool _is16BitModeEnabled(bool &mode16Bit); + virtual bool _getDealiasedPhaseMask(int &dealiasedPhaseMask); + + virtual bool _getSubFrameCount(int &subframeCount) const; + + virtual bool _isHistogramEnabled() const; + + virtual bool _applyCalibrationParams(); + + bool _updateEasyConf(); + + virtual bool _getCurrentProfileRegisterName(String& name); + +public: + ToFCalculusCamera(const String &name, DevicePtr device); + + + + virtual ~ToFCalculusCamera() {} + + friend class CalculusVCOFrequency; + friend class CalculusModulationFrequencyParameter; + friend class CalculusIntegDutyCycle; + friend class CalculusUnambiguousRangeParameter; +}; + +class TI3DTOF_EXPORT CalculusModulationFrequencyParameter: public FloatParameter +{ + ToFCalculusCamera &_depthCamera; + float _optimalMinimum, _optimalMaximum; +public: + CalculusModulationFrequencyParameter(ToFCalculusCamera &depthCamera, RegisterProgrammer &programmer, const float &optimalMinimum, const float &optimalMaximum, const float &defaultValue): + FloatParameter(programmer, MOD_F, "MHz", 0, 0, 0, 1, 2.5f, 600.0f, defaultValue, "Modulation frequency", "Frequency used for modulation of illumination", + Parameter::IO_READ_WRITE, {VCO_FREQ, MOD_M, MOD_M_FRAC, MOD_N, MOD_PS}), _optimalMinimum(optimalMinimum), _optimalMaximum(optimalMaximum), _depthCamera(depthCamera) {} + + const float getOptimalMaximum() { return _optimalMaximum; } + const float getOptimalMinimum() { return _optimalMinimum; } + + virtual const float lowerLimit() const; + virtual const float upperLimit() const; + + virtual bool get(float &value, bool refresh = false); + + virtual bool set(const float &value); + + virtual ~CalculusModulationFrequencyParameter() {} +}; + +class TI3DTOF_EXPORT CalculusUnambiguousRangeParameter: public UnsignedIntegerParameter +{ + ToFCalculusCamera &_depthCamera; + uint _defaultValue; +public: + CalculusUnambiguousRangeParameter(ToFCalculusCamera &depthCamera, RegisterProgrammer &programmer, const uint &minimum, const uint &maximum, const uint &defaultValue): + UnsignedIntegerParameter(programmer, UNAMBIGUOUS_RANGE, "m", 0, 0, 23, 16, minimum, maximum, + defaultValue, "Unambiguous Range", "Unambiguous range of distance the camera needs to support"), _defaultValue(defaultValue), + _depthCamera(depthCamera) {} //FIXME 0x5839, 24 -- this register is not working + + virtual bool get(uint &value, bool refresh = false); + + virtual bool set(const uint &value); + + virtual ~CalculusUnambiguousRangeParameter() {} +}; + +} +} + +#endif // VOXEL_TI_TOFCALCULUSCAMERA_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCamera.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCamera.h new file mode 100755 index 0000000..f04e09c --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCamera.h @@ -0,0 +1,211 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TI_TOFCAMERA_H +#define VOXEL_TI_TOFCAMERA_H + +#include +#include "ToFFrameGenerator.h" + +#include "TI3DToFExports.h" + +#define PIX_CNT_MAX_SET_FAILED "pix_cnt_max_set_failed" +#define PIX_CNT_MAX "pix_cnt_max" +#define QUAD_CNT_MAX "quad_cnt_max" +#define SUBFRAME_CNT_MAX "sub_frame_cnt_max" + +#define TG_EN "tg_en" +#define BLK_SIZE "blk_size" +#define BLK_HEADER_EN "blk_header_en" +#define OP_CS_POL "op_cs_pol" +#define FB_READY_EN "fb_ready_en" + +#define CONFIDENCE_THRESHOLD "confidence_threshold" + +#define ILLUM_EN_POL "illum_en_pol" + +#define BIN_ROWS_TO_MERGE "rows_to_merge" +#define BIN_COLS_TO_MERGE "cols_to_merge" +#define BIN_ROW_COUNT "bin_row_count" +#define BIN_COLUMN_COUNT "bin_col_count" +#define BINNING_EN "binning_en" + +#define ROW_START "row_start" +#define ROW_END "row_end" +#define COL_START "col_start" +#define COL_END "col_end" + +#define DEBUG_EN "debug_en" + +#define PIXEL_DATA_SIZE "pixel_data_size" +#define OP_DATA_ARRANGE_MODE "op_data_arrange_mode" +#define OP_CLK_FREQ "op_clk_freq" + +#define HISTOGRAM_EN "histogram_en" + +#define INTG_TIME "intg_time" // Integration time +#define INTG_DUTY_CYCLE "intg_duty_cycle" +#define INTG_DUTY_CYCLE_SET_FAILED "intg_duty_cycle_set_failed" +#define MOD_FREQ1 "mod_freq1" // Modulation frequency for first source (MHz) +#define MOD_FREQ2 "mod_freq2" // Modulation frequency for second source (MHz) +#define VCO_FREQ "vco_freq" +#define MOD_PS1 "mod_ps1" +#define MOD_PS2 "mod_ps2" +#define MOD_M "mod_m" +#define MOD_N "mod_n" +#define MOD_PLL_UPDATE "mod_pll_update" + +#define MA "ma" +#define MB "mb" +#define K0 "ka" +#define DEALIAS_EN "dealias_en" +#define DEALIAS_16BIT_OP_ENABLE "dealias_16bit_op_enable" +#define DEALIASED_PHASE_MASK "dealiased_ph_mask" + +#define ToF_CALIB_SECT_FREQUENCY "frequency" +#define ToF_CALIB_SECT_CROSS_TALK "cross_talk" +#define ToF_CALIB_SECT_NON_LINEARITY "non_linearity" +#define ToF_CALIB_SECT_TEMPERATURE "temperature" +#define ToF_CALIB_SECT_COMMON_PHASE_OFFSET "common_phase_offset" +#define ToF_CALIB_SECT_PIXELWISE_PHASE_OFFSET "pixelwise_phase_offset" + +#define ToF_CALIB_SECT_FREQUENCY_ID 1 +#define ToF_CALIB_SECT_CROSS_TALK_ID 2 +#define ToF_CALIB_SECT_NON_LINEARITY_ID 3 +#define ToF_CALIB_SECT_TEMPERATURE_ID 4 +#define ToF_CALIB_SECT_COMMON_PHASE_OFFSET_ID 5 +#define ToF_CALIB_SECT_PIXELWISE_PHASE_OFFSET_ID 6 + + +#define PHASE_CORR_ADD "phase_corr_add" // Is the phase correction additive or subtractive? +#define PHASE_CORR_1 "phase_corr_1" +#define PHASE_CORR_2 "phase_corr_2" +#define TILLUM_CALIB "tillum_calib" +#define TSENSOR_CALIB "tsensor_calib" +#define COEFF_ILLUM_1 "coeff_illum_1" +#define COEFF_ILLUM_2 "coeff_illum_2" +#define COEFF_SENSOR_1 "coeff_sensor_1" +#define COEFF_SENSOR_2 "coeff_sensor_2" +#define DISABLE_OFFSET_CORR "disable_offset_corr" +#define DISABLE_TEMP_CORR "disable_temp_corr" +#define CALIB_PREC "calib_prec" + +#define ToF_FRAME_TYPE "output_mode" +#define SOFTWARE_RESET "software_reset" + +#define SPEED_OF_LIGHT 299792458.0 + +#define TI_VENDOR_ID 0x0451U + +#define UNAMBIGUOUS_RANGE "unambiguous_range" + +#define ILLUM_POWER "illum_power" +#define ILLUM_POWER_PERCENTAGE "illum_power_percentage" + + +#if ANDROID +#include +#include + +using namespace std; +namespace std +{ + template < typename T > std::string to_string( const T& n ) + { + std::ostringstream stm ; + stm << n ; + return stm.str() ; + } +} + +#endif + +namespace Voxel +{ + +namespace TI +{ + +// TI's ToF specific handling. This is generic base currently for TinTin and Haddock generation +class TI3DTOF_EXPORT ToFCamera: public ToFCameraBase +{ +protected: + bool _init(); + + virtual bool _processRawFrame(const RawFramePtr &rawFrameInput, RawFramePtr &rawFrameOutput); // here output raw frame will have processed data, like ToF data for ToF cameras + + virtual bool _getAmplitudeNormalizingFactor(float &factor); + virtual bool _getDepthScalingFactor(float& factor); + + virtual bool _setFrameRate(const FrameRate &r); + virtual bool _getFrameRate(FrameRate &r) const; + + virtual bool _getFrameSize(FrameSize &s) const; + virtual bool _setFrameSize(const FrameSize &s); + virtual bool _setFrameSize(const FrameSize &s, bool resetROI); + virtual bool _setStreamerFrameSize(const FrameSize &s) = 0; + virtual bool _getMaximumFrameRate(FrameRate& frameRate, const FrameSize& forFrameSize) const; + + virtual bool _getBytesPerPixel(uint &bpp) const; + virtual bool _setBytesPerPixel(const uint &bpp); + + virtual bool _getOpDataArrangeMode(int &dataArrangeMode) const; + + // Return the resultant modulation frequency. This is mod_freq1 for non-dealiased case and + // gcd(mod_freq1, mod_freq2) for dealiased case + virtual bool _getIlluminationFrequency(float &frequency) const = 0; + + virtual bool _getBinning(uint &rowsToMerge, uint &columnsToMerge) const; + virtual bool _setBinning(uint rowsToMerge, uint columnsToMerge, const FrameSize &frameSize); + + // Return in MHz + virtual bool _getSystemClockFrequency(uint &frequency) const = 0; + virtual bool _isHistogramEnabled() const = 0; + + virtual bool _getToFFrameType(ToFFrameType &frameType) const; + + virtual bool _is16BitModeEnabled(bool &mode16Bit); + virtual bool _getDealiasedPhaseMask(int &dealiasedPhaseMask); + + virtual bool _getSubFrameCount(int &subframeCount) const; + + virtual bool _initStartParams(); + + virtual bool _applyCalibrationParams() = 0; + + virtual bool _getCurrentProfileRegisterName(String &name) = 0; + virtual bool _getCurrentProfileID(int& id); + virtual bool _saveCurrentProfileID(const int id); + + virtual bool _reset(); + + Ptr _tofFrameGenerator; + +public: + ToFCamera(const String &name, const String &chipset, DevicePtr device); + + // NOTE: Not using the low-level API for getting serial number. USB's serial number is enough + //virtual bool getSerialNumber(String& serialNumber) const; + + virtual bool setSerialNumber(const String& serialNumber); + + virtual ~ToFCamera() {} + + friend class IntegrationTimeParameter; +}; + +class TI3DTOF_EXPORT PhaseCorrectionAdditiveParameter: public BoolParameter +{ +public: + PhaseCorrectionAdditiveParameter(bool value, RegisterProgrammer &programmer): + BoolParameter(programmer, PHASE_CORR_ADD, 0, 0, 0, {"Subtract common-phase correction to phase.", "Add common-phase correction from phase."}, + {"Subtract Correction", "Add Correction"}, value, "Common-phase Correction Type", "This read-only boolean indicates whether common-phase correction is additive or subtractive", Parameter::IO_READ_ONLY) + {} +}; +} +} + +#endif // VOXEL_TI_TOFCAMERA_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCameraBase.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCameraBase.h new file mode 100755 index 0000000..ae2cf02 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCameraBase.h @@ -0,0 +1,55 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TI_TOFCAMERABASE_H +#define VOXEL_TI_TOFCAMERABASE_H + +#include + +#include "TI3DToFExports.h" +#include "ToFDepthFrameGenerator.h" + +namespace Voxel +{ + +namespace TI +{ + +/// This is a generic ToFCamera which is not strictly dependent on TI's ToF chips +class TI3DTOF_EXPORT ToFCameraBase : public DepthCamera +{ +protected: + RawDataFramePtr _rawDataFrame; // Used by _captureDepthFrame(). This is not exposed to DepthCamera + virtual bool _captureRawUnprocessedFrame(RawFramePtr &rawFrame); + virtual bool _convertToDepthFrame(const RawFramePtr &rawFrame, DepthFramePtr &depthFrame); + + virtual bool _start(); + virtual bool _stop(); + + virtual bool _initStartParams(); + + virtual bool _getAmplitudeNormalizingFactor(float &factor) = 0; + virtual bool _getDepthScalingFactor(float &factor) = 0; + + bool _init(); + virtual bool _onReset(); + + Ptr _tofDepthFrameGenerator; + +public: + ToFCameraBase(const String &name, const String &chipset, DevicePtr device): DepthCamera(name, chipset, device), + _tofDepthFrameGenerator(new ToFDepthFrameGenerator()) + { + _frameGenerators[1] = std::dynamic_pointer_cast(_tofDepthFrameGenerator); + } + + virtual ~ToFCameraBase() {} +}; + +} +} + +#endif // TOFCAMERABASE_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCameraFactoryBase.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCameraFactoryBase.h new file mode 100755 index 0000000..988fab2 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCameraFactoryBase.h @@ -0,0 +1,36 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TI_TOFCAMERAFACTORY_H +#define VOXEL_TI_TOFCAMERAFACTORY_H + +#include + +#include "TI3DToFExports.h" + +namespace Voxel +{ + +namespace TI +{ + +class TI3DTOF_EXPORT ToFCameraFactoryBase: public DepthCameraFactory +{ +public: + ToFCameraFactoryBase(const String &name); + + virtual bool getChannels(Device &device, Vector &channels); + + virtual Vector getSupportedGeneratorTypes(); + virtual bool getFrameGenerator(uint8_t frameType, GeneratorIDType generatorID, FrameGeneratorPtr &frameGenerator); + + virtual ~ToFCameraFactoryBase() {} +}; + +} +} + +#endif // VOXEL_TI_TOFCAMERAFACTORY_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCrossTalkFilter.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCrossTalkFilter.h new file mode 100755 index 0000000..d798ce3 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFCrossTalkFilter.h @@ -0,0 +1,43 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#include "Filter/Filter.h" + +namespace Voxel +{ + +class ToFCrossTalkFilter: public Filter +{ + virtual bool _filter(const FramePtr& in, FramePtr& out); + + template + bool _filter(const T *amplitudeIn, const T *phaseIn, T *amplitudeOut, T *phaseOut); + + virtual void _onSet(const FilterParameterPtr& f) {} // No parameters + + FrameSize _size; + + uint32_t _maxPhaseRange; + float _phaseToAngleFactor, _angleToPhaseFactor; + + Vector _amplitudePhase; + + Vector _coefficients; + +public: + ToFCrossTalkFilter(); + + bool readCoefficients(const String &coefficients); + + bool setMaxPhaseRange(uint32_t maxPhaseRange); + virtual void reset(); + + virtual ~ToFCrossTalkFilter() {} +}; + +typedef Ptr ToFCrossTalkFilterPtr; + +} \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFDepthFrameGenerator.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFDepthFrameGenerator.h new file mode 100755 index 0000000..2009bf7 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFDepthFrameGenerator.h @@ -0,0 +1,46 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TOF_DEPTH_FRAME_GENERATOR_H +#define VOXEL_TOF_DEPTH_FRAME_GENERATOR_H + +#include +#include +#include "ToFFrameGenerator.h" + +namespace Voxel +{ + +namespace TI +{ + +class TI3DTOF_EXPORT ToFDepthFrameGenerator: public DepthFrameGenerator +{ + float _amplitudeScalingFactor, _depthScalingFactor; + + FramePtr _intermediate; + + ToFFrameGeneratorPtr _tofFrameGenerator; + + virtual bool _onReadConfiguration(); + virtual bool _onWriteConfiguration(); + +public: + ToFDepthFrameGenerator(); + + virtual bool generate(const FramePtr &in, FramePtr &out); + + bool setParameters(float amplitudeScalingFactor, float depthScalingFactor); + + virtual bool setProcessedFrameGenerator(FrameGeneratorPtr &p); + + virtual ~ToFDepthFrameGenerator() {} +}; + +} +} + +#endif \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFFrameGenerator.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFFrameGenerator.h new file mode 100755 index 0000000..9a33600 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFFrameGenerator.h @@ -0,0 +1,83 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TOF_FRAME_GENERATOR_H +#define VOXEL_TOF_FRAME_GENERATOR_H + +#include +#include "ToFCrossTalkFilter.h" +#include + +namespace Voxel +{ + +namespace TI +{ + +class TI3DTOF_EXPORT ToFFrameGenerator: public FrameGenerator +{ + uint32_t _bytesPerPixel, _dataArrangeMode; + + bool _dealiased16BitMode; + int _dealiasedPhaseMaskInPhaseOffset, _dealiasedPhaseMask; + + RegionOfInterest _roi; + FrameSize _maxFrameSize, _frameSize, _size; + uint32_t _rowsToMerge, _columnsToMerge; + + uint32_t _quadCount; + + Vector _sineTable, _cosineTable; + + uint32_t _histogramEnabled; + + String _phaseOffsetFileName; + Vector _phaseOffsetCorrectionData; + + ToFFrameType _frameType; + + ToFCrossTalkFilterPtr _crossTalkFilter; + String _crossTalkCoefficients; + FramePtr _filterInputFrame; + +protected: + virtual bool _onReadConfiguration(); + virtual bool _onWriteConfiguration(); + + virtual bool _createCrossTalkFilter(); + virtual bool _applyCrossTalkFilter(FramePtr &out); + virtual bool _readPhaseOffsetCorrection(); + virtual bool _applyPhaseOffsetCorrection(Vector &phaseData); + + bool _generateToFRawFrame(const FramePtr &in, FramePtr &out); + bool _generateToFRawIQFrame(const FramePtr &in, FramePtr &out); + +public: + ToFFrameGenerator(); + + virtual bool generate(const ToFRawIQFramePtr &in, FramePtr &out); // Convert IQ to amplitude-phase + virtual bool generate(const FramePtr &in, FramePtr &out); + + bool setParameters(const String &phaseOffsetFileName, const Vector &phaseOffsets, uint32_t bytesPerPixel, + uint32_t dataArrangeMode, + const RegionOfInterest &roi, const FrameSize &maxFrameSize, + const FrameSize &frameSize, + uint rowsToMerge, uint columnsToMerge, + uint8_t histogramEnabled, + const String &crossTalkCoefficients, ToFFrameType type, + uint32_t quadCount, + bool dealiased16BitMode, + int dealiasedPhaseMask); + + virtual ~ToFFrameGenerator() {} +}; + +typedef Ptr ToFFrameGeneratorPtr; + +} +} + +#endif \ No newline at end of file diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFHaddockCamera.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFHaddockCamera.h new file mode 100755 index 0000000..1ac98f3 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFHaddockCamera.h @@ -0,0 +1,59 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TI_TOFHADDOCKCAMERA_H +#define VOXEL_TI_TOFHADDOCKCAMERA_H + +#include + +#define CURRENT_PROFILE "scratch2" //sys_clk_freq used as scratch register + +namespace Voxel +{ + +namespace TI +{ + +class TI3DTOF_EXPORT ToFHaddockCamera: public ToFCamera +{ +protected: + bool _init(); + + virtual bool _initStartParams(); + + bool _getMaximumFrameSize(FrameSize &s) const; + + virtual bool _getSystemClockFrequency(uint &frequency) const; + virtual bool _getIlluminationFrequency(float& frequency) const; + + + virtual bool _allowedROI(String &message); + virtual bool _getROI(RegionOfInterest &roi) const; + virtual bool _setROI(const RegionOfInterest &roi); + + virtual bool _isHistogramEnabled() const; + + virtual bool _applyCalibrationParams(); + + virtual bool _getCurrentProfileRegisterName(String& name); + +public: + ToFHaddockCamera(const String &name, DevicePtr device); + + + + virtual ~ToFHaddockCamera() {} + + friend class HaddockVCOFrequency; + friend class HaddockModulationFrequencyParameter; + friend class HaddockUnambiguousRangeParameter; + friend class HaddockSensorTemperatureParameter; +}; + +} +} + +#endif // VOXEL_TI_TOFHADDOCKCAMERA_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFTintinCamera.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFTintinCamera.h new file mode 100755 index 0000000..8456d28 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/ToFTintinCamera.h @@ -0,0 +1,180 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TI_TOFTINTINCAMERA_H +#define VOXEL_TI_TOFTINTINCAMERA_H + +#include + +#define MOD_M1 "mod_m1" //mdiv_fb_deci_pll1 +#define MOD_M_FRAC1 "mod_m_frac1" +#undef MOD_M2 +#define MOD_M2 "mod_m2" //mdiv_fb_deci_pll2 +#define MOD_M_FRAC2 "mod_m_frac2" +#define MOD_N1 "mod_n1" //mdiv_pll_1_in +#undef MOD_N2 +#define MOD_N2 "mod_n2" //mdiv_pll_2_in + +#define VCO_FREQ1 "vco_freq1" +#define VCO_FREQ2 "vco_freq2" + +#undef MOD_PS1 +#define MOD_PS1 "mod_ps1" //mdiv_ff_pll1 +#undef MOD_PS2 +#define MOD_PS2 "mod_ps2" //mdiv_ff_pll2 +#undef MOD_PLL_UPDATE +#define MOD_PLL_UPDATE "mod_pll_update" //reset_pll_reg + +#undef DEBUG_EN +#define DEBUG_EN "phy_test_enable" + +#undef CONFIDENCE_THRESHOLD +#define CONFIDENCE_THRESHOLD "amplitude_threshold" + +#define KA "ka" +#define KB "kb" +#define FREQ_RATIO "freq_ratio" +#define DELAY_FB_COEFF1 "delay_fb_coeff_1" + +#undef HISTOGRAM_EN + +#define TG_DISABLE "tg_dis" + +#define SCRATCH1 "scratch1" // Used for storing unambiguous range +#define SCRATCH2 "scratch2" // Used for storing current camera profile ID + +#define X_CROSS_TALK_COEFF_F1 "x_filt_coeff_f1" +#define Y_CROSS_TALK_COEFF_F1 "y_filt_coeff_f1" +#define X_CROSS_TALK_COEFF_F2 "x_filt_coeff_f2" +#define Y_CROSS_TALK_COEFF_F2 "y_filt_coeff_f2" + +#define CROSS_TALK_FILT_COEFF_X_RE_F1 "filt_coeff_x_re_f1" +#define CROSS_TALK_FILT_COEFF_X_IM_F1 "filt_coeff_x_im_f1" +#define CROSS_TALK_FILT_COEFF_Y_RE_F1 "filt_coeff_y_re_f1" +#define CROSS_TALK_FILT_COEFF_Y_IM_F1 "filt_coeff_y_im_f1" +#define CROSS_TALK_FILT_COEFF_X_RE_F2 "filt_coeff_x_re_f2" +#define CROSS_TALK_FILT_COEFF_X_IM_F2 "filt_coeff_x_im_f2" +#define CROSS_TALK_FILT_COEFF_Y_RE_F2 "filt_coeff_y_re_f2" +#define CROSS_TALK_FILT_COEFF_Y_IM_F2 "filt_coeff_y_im_f2" +#define CROSS_TALK_EN "filt_en" +#define CROSS_TALK_SCALE "filt_scale" + +#define NONLINEARITY_PHASE_PERIOD "phase_lin_corr_period" +#define NONLINEARITY_COEFF_F1 "phase_lin_coeff0" +#define NONLINEARITY_COEFF_F2 "phase_lin_coeff1" +#define NONLINEARITY_ENABLE "phase_lin_corr_en" + +#define COEFF_ILLUM "coeff_illum" +#define COEFF_SENSOR "coeff_sensor" +#define DELAY_FB_CORR_MODE "delay_fb_corr_mode" +#define DELAY_FB_DC_CORR_MODE "delay_fb_dc_corr_mode" + +namespace Voxel +{ + +namespace TI +{ + +class TI3DTOF_EXPORT ToFTintinCamera: public ToFCamera +{ +protected: + bool _init(); + + virtual bool _initStartParams(); + + virtual bool _getIlluminationFrequency(float& frequency) const; + + virtual bool _getSystemClockFrequency(uint &frequency) const; + virtual bool _allowedROI(String &message); + virtual bool _getROI(RegionOfInterest &roi) const; + virtual bool _setROI(const RegionOfInterest &roi); + + virtual bool _isHistogramEnabled() const; + + virtual bool _applyCalibrationParams(); + + virtual bool _getCurrentProfileRegisterName(String& name); + +public: + ToFTintinCamera(const String &name, DevicePtr device); + + virtual bool _getMaximumFrameSize(FrameSize &s) const; + virtual ~ToFTintinCamera() {} + + friend class TintinVCOFrequency; + friend class TintinModulationFrequencyParameter; + friend class TintinUnambiguousRangeParameter; +}; + +class TI3DTOF_EXPORT TintinModulationFrequencyParameter: public FloatParameter +{ + ToFTintinCamera &_depthCamera; + String _modPS, _vcoFreq; +public: + TintinModulationFrequencyParameter(ToFTintinCamera &depthCamera, RegisterProgrammer &programmer, const String &name, const String &vcoFreq, const String &modPS, const float &defaultValue): + FloatParameter(programmer, name, "MHz", 0, 0, 0, 1, 2.5f, 600.0f, defaultValue, "Modulation frequency", "Frequency used for modulation of illumination", + Parameter::IO_READ_WRITE, {vcoFreq, modPS}), _vcoFreq(vcoFreq), _modPS(modPS), _depthCamera(depthCamera) {} + + virtual const float getOptimalMaximum() = 0; + virtual const float getOptimalMinimum() = 0; + + virtual const float lowerLimit() const + { + int quadCount; + + if(!_depthCamera._get(QUAD_CNT_MAX, quadCount)) + return _lowerLimit; + + if(quadCount == 0) + return _lowerLimit; + + return 37.5f/quadCount; + + } + virtual const float upperLimit() const + { + int quadCount; + + if(!_depthCamera._get(QUAD_CNT_MAX, quadCount)) + return _upperLimit; + + if(quadCount == 0) + return _upperLimit; + + return 600.0f/quadCount; + } + + virtual bool get(float &value, bool refresh = false); + + virtual bool set(const float &value); + + virtual ~TintinModulationFrequencyParameter() {} +}; + +// NOTE: scratch1 register available for software to store bits in Tintin camera. +class TI3DTOF_EXPORT TintinUnambiguousRangeParameter: public UnsignedIntegerParameter +{ + ToFTintinCamera &_depthCamera; + uint _defaultValue; + uint _modPS1, _modPS2; +public: + TintinUnambiguousRangeParameter(ToFTintinCamera &depthCamera, RegisterProgrammer &programmer, const uint &minimum, const uint &maximum, const uint &defaultValue, const uint &modPS1, const uint &modPS2): + UnsignedIntegerParameter(programmer, UNAMBIGUOUS_RANGE, "m", 0, 0, 0, 0, minimum, maximum, + defaultValue, "Unambiguous Range", "Unambiguous range of distance the camera needs to support"), _defaultValue(defaultValue), + _modPS1(modPS1), _modPS2(modPS2), + _depthCamera(depthCamera) {} + + virtual bool get(uint &value, bool refresh = false); + + virtual bool set(const uint &value); +}; + + + +} +} + +#endif // VOXEL_TI_TOFTINTINCAMERA_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/VoxelProgrammerBase.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/VoxelProgrammerBase.h new file mode 100755 index 0000000..3366990 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/VoxelProgrammerBase.h @@ -0,0 +1,52 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TI_VOXEL_PROGRAMMER_BASE_H +#define VOXEL_TI_VOXEL_PROGRAMMER_BASE_H + +#include "RegisterProgrammer.h" +#include "Device.h" + +#include "TI3DToFExports.h" + +namespace Voxel +{ + +namespace TI +{ + +class TI3DTOF_EXPORT VoxelProgrammerBase: public RegisterProgrammer +{ +public: + typedef Map SlaveAddressToByteMap; + +protected: + DevicePtr _device; + + mutable Mutex _mutex; + + SlaveAddressToByteMap _slaveAddressToByteMap; + + virtual bool _readRegister(uint16_t slaveAddress, uint16_t registerAddress, uint32_t &value, uint8_t length) const = 0; + virtual bool _writeRegister(uint16_t slaveAddress, uint16_t registerAddress, uint32_t value, uint8_t length) = 0; + +public: + VoxelProgrammerBase(const SlaveAddressToByteMap &map, DevicePtr device); + + virtual bool readRegister(uint32_t address, uint32_t &value) const; + virtual bool writeRegister(uint32_t address, uint32_t value); + + // getValue() and setValue() are internally called readRegister() and writeRegister() which are thread-safe. So, no mutex locking in getValue() and setValue() + virtual bool getValue(const Parameter ¶m, uint32_t &value) const; + virtual bool setValue(const Parameter ¶m, uint32_t value, bool writeOnly = false); + + virtual ~VoxelProgrammerBase() {} +}; + +} +} + +#endif // VOXEL_TI_VOXEL_PROGRAMMER_BASE_H diff --git a/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/VoxelUSBProgrammer.h b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/VoxelUSBProgrammer.h new file mode 100755 index 0000000..c6f70eb --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/include/voxel-0.6.7/ti3dtof/VoxelUSBProgrammer.h @@ -0,0 +1,51 @@ +/* + * TI Voxel Lib component. + * + * Copyright (c) 2014 Texas Instruments Inc. + */ + +#ifndef VOXEL_TI_VOXEL_USB_PROGRAMMER_H +#define VOXEL_TI_VOXEL_USB_PROGRAMMER_H + +#include "USBIO.h" +#include "VoxelProgrammerBase.h" + +namespace Voxel +{ + +namespace TI +{ + +class TI3DTOF_EXPORT VoxelUSBProgrammer: public VoxelProgrammerBase +{ +public: + struct RequestParams + { + uint8_t readRequestCode, writeRequestCode; + uint8_t leftShiftBits; + }; + + typedef Map SlaveAddressToRequestParamsMap; +protected: + USBIOPtr _usbIO; + SlaveAddressToRequestParamsMap _slaveAddressToRequestParamsMap; + + virtual bool _readRegister(uint16_t slaveAddress, uint16_t registerAddress, uint32_t &value, uint8_t length) const; + virtual bool _writeRegister(uint16_t slaveAddress, uint16_t registerAddress, uint32_t value, uint8_t length); + +public: + VoxelUSBProgrammer(const SlaveAddressToByteMap &map, const SlaveAddressToRequestParamsMap &slaveAddressToRequestParamsMap, USBIOPtr &usbIO, DevicePtr device); + + virtual bool isInitialized() const; + + virtual bool reset(); + + inline USBIOPtr &getUSBIO() { return _usbIO; } + + virtual ~VoxelUSBProgrammer() {} +}; + +} +} + +#endif // VOXEL_TI_VOXELXU_PROGRAMMER_H diff --git a/third_party/voxelsdk_ubuntu_mate/lib/libti3dtof.so b/third_party/voxelsdk_ubuntu_mate/lib/libti3dtof.so new file mode 100755 index 0000000..2d2e21a Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/lib/libti3dtof.so differ diff --git a/third_party/voxelsdk_ubuntu_mate/lib/libti3dtof.so.0.6.7 b/third_party/voxelsdk_ubuntu_mate/lib/libti3dtof.so.0.6.7 new file mode 100755 index 0000000..2d2e21a Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/lib/libti3dtof.so.0.6.7 differ diff --git a/third_party/voxelsdk_ubuntu_mate/lib/libti3dtof.so.34 b/third_party/voxelsdk_ubuntu_mate/lib/libti3dtof.so.34 new file mode 100755 index 0000000..2d2e21a Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/lib/libti3dtof.so.34 differ diff --git a/third_party/voxelsdk_ubuntu_mate/lib/libvoxel.so b/third_party/voxelsdk_ubuntu_mate/lib/libvoxel.so new file mode 100755 index 0000000..3be2252 Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/lib/libvoxel.so differ diff --git a/third_party/voxelsdk_ubuntu_mate/lib/libvoxel.so.0.6.7 b/third_party/voxelsdk_ubuntu_mate/lib/libvoxel.so.0.6.7 new file mode 100755 index 0000000..3be2252 Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/lib/libvoxel.so.0.6.7 differ diff --git a/third_party/voxelsdk_ubuntu_mate/lib/libvoxel.so.34 b/third_party/voxelsdk_ubuntu_mate/lib/libvoxel.so.34 new file mode 100755 index 0000000..3be2252 Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/lib/libvoxel.so.34 differ diff --git a/third_party/voxelsdk_ubuntu_mate/lib/python2.7/Voxel.py b/third_party/voxelsdk_ubuntu_mate/lib/python2.7/Voxel.py new file mode 100644 index 0000000..1608961 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/lib/python2.7/Voxel.py @@ -0,0 +1,215 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 3.0.8 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. + + + + + +from sys import version_info +if version_info >= (2, 6, 0): + def swig_import_helper(): + from os.path import dirname + import imp + fp = None + try: + fp, pathname, description = imp.find_module('_Voxel', [dirname(__file__)]) + except ImportError: + import _Voxel + return _Voxel + if fp is not None: + try: + _mod = imp.load_module('_Voxel', fp, pathname, description) + finally: + fp.close() + return _mod + _Voxel = swig_import_helper() + del swig_import_helper +else: + import _Voxel +del version_info +from _Voxel import * +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. + + +def _swig_setattr_nondynamic(self, class_type, name, value, static=1): + if (name == "thisown"): + return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'SwigPyObject': + self.__dict__[name] = value + return + method = class_type.__swig_setmethods__.get(name, None) + if method: + return method(self, value) + if (not static): + if _newclass: + object.__setattr__(self, name, value) + else: + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + + +def _swig_setattr(self, class_type, name, value): + return _swig_setattr_nondynamic(self, class_type, name, value, 0) + + +def _swig_getattr_nondynamic(self, class_type, name, static=1): + if (name == "thisown"): + return self.this.own() + method = class_type.__swig_getmethods__.get(name, None) + if method: + return method(self) + if (not static): + return object.__getattr__(self, name) + else: + raise AttributeError(name) + +def _swig_getattr(self, class_type, name): + return _swig_getattr_nondynamic(self, class_type, name, 0) + + +def _swig_repr(self): + try: + strthis = "proxy of " + self.this.__repr__() + except Exception: + strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + +try: + _object = object + _newclass = 1 +except AttributeError: + class _object: + pass + _newclass = 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# This file is compatible with both classic and new-style classes. + + diff --git a/third_party/voxelsdk_ubuntu_mate/lib/python2.7/_Voxel.so b/third_party/voxelsdk_ubuntu_mate/lib/python2.7/_Voxel.so new file mode 100755 index 0000000..6638f86 Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/lib/python2.7/_Voxel.so differ diff --git a/third_party/voxelsdk_ubuntu_mate/lib/voxel/libdeptheyeh1cdk.so b/third_party/voxelsdk_ubuntu_mate/lib/voxel/libdeptheyeh1cdk.so new file mode 100755 index 0000000..a48061f Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/lib/voxel/libdeptheyeh1cdk.so differ diff --git a/third_party/voxelsdk_ubuntu_mate/lib/voxel/libdeptheyeh1cdk.so.0.6.7 b/third_party/voxelsdk_ubuntu_mate/lib/voxel/libdeptheyeh1cdk.so.0.6.7 new file mode 100755 index 0000000..a48061f Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/lib/voxel/libdeptheyeh1cdk.so.0.6.7 differ diff --git a/third_party/voxelsdk_ubuntu_mate/lib/voxel/libdeptheyeh1cdk.so.34 b/third_party/voxelsdk_ubuntu_mate/lib/voxel/libdeptheyeh1cdk.so.34 new file mode 100755 index 0000000..a48061f Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/lib/voxel/libdeptheyeh1cdk.so.34 differ diff --git a/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/CalculusCDKCamera.conf b/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/CalculusCDKCamera.conf new file mode 100755 index 0000000..f763f96 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/CalculusCDKCamera.conf @@ -0,0 +1,8 @@ +[core] +dml = OPT8320.dml +camera_profiles = DepthEyeH1CDKCameraH1ForSeeed.conf +default_profile = 130 + +[observed_params] +tsensor = refresh:5 + diff --git a/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/DepthEyeH1CDKCamera.conf b/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/DepthEyeH1CDKCamera.conf new file mode 100755 index 0000000..9c2527b --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/DepthEyeH1CDKCamera.conf @@ -0,0 +1,7 @@ +[observed_params] + +[core] +dml = OPT8320.dml +camera_profiles = DepthEyeH1CDKCameraH1ForSeeed.conf +default_profile = 130 + diff --git a/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/DepthEyeH1CDKCameraH1ForSeedPhaseOffset.bin b/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/DepthEyeH1CDKCameraH1ForSeedPhaseOffset.bin new file mode 100755 index 0000000..e1a39f0 Binary files /dev/null and b/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/DepthEyeH1CDKCameraH1ForSeedPhaseOffset.bin differ diff --git a/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/DepthEyeH1CDKCameraH1ForSeeed.conf b/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/DepthEyeH1CDKCameraH1ForSeeed.conf new file mode 100755 index 0000000..509f6b8 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/DepthEyeH1CDKCameraH1ForSeeed.conf @@ -0,0 +1,48 @@ +[params] +disable_illum_p = false +disable_illum_n = false +# PVDD 2.7V +pvdd_voltage = 5 +pvdd_en = true + +[calib] +actual_distance = 1.0 +coeff_sensor = -69 +tsensor_calib = 47 +tillum_calib = 0 +phase_corr_2 = 0 +phase_corr_1 = -237 +phasecorrection = file:DepthEyeH1CDKCameraH1ForSeedPhaseOffset.bin +freq_corr = 1 +freq_corr_at = 36 +phase_lin_coeff = 15 132 246 364 491 654 777 912 1039 +phase_lin_corr_period = 0 +coeff_illum = 0 +calib_prec = 8 +fy = 54.0 +fx = 54.0 +cx = 39.0 +cy = 29.0 +k1 = -0.175643 +k2 = -0.050417 +k3 = 1.144932 +p1 = 0.00 +p2 = 0.00 + +[defining_params] +unambiguous_range = 4 +mix_volt = 1200 +mod_freq1 = 36.0 +mod_cdriv_en = false +mod_cdriv_curr = 30 +sub_frame_cnt_max1 = 2 +frame_rate = 30.0 +intg_time = 9 +shutter_en = true +high_ambient_en = true + +[global] +id = 130 +name = H1ForSeeed + + diff --git a/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/OPT8320.dml b/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/OPT8320.dml new file mode 100755 index 0000000..14541e6 --- /dev/null +++ b/third_party/voxelsdk_ubuntu_mate/share/voxel-0.6.7/conf/OPT8320.dml @@ -0,0 +1,6357 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+