Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'peekFrame' to the API #163

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Include/OniCAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ ONI_C_API OniStatus oniStreamStart(OniStreamHandle stream);
/** Stop generating data from the stream. */
ONI_C_API void oniStreamStop(OniStreamHandle stream);

/** Send to handler the current frame held by the stream without any side effect or blocking. For use in an onNewFrame() callback and after a successful oniWaitForStreams(). */
ONI_C_API OniStatus oniStreamPeekFrame(OniStreamHandle stream, OniProcessFrameCallback handler, void* pCookie);

/** Get the next frame from the stream. This function is blocking until there is a new frame from the stream. For timeout, use oniWaitForStreams() first */
ONI_C_API OniStatus oniStreamReadFrame(OniStreamHandle stream, OniFrame** pFrame);

Expand Down
1 change: 1 addition & 0 deletions Include/OniCTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ typedef struct
} OniFrame;

typedef void (ONI_CALLBACK_TYPE* OniNewFrameCallback)(OniStreamHandle stream, void* pCookie);
typedef void (ONI_CALLBACK_TYPE* OniProcessFrameCallback)(OniFrame* frame, void* pCookie);
typedef void (ONI_CALLBACK_TYPE* OniGeneralCallback)(void* pCookie);
typedef void (ONI_CALLBACK_TYPE* OniDeviceInfoCallback)(const OniDeviceInfo* pInfo, void* pCookie);
typedef void (ONI_CALLBACK_TYPE* OniDeviceStateCallback)(const OniDeviceInfo* pInfo, OniDeviceState deviceState, void* pCookie);
Expand Down
6 changes: 3 additions & 3 deletions Include/OniVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include "OniPlatform.h"

#define ONI_VERSION_MAJOR 2
#define ONI_VERSION_MINOR 2
#define ONI_VERSION_MAINTENANCE 0
#define ONI_VERSION_BUILD 33
#define ONI_VERSION_MINOR 3
#define ONI_VERSION_MAINTENANCE 2
#define ONI_VERSION_BUILD 0

/** OpenNI version (in brief string format): "Major.Minor.Maintenance (Build)" */
#define ONI_BRIEF_VERSION_STRING \
Expand Down
44 changes: 31 additions & 13 deletions Include/OpenNI.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ class VideoMode : private OniVideoMode
@param [in] resolutionX Desired new horizontal resolution in pixels.
@param [in] resolutionY Desired new vertical resolution in pixels.
*/
void setResolution(int resolutionX, int resolutionY)
void setResolution(int _resolutionX, int _resolutionY)
{
this->resolutionX = resolutionX;
this->resolutionY = resolutionY;
this->resolutionX = _resolutionX;
this->resolutionY = _resolutionY;
}

/**
Expand All @@ -287,7 +287,7 @@ class VideoMode : private OniVideoMode
video modes.
@param [in] fps Desired new frame rate, measured in frames per second.
*/
void setFps(int fps) { this->fps = fps; }
void setFps(int _fps) { this->fps = _fps; }

friend class SensorInfo;
friend class VideoStream;
Expand Down Expand Up @@ -596,11 +596,12 @@ class VideoFrameRef
/** @internal */
void _setFrame(OniFrame* pFrame)
{
setReference(pFrame);
if (pFrame != NULL)
{
oniFrameAddRef(pFrame);
}
release();
m_pFrame = pFrame;
}

/** @internal */
Expand All @@ -611,11 +612,10 @@ class VideoFrameRef

private:
friend class VideoStream;
inline void setReference(OniFrame* pFrame)
static void ONI_CALLBACK_TYPE setReference(OniFrame* pFrame, void* pCookie)
{
// Initial - don't addref. This is the reference from OpenNI
release();
m_pFrame = pFrame;
VideoFrameRef* pRef = (VideoFrameRef*)pCookie;
pRef->_setFrame(pFrame);
}

OniFrame* m_pFrame; // const!!?
Expand Down Expand Up @@ -800,16 +800,34 @@ class VideoStream
}

/**
Read the next frame from this video stream, delivered as a @ref VideoFrameRef. This is the primary
method for manually obtaining frames of video data.
Get the current frame from this video stream without any side effect or blocking, delivered as a @ref VideoFrameRef.
Call this after using @ref OpenNI::waitForAnyStream() to wait for new frames from several streams.
Alternatively, use @ref VideoStream::Listener to implement an event driven architecture
and call this in the callback method to get the frame from the stream.

@param [out] pFrame Pointer to a @ref VideoFrameRef object to hold the reference to the new frame.
@returns Status code to indicated success or failure of this function.
*/
Status peekFrame(VideoFrameRef* pFrameRef)
{
if (!isValid())
{
return STATUS_ERROR;
}

return (Status)oniStreamPeekFrame(m_stream, VideoFrameRef::setReference, pFrameRef);
}

/**
Read the next frame from this video stream, delivered as a @ref VideoFrameRef.
If no new frame is available, the call will block until one is available.
To avoid blocking, use @ref VideoStream::Listener to implement an event driven architecture. Another
alternative is to use @ref OpenNI::waitForAnyStream() to wait for new frames from several streams.

@param [out] pFrame Pointer to a @ref VideoFrameRef object to hold the reference to the new frame.
@returns Status code to indicated success or failure of this function.
*/
Status readFrame(VideoFrameRef* pFrame)
Status readFrame(VideoFrameRef* pFrameRef)
{
if (!isValid())
{
Expand All @@ -819,7 +837,7 @@ class VideoStream
OniFrame* pOniFrame;
Status rc = (Status)oniStreamReadFrame(m_stream, &pOniFrame);

pFrame->setReference(pOniFrame);
VideoFrameRef::setReference(pOniFrame, pFrameRef);
return rc;
}

Expand Down
4 changes: 2 additions & 2 deletions Packaging/Harvest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def copySharedObject(self, sourceDir, name, targetDir):
elif self.osName == 'Darwin':
shutil.copy(os.path.join(sourceDir, 'lib' + name + '.dylib'), targetDir)
else:
raise 'Unsupported platform!'
raise Execption('Unsupported platform!')

def copyExecutable(self, sourceDir, name, targetDir):
if self.osName == 'Windows':
Expand Down Expand Up @@ -335,7 +335,7 @@ def run(self):
shutil.copy(os.path.join(self.rootDir, 'Packaging', 'Linux', 'primesense-usb.rules'), self.outDir)

if len(sys.argv) < 3:
print 'Usage: ' + sys.argv[0] + ' <OutDir> <x86|x64|Arm>'
print('Usage: ' + sys.argv[0] + ' <OutDir> <x86|x64|Arm>')
exit(1)

rootDir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
Expand Down
6 changes: 3 additions & 3 deletions Packaging/Install/Includes/Variables.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
It's not enough to just include newer files.
-->
<?define MajorVersion=2?>
<?define MinorVersion=2?>
<?define MinorVersion=3?>
<?define MaintenanceVersion=0?>
<!-- BuildVersion is NOT used by WiX in the upgrade procedure -->
<?define BuildVersion=33?>
<?define BuildVersion=2?>
<!-- Full version number to display -->
<?define VersionNumber="$(var.MajorVersion).$(var.MinorVersion).$(var.MaintenanceVersion).$(var.BuildVersion)"?>
<?define VersionName="2.2"?>
<?define VersionName="2.3"?>

<!--
Path to the resources directory. resources don't really need to be included
Expand Down
2 changes: 1 addition & 1 deletion Packaging/Install/Install.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ProductVersion>3.5</ProductVersion>
<ProjectGuid>{baeb9c48-562c-4d56-a6cd-18932265480a}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>OpenNI-Windows-$(Platform)-2.2</OutputName>
<OutputName>OpenNI-Windows-$(Platform)-2.3</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
Expand Down
14 changes: 7 additions & 7 deletions Packaging/ReleaseVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import UpdateVersion

if len(sys.argv) < 2 or sys.argv[1] in ('-h','--help'):
print "usage: " + sys.argv[0] + " <x86|x64|Arm|android> [UpdateVersion]"
print("usage: " + sys.argv[0] + " <x86|x64|Arm|android> [UpdateVersion]")
sys.exit(1)

plat = sys.argv[1]
Expand Down Expand Up @@ -89,14 +89,14 @@ def calc_jobs_number():

# Create installer
strVersion = UpdateVersion.getVersionName()
print "Creating installer for OpenNI " + strVersion + " " + plat
print("Creating installer for OpenNI " + strVersion + " " + plat)
finalDir = "Final"
if not os.path.isdir(finalDir):
os.mkdir(finalDir)

if plat == 'android':
if not 'NDK_ROOT' in os.environ:
print 'Please define NDK_ROOT!'
print('Please define NDK_ROOT!')
sys.exit(2)

ndkDir = os.environ['NDK_ROOT']
Expand All @@ -115,7 +115,7 @@ def calc_jobs_number():
shutil.copy('../Application.mk', buildDir + '/jni')
rc = subprocess.call([ ndkDir + '/ndk-build', '-C', buildDir, '-j8' ])
if rc != 0:
print 'Build failed!'
print('Build failed!')
sys.exit(3)

finalFile = finalDir + '/' + outputDir + '.tar'
Expand Down Expand Up @@ -174,12 +174,12 @@ def calc_jobs_number():
os.remove(origDir + '/build.release.' + plat + '.log')

else:
print "Unknown OS"
print("Unknown OS")
sys.exit(2)

# also copy Release Notes and CHANGES documents
shutil.copy('../ReleaseNotes.txt', finalDir)
shutil.copy('../CHANGES.txt', finalDir)

print "Installer can be found under: " + finalDir
print "Done"
print("Installer can be found under: " + finalDir)
print("Done")
6 changes: 3 additions & 3 deletions Packaging/UpdateVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
from datetime import date

VERSION_MAJOR = 2
VERSION_MINOR = 2
VERSION_MINOR = 3
VERSION_MAINTENANCE = 0
VERSION_BUILD = 33
VERSION_BUILD = 0

def getVersionString():
return str(VERSION_MAJOR) + "." + str(VERSION_MINOR) + "." + str(VERSION_MAINTENANCE) + "." + str(VERSION_BUILD)
Expand Down Expand Up @@ -58,7 +58,7 @@ def update():
print ("Illegal build version")
sys.exit()

print "Going to update files to version: " + getVersionString()
print ("Going to update files to version: " + getVersionString())

update_self_defs("./UpdateVersion.py")
update_src_ver_defs("../Include/OniVersion.h")
Expand Down
4 changes: 2 additions & 2 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OpenNI 2.2.0 Build 33
November 12 2013
OpenNI 2.3.0 Build 2
August 30 2022

Minimum Requirements:
---------------------
Expand Down
4 changes: 4 additions & 0 deletions Samples/ClosestPointViewer/ClosestPointViewer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
4 changes: 4 additions & 0 deletions Samples/EventBasedRead/EventBasedRead.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
4 changes: 4 additions & 0 deletions Samples/MWClosestPoint/MWClosestPoint.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
4 changes: 4 additions & 0 deletions Samples/MWClosestPointApp/MWClosestPointApp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
4 changes: 4 additions & 0 deletions Samples/MultiDepthViewer/MultiDepthViewer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
Loading