Skip to content

Commit

Permalink
openni2: new recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Apr 27, 2024
1 parent 3f1e13b commit 6c80703
Show file tree
Hide file tree
Showing 12 changed files with 523 additions and 0 deletions.
27 changes: 27 additions & 0 deletions recipes/openni2/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
sources:
"2.2.0.33":
url: "https://github.com/structureio/OpenNI2/archive/refs/tags/v2.2.0-debian.tar.gz"
sha256: "08f6842f20d1098ab2ebafadaac0130ffae5abd34cdf464bb6100cbe01ed95a8"
patches:
- patch_file: "patches/0003-Use-system-wide-libjpeg.patch"

Check failure on line 6 in recipes/openni2/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

wrong indentation: expected 2 but found 4
patch_description: "Use libjpeg from Conan"
patch_type: "conan"
patch_source: "https://salsa.debian.org/multimedia-team/openni2/-/blob/master/debian/patches/0003-Use-system-wide-libjpeg.patch"
- patch_file: "patches/0006-rpi-Added-Armv6l-as-new-target-platform-and-created-missing-OniPlatformLinux-Arm.h-header.patch"
patch_description: "Add support for armv6l"
patch_type: "portability"
patch_source: "https://salsa.debian.org/multimedia-team/openni2/-/blob/master/debian/patches/0006-rpi-Added-Armv6l-as-new-target-platform-and-created-missing-OniPlatformLinux-Arm.h-header.patch"
- patch_file: "patches/0014-fix-format-overflow-for-GCC7.patch"
patch_description: "Fix format overflow for GCC7"
patch_type: "portability"
patch_source: "https://salsa.debian.org/multimedia-team/openni2/-/blob/master/debian/patches/0014-fix-format-overflow-for-GCC7.patch"
- patch_file: "patches/0018-Don-t-allocate-m_errorBuffer-on-TLS.patch"
patch_description: "Don't allocate m_errorBuffer on TLS"
patch_type: "bugfix"
patch_source: "https://salsa.debian.org/multimedia-team/openni2/-/blob/master/debian/patches/0018-Don-t-allocate-m_errorBuffer-on-TLS.patch"
- patch_file: "patches/0019-disable-samples-jni-tools.patch"
patch_description: "Disable building of samples, JNI wrappers and tools"
patch_type: "conan"
- patch_file: "patches/0020-honor-cppflags.patch"
patch_description: "Use CPPFLAGS set by Conan"
patch_type: "conan"
109 changes: 109 additions & 0 deletions recipes/openni2/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import cmake_layout
from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, rmdir
from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain

required_conan_version = ">=1.53.0"


class Openni2Conan(ConanFile):
name = "openni2"
description = "The OpenNI 2.0 API provides access to PrimeSense-compatible depth sensors"
license = "Apache-2.0"
homepage = "https://github.com/structureio/OpenNI2"
url = "https://github.com/conan-io/conan-center-index"
topics = ("rgb-d", "cameras", "driver", "computer-vision", "depth-sensor")

package_type = "shared-library"
settings = "os", "arch", "compiler", "build_type"

def export_sources(self):
export_conandata_patches(self)

def package_id(self):
if self.info.settings.build_type != "Debug":
self.info.settings.build_type = "Release"

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("libjpeg/9e")
if self.settings.os == "Linux":
self.requires("libusb/1.0.26")
self.requires("libudev/system")

def validate(self):
if self.settings.os != "Linux":
# The library should also support Windows via MSBuild and macOS via Makefiles.
raise ConanInvalidConfiguration("Only Linux builds are currently supported. Contributions are welcome!")
if self.settings.arch not in ["x86", "x86_64", "armv6", "armv7"]:
raise ConanInvalidConfiguration(f"{self.settings.arch} architecture is not supported.")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

@property
def _build_type(self):
return "Debug" if self.settings.build_type == "Debug" else "Release"

@property
def _platform(self):
return {
"x86": "x86",
"x86_64": "x64",
"armv6": "Armv6l",
"armv7": "Arm",
}[str(self.settings.arch)]


def generate(self):
tc = AutotoolsToolchain(self)
tc.make_args.extend([
f"CFG={self._build_type}",
f"PLATFORM={self._platform}",
# Disable -Werror
"ALLOW_WARNINGS=1",
])
tc.generate()
deps = AutotoolsDeps(self)
deps.generate()

def build(self):
apply_conandata_patches(self)
rmdir(self, os.path.join(self.source_folder, "ThirdParty", "LibJPEG"))
with chdir(self, self.source_folder):
autotools = Autotools(self)
autotools.make()

def package(self):
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "*", os.path.join(self.source_folder, "Include"), os.path.join(self.package_folder, "include", "openni2"))
bin_dir = os.path.join(self.source_folder, "Bin", f"{self._platform}-{self._build_type}")
copy(self, "*.a", bin_dir, os.path.join(self.package_folder, "lib"))
copy(self, "*.so*", bin_dir, os.path.join(self.package_folder, "lib"))
copy(self, "*.ini", os.path.join(self.source_folder, "Config"), os.path.join(self.package_folder, "res"))

def package_info(self):
# The component groupings are unofficial
self.cpp_info.components["libopenni2"].libs = ["OpenNI2"]
self.cpp_info.components["libopenni2"].includedirs.append(os.path.join("include", "openni2"))
self.cpp_info.components["libopenni2"].requires = ["libjpeg::libjpeg"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["libopenni2"].system_libs.extend(["pthread", "m", "dl"])

self.cpp_info.components["depthutils"].libs = ["DepthUtils"]
self.cpp_info.components["depthutils"].includedirs.append(os.path.join("include", "openni2"))
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["depthutils"].system_libs.extend(["rt"])

self.cpp_info.components["drivers"].libs = ["DummyDevice", "OniFile", "PS1080", "PSLink"]
self.cpp_info.components["drivers"].includedirs.append(os.path.join("include", "openni2"))
self.cpp_info.components["drivers"].libdirs.append(os.path.join("lib", "OpenNI2", "Drivers"))
self.cpp_info.components["drivers"].resdirs = ["res"]
self.cpp_info.components["drivers"].requires = ["libjpeg::libjpeg", "libusb::libusb", "libudev::libudev"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["drivers"].system_libs.extend(["pthread", "m", "dl"])
124 changes: 124 additions & 0 deletions recipes/openni2/all/patches/0003-Use-system-wide-libjpeg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
From: Hauke Wintjen <[email protected]>
Date: Fri, 29 Mar 2013 22:21:36 +0100
Subject: Use system wide libjpeg

---
Source/Core/Makefile | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

--- a/Source/Core/Makefile
+++ b/Source/Core/Makefile
@@ -5,14 +5,12 @@
INC_DIRS = \
../../Include \
../../ThirdParty/PSCommon/XnLib/Include \
- ../Drivers/OniFile/Formats \
- ../../ThirdParty/LibJPEG
+ ../Drivers/OniFile/Formats

SRC_FILES = \
*.cpp \
../Drivers/OniFile/Formats/XnCodec.cpp \
- ../Drivers/OniFile/Formats/XnStreamCompression.cpp \
- ../../ThirdParty/LibJPEG/*.c \
+ ../Drivers/OniFile/Formats/XnStreamCompression.cpp

ifeq ("$(OSTYPE)","Darwin")
INC_DIRS += /opt/local/include
@@ -23,7 +21,7 @@
LIB_NAME = OpenNI2

LIB_DIRS = ../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG)
-USED_LIBS = XnLib dl pthread
+USED_LIBS = XnLib dl pthread jpeg
ifneq ("$(OSTYPE)","Darwin")
USED_LIBS += rt
endif
@@ -32,4 +30,5 @@

CFLAGS += -Wall

+USED_LIBS += jpeg
include ../../ThirdParty/PSCommon/BuildSystem/CommonCppMakefile
--- a/Source/Drivers/OniFile/Makefile
+++ b/Source/Drivers/OniFile/Makefile
@@ -6,15 +6,12 @@
. \
../../../Include \
../../../ThirdParty/PSCommon/XnLib/Include \
- ../../../ThirdParty/LibJPEG \
Formats

SRC_FILES = \
*.cpp \
Formats/*.cpp \
- XnLibExtensions/*.cpp \
- ../../../ThirdParty/LibJPEG/*.c
-
+ XnLibExtensions/*.cpp

ifeq ("$(OSTYPE)","Darwin")
INC_DIRS += /opt/local/include
@@ -25,7 +22,7 @@
LIB_NAME = OniFile

LIB_DIRS = ../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG)
-USED_LIBS = XnLib pthread
+USED_LIBS = XnLib pthread jpeg
ifneq ("$(OSTYPE)","Darwin")
USED_LIBS += rt
endif
--- a/Source/Drivers/PS1080/Makefile
+++ b/Source/Drivers/PS1080/Makefile
@@ -16,8 +16,7 @@
DriverImpl/*.cpp\
Formats/*.cpp \
Include/*.cpp \
- Sensor/*.cpp \
- ../../../ThirdParty/LibJPEG/*.c
+ Sensor/*.cpp


ifeq ("$(OSTYPE)","Darwin")
@@ -30,7 +29,7 @@

LIB_DIRS += ../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG)
LIB_DIRS += $(BIN_DIR)/$(PLATFORM)-$(CFG)
-USED_LIBS = XnLib dl pthread DepthUtils
+USED_LIBS = XnLib dl pthread DepthUtils jpeg
ifneq ("$(OSTYPE)","Darwin")
USED_LIBS += rt usb-1.0 udev
else
--- a/Source/Drivers/PS1080/PS1080Console/Makefile
+++ b/Source/Drivers/PS1080/PS1080Console/Makefile
@@ -11,7 +11,7 @@
*.cpp \

LIB_DIRS = ../../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG)
-USED_LIBS = XnLib OpenNI2 dl pthread
+USED_LIBS = XnLib OpenNI2 dl pthread jpeg

ifeq ("$(OSTYPE)","Darwin")
INC_DIRS += /opt/local/include
--- a/Source/Tools/NiViewer/Makefile
+++ b/Source/Tools/NiViewer/Makefile
@@ -26,7 +26,7 @@
endif

LIB_DIRS += ../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG)
-USED_LIBS += OpenNI2 XnLib pthread
+USED_LIBS += OpenNI2 XnLib pthread jpeg

EXE_NAME = NiViewer

--- a/Source/Drivers/PSLink/PSLinkConsole/Makefile
+++ b/Source/Drivers/PSLink/PSLinkConsole/Makefile
@@ -15,7 +15,7 @@
../*.cpp \

LIB_DIRS = ../../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG)
-USED_LIBS = OpenNI2 XnLib dl pthread
+USED_LIBS = OpenNI2 XnLib dl pthread jpeg

ifeq ("$(OSTYPE)","Darwin")
INC_DIRS += /opt/local/include
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From 9ae6d6ca4e8a3e17149d307bf97e5d0ac0f931d0 Mon Sep 17 00:00:00 2001
From: Hauke Wintjen <[email protected]>
Date: Wed, 30 Jan 2013 21:38:18 +0100
Subject: [PATCH] Added Armv6l as new target platform

---
ThirdParty/PSCommon/BuildSystem/CommonDefs.mak | 2 +
ThirdParty/PSCommon/BuildSystem/Platform.Armv6l | 14 ++++
3 files changed, 118 insertions(+)
create mode 100644 ThirdParty/PSCommon/BuildSystem/Platform.Armv6l

--- a/ThirdParty/PSCommon/BuildSystem/CommonDefs.mak
+++ b/ThirdParty/PSCommon/BuildSystem/CommonDefs.mak
@@ -16,6 +16,8 @@
HOST_PLATFORM = x86
else ifneq (,$(findstring i386,$(MACHINE)))
HOST_PLATFORM = x86
+else ifneq (,$(findstring armv6l,$(MACHINE)))
+ HOST_PLATFORM = Armv6l
else ifneq (,$(findstring arm,$(MACHINE)))
HOST_PLATFORM = Arm
else
--- /dev/null
+++ b/ThirdParty/PSCommon/BuildSystem/Platform.Armv6l
@@ -0,0 +1,16 @@
+# Platform defs for Raspberry PI Hard floats
+export GLUT_SUPPORTED=1
+
+ifeq "$(CFG)" "Release"
+
+ # Hardware specifying flags
+ # hardfp is now default, so no extra flags needed
+ # CFLAGS += -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard
+
+ # Optimization level, minus currently buggy optimizing methods (which break bit-exact)
+ CFLAGS += -O3 -fno-tree-pre -fno-strict-aliasing
+
+ # More optimization flags
+ CFLAGS += -ftree-vectorize -ffast-math -funsafe-math-optimizations -fsingle-precision-constant
+
+endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From: Jochen Sprickerhof <[email protected]>
Date: Tue, 7 Feb 2017 17:30:41 +0100
Subject: fix format-overflow for GCC7

---
Source/Drivers/PS1080/Sensor/XnFrameStreamProcessor.cpp | 4 ++--
Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.cpp | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Source/Drivers/PS1080/Sensor/XnFrameStreamProcessor.cpp b/Source/Drivers/PS1080/Sensor/XnFrameStreamProcessor.cpp
index 9663e41..62cf1c7 100644
--- a/Source/Drivers/PS1080/Sensor/XnFrameStreamProcessor.cpp
+++ b/Source/Drivers/PS1080/Sensor/XnFrameStreamProcessor.cpp
@@ -40,8 +40,8 @@ XnFrameStreamProcessor::XnFrameStreamProcessor(XnFrameStream* pStream, XnSensorS
m_nLastSOFPacketID(0),
m_nFirstPacketTimestamp(0)
{
- sprintf(m_csInDumpMask, "%sIn", pStream->GetType());
- sprintf(m_csInternalDumpMask, "Internal%s", pStream->GetType());
+ snprintf(m_csInDumpMask, 100, "%.90sIn", pStream->GetType());
+ snprintf(m_csInternalDumpMask, 100, "Internal%.90s", pStream->GetType());
m_InDump = xnDumpFileOpen(m_csInDumpMask, "%s_0.raw", m_csInDumpMask);
m_InternalDump = xnDumpFileOpen(m_csInternalDumpMask, "%s_0.raw", m_csInternalDumpMask);
}
diff --git a/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.cpp b/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.cpp
index f93f333..d962ec0 100644
--- a/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.cpp
+++ b/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.cpp
@@ -263,7 +263,7 @@ XnStatus XnSensorFirmwareParams::AddFirmwareParam(XnActualIntProperty& Property,
XN_IS_STATUS_OK(nRetVal);

XnChar csNewName[XN_DEVICE_MAX_STRING_LENGTH];
- sprintf(csNewName, "%s (%d)", Property.GetName(), nFirmwareParam);
+ snprintf(csNewName, XN_DEVICE_MAX_STRING_LENGTH, "%.150s (%d)", Property.GetName(), nFirmwareParam);

Property.UpdateName("Firmware", csNewName);
Property.SetLogSeverity(XN_LOG_VERBOSE);
Loading

0 comments on commit 6c80703

Please sign in to comment.