Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updates to wrapper

  • Loading branch information...
commit e806214797e8dc6190cc360fa345c1fd53b68dcb 1 parent d115f97
@elliotwoods authored
Showing with 81 additions and 19 deletions.
  1. +2 −2 NPCameraSDKDotNet.sln
  2. +6 −4 NPCameraSDKDotNet.vcxproj
  3. +73 −13 Wrapper.cpp
View
4 NPCameraSDKDotNet.sln
@@ -1,6 +1,6 @@

-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NPCameraSDKDotNet", "NPCameraSDKDotNet.vcxproj", "{D04530D4-58C9-476E-8249-30CCEB669D63}"
EndProject
Global
View
10 NPCameraSDKDotNet.vcxproj
@@ -17,7 +17,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
@@ -51,6 +51,7 @@
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<LinkIncremental>false</LinkIncremental>
+ <TargetExt>.dll</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -77,15 +78,15 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
- <AdditionalIncludeDirectories>..\..\..\cameracommon;..\..;..\..\..\common\inc;..\..\..\..\drivers\USBIO\V2.41\source\usbiolib;..\..\..\..\drivers\USBIO\V2.41\source\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>C:\Program Files %28x86%29\OptiTrack\Camera SDK\include;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
- <AdditionalDependencies>opengl32.lib;glu32.lib;glaux.lib;ws2_32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>cameralibrary.lib;ws2_32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
@@ -93,6 +94,7 @@
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention />
<TargetMachine>MachineX86</TargetMachine>
+ <AdditionalLibraryDirectories>C:\Program Files %28x86%29\OptiTrack\Camera SDK\lib;..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
View
86 Wrapper.cpp
@@ -8,6 +8,7 @@
#include "cameralibrary.h"
using namespace CameraLibrary;
using namespace System;
+using namespace System::Runtime::InteropServices;
namespace NPCameraSDKDotNet{
@@ -80,7 +81,10 @@ namespace NPCameraSDKDotNet{
//Segment * SegmentHead();
//Segment * SegmentTail();
-
+ MObject ^ Clone(){
+ cObject * object = new cObject(*this->cobject);
+ return gcnew MObject(object);
+ }
protected:
private:
cObject * cobject;
@@ -139,17 +143,61 @@ namespace NPCameraSDKDotNet{
//unsigned char* GetGrayscaleData();
//int GetGrayscaleDataSize();
void CopyGrayScaleDataTo(IntPtr buffer) {
- memcpy(buffer.ToPointer(), frame->GetGrayscaleData(), frame->GetGrayscaleDataSize());
+ const int width = frame->GetCamera()->Width();
+ const int height = frame->GetCamera()->Height();
+ frame->Rasterize(width, height, width, 8, buffer.ToPointer());
}
-
-
protected:
private:
Frame * frame;
};
+ typedef void (__stdcall *BANG_MESSAGE)(void);
+ delegate void TakesABangDelegate();
+
+ class CameraListener : public cCameraListener {
+ public:
+ CameraListener(){
+ this->FrameAvailableCallback = 0;
+ this->FrameOverflowCallback = 0;
+ this->ButtonPressedCallback = 0;
+ }
+
+ void SetFrameAvailableCallback(BANG_MESSAGE function){
+ this->FrameAvailableCallback = function;
+ }
+
+ void SetFrameOverflowCallback(BANG_MESSAGE function){
+ this->FrameOverflowCallback = function;
+ }
+
+ void SetButtonPressedCallback(BANG_MESSAGE function){
+ this->ButtonPressedCallback = function;
+ }
+
+ void FrameAvailable(){
+ if (this->FrameAvailableCallback != 0)
+ this->FrameAvailableCallback();
+ }
+
+ void FrameOverflow(){
+ if (this->FrameOverflowCallback != 0)
+ this->FrameOverflowCallback();
+ }
+
+ void ButtonPressed(){
+ if (this->ButtonPressedCallback != 0)
+ this->ButtonPressedCallback();
+ }
+
+ protected:
+ BANG_MESSAGE FrameAvailableCallback;
+ BANG_MESSAGE FrameOverflowCallback;
+ BANG_MESSAGE ButtonPressedCallback;
+ };
+
public ref class MCamera{
//Camera();
//~Camera();
@@ -239,21 +287,32 @@ namespace NPCameraSDKDotNet{
//virtual bool IsEthernet() { return false; } //== Camera helpers =================---
//virtual bool IsTBar () { return false; } //== Camera helpers =================---
-
-
-
-
-
public:
MCamera(Camera * camera){
this->camera = camera;
-
+ this->cameraListener = new CameraListener();
+ this->camera->AttachListener(this->cameraListener);
+
+ TakesABangDelegate^ fp = gcnew TakesABangDelegate(this, & MCamera::NewFrame);
+ this->callbackHandle = GCHandle::Alloc(fp);
+ IntPtr ip = Marshal::GetFunctionPointerForDelegate(fp);
+ BANG_MESSAGE cb = static_cast<BANG_MESSAGE>(ip.ToPointer());
+ this->cameraListener->SetFrameAvailableCallback(cb);
}
+
~MCamera(){
+ callbackHandle.Free();
+ delete this->cameraListener;
delete this->camera;
}
+ event EventHandler<EventArgs^> ^ FrameAvailable;
+
+ void NewFrame(){
+ this->FrameAvailable(this, gcnew EventArgs());
+ }
+
MFrame ^ GetFrame(){
Frame * frame;
frame = camera->GetFrame();
@@ -262,7 +321,8 @@ namespace NPCameraSDKDotNet{
} else {
return gcnew MFrame(frame);
}
- }
+ }
+
MFrame ^ GetLatestFrame(){
Frame * frame;
frame = camera->GetFrame();
@@ -425,6 +485,8 @@ namespace NPCameraSDKDotNet{
protected:
private:
Camera * camera;
+ CameraListener * cameraListener;
+ GCHandle callbackHandle;
};
public ref class MCameraManager{
@@ -441,7 +503,6 @@ namespace NPCameraSDKDotNet{
return CameraManager::X().AreCamerasInitialized();
}
-
static void Shutdown(){
CameraManager::X().Shutdown();
}
@@ -462,7 +523,6 @@ namespace NPCameraSDKDotNet{
ret[c] = gcnew MCamera(CameraManager::X().GetCamera(list[c].UID()));
}
return ret;
-
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.