Permalink
Browse files

firebreath plugin push

  • Loading branch information...
1 parent 4db4bfe commit 33c3fc799abc13c43c47f9cd76a758a0dcbf247a @royshil royshil committed Jan 26, 2012
Showing with 1,484 additions and 1 deletion.
  1. +0 −1 firebreath-plugin
  2. +40 −0 firebreath-plugin/CMakeLists.txt
  3. +58 −0 firebreath-plugin/Debug/depthjsplugin.plugin/Contents/Info.plist
  4. BIN firebreath-plugin/Debug/depthjsplugin.plugin/Contents/MacOS/depthjsplugin
  5. +4 −0 firebreath-plugin/Debug/depthjsplugin.plugin/Contents/Resources/English.lproj/InfoPlist.strings
  6. BIN firebreath-plugin/Debug/depthjsplugin.plugin/Contents/Resources/English.lproj/Localized.rsrc
  7. +23 −0 firebreath-plugin/Debug/depthjsplugin.plugin/Contents/Resources/Sample-Tracking.xml
  8. +55 −0 firebreath-plugin/Factory.cpp
  9. +11 −0 firebreath-plugin/HandMessageListener.cpp
  10. +156 −0 firebreath-plugin/HandMessageListener.h
  11. +12 −0 firebreath-plugin/Mac/ResourceRecovery.mm
  12. +60 −0 firebreath-plugin/Mac/bundle_template/Info.plist
  13. +4 −0 firebreath-plugin/Mac/bundle_template/InfoPlist.strings
  14. +20 −0 firebreath-plugin/Mac/bundle_template/Localized.r
  15. +61 −0 firebreath-plugin/Mac/projectDef.cmake
  16. +59 −0 firebreath-plugin/PluginConfig.cmake
  17. +1 −0 firebreath-plugin/ResourceRecovery.h
  18. +76 −0 firebreath-plugin/Win/WiX/depthjspluginInstaller.wxs
  19. +73 −0 firebreath-plugin/Win/projectDef.cmake
  20. +32 −0 firebreath-plugin/X11/projectDef.cmake
  21. +142 −0 firebreath-plugin/depthjsplugin.cpp
  22. +63 −0 firebreath-plugin/depthjsplugin.h
  23. +177 −0 firebreath-plugin/depthjspluginAPI.cpp
  24. +63 −0 firebreath-plugin/depthjspluginAPI.h
  25. +273 −0 firebreath-plugin/openni_backend.cpp
  26. +21 −0 firebreath-plugin/openni_backend.hpp
View
@@ -0,0 +1,40 @@
+#/**********************************************************\
+#
+# Auto-generated CMakeLists.txt for the DepthJS Plugin project
+#
+#\**********************************************************/
+
+# Written to work with cmake 2.6
+cmake_minimum_required (VERSION 2.6)
+set (CMAKE_BACKWARDS_COMPATIBILITY 2.6)
+
+Project(${PLUGIN_NAME})
+
+file (GLOB GENERAL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ [^.]*.cpp
+ [^.]*.h
+ [^.]*.hpp
+ [^.]*.cmake
+ )
+
+include_directories(${PLUGIN_INCLUDE_DIRS})
+
+# Generated files are stored in ${GENERATED} by the project configuration
+SET_SOURCE_FILES_PROPERTIES(
+ ${GENERATED}
+ PROPERTIES
+ GENERATED 1
+ )
+
+SOURCE_GROUP(Generated FILES
+ ${GENERATED}
+ )
+
+SET( SOURCES
+ ${GENERAL}
+ ${GENERATED}
+ )
+
+# This will include Win/projectDef.cmake, X11/projectDef.cmake, Mac/projectDef
+# depending on the platform
+include_platform()
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>depthjsplugin</string>
+ <key>CFBundleGetInfoString</key>
+ <string>depthjsplugin 1.0.0.0, Copyright 2012 MIT Media Lab</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.depthjspluginLib.DepthJS Plugin</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>BRPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>depthjsplugin 1.0.0.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0.0.0</string>
+ <key>CFPlugInDynamicRegisterFunction</key>
+ <string></string>
+ <key>CFPlugInDynamicRegistration</key>
+ <string>NO</string>
+ <key>CFPlugInFactories</key>
+ <dict>
+ <key>00000000-0000-0000-0000-000000000000</key>
+ <string>MyFactoryFunction</string>
+ </dict>
+ <key>CFPlugInTypes</key>
+ <dict>
+ <key>00000000-0000-0000-0000-000000000000</key>
+ <array>
+ <string>00000000-0000-0000-0000-000000000000</string>
+ </array>
+ </dict>
+ <key>CFPlugInUnloadFunction</key>
+ <string></string>
+ <key>WebPluginDescription</key>
+ <string>The native plugin part of the DepthJS project</string>
+ <key>WebPluginMIMETypes</key>
+ <dict>
+ <key>application/x-depthjsplugin</key>
+ <dict>
+ <key>WebPluginExtensions</key>
+ <array>
+ <string></string>
+ </array>
+ <key>WebPluginTypeDescription</key>
+ <string>The native plugin part of the DepthJS project</string>
+ </dict>
+ </dict>
+ <key>WebPluginName</key>
+ <string>DepthJS Plugin</string>
+</dict>
+</plist>
@@ -0,0 +1,4 @@
+/* Localized versions of Info.plist keys */
+
+CFBundleName = "depthjsplugin.plugin";
+NSHumanReadableCopyright = "Copyright 2012 MIT Media Lab";
@@ -0,0 +1,23 @@
+<OpenNI>
+ <Licenses>
+ <License vendor="PrimeSense" key="insert key here"/>
+ </Licenses>
+ <Log writeToConsole="true" writeToFile="false">
+ <!-- 0 - Verbose, 1 - Info, 2 - Warning, 3 - Error (default) -->
+ <LogLevel value="3"/>
+ <Masks>
+ <Mask name="ALL" on="false"/>
+ </Masks>
+ <Dumps>
+ </Dumps>
+ </Log>
+ <ProductionNodes>
+ <Node type="Depth">
+ <Configuration>
+ <Mirror on="true"/>
+ </Configuration>
+ </Node>
+ <Node type="Gesture" />
+ <Node type="Hands" />
+ </ProductionNodes>
+</OpenNI>
@@ -0,0 +1,55 @@
+/**********************************************************\
+
+ Auto-generated Factory.cpp
+
+ This file contains the auto-generated factory methods
+ for the depthjsplugin project
+
+\**********************************************************/
+
+#include "FactoryBase.h"
+#include "depthjsplugin.h"
+#include <boost/make_shared.hpp>
+
+class PluginFactory : public FB::FactoryBase
+{
+public:
+ ///////////////////////////////////////////////////////////////////////////////
+ /// @fn FB::PluginCorePtr createPlugin(const std::string& mimetype)
+ ///
+ /// @brief Creates a plugin object matching the provided mimetype
+ /// If mimetype is empty, returns the default plugin
+ ///////////////////////////////////////////////////////////////////////////////
+ FB::PluginCorePtr createPlugin(const std::string& mimetype)
+ {
+ return boost::make_shared<depthjsplugin>();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////
+ /// @see FB::FactoryBase::globalPluginInitialize
+ ///////////////////////////////////////////////////////////////////////////////
+ void globalPluginInitialize()
+ {
+ depthjsplugin::StaticInitialize();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////
+ /// @see FB::FactoryBase::globalPluginDeinitialize
+ ///////////////////////////////////////////////////////////////////////////////
+ void globalPluginDeinitialize()
+ {
+ depthjsplugin::StaticDeinitialize();
+ }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+/// @fn getFactoryInstance()
+///
+/// @brief Returns the factory instance for this plugin module
+///////////////////////////////////////////////////////////////////////////////
+FB::FactoryBasePtr getFactoryInstance()
+{
+ static boost::shared_ptr<PluginFactory> factory = boost::make_shared<PluginFactory>();
+ return factory;
+}
+
@@ -0,0 +1,11 @@
+/*
+ * HandMessageListener.cpp
+ * OpenniTry
+ *
+ * Created by Roy Shilkrot on 9/30/11.
+ * Copyright 2011 MIT. All rights reserved.
+ *
+ */
+
+#include "HandMessageListener.h"
+
@@ -0,0 +1,156 @@
+/*
+ * HandMessageListener.h
+ * OpenniTry
+ *
+ * Created by Roy Shilkrot on 9/30/11.
+ * Copyright 2011 MIT. All rights reserved.
+ *
+ */
+
+#ifndef _HANDMESSAGELISTENER_H
+#define _HANDMESSAGELISTENER_H
+
+#include <XnCppWrapper.h>
+#include <XnVPointControl.h>
+#include <XnVFlowRouter.h>
+#include <XnVSwipeDetector.h>
+#include <XnVSelectableSlider1D.h>
+#include <XnVSteadyDetector.h>
+#include <XnVBroadcaster.h>
+#include <XnVPushDetector.h>
+#include <XnVWaveDetector.h>
+#include <XnVSessionManager.h>
+#include <XnVCircleDetector.h>
+
+#include <sstream>
+using namespace std;
+
+void send_event(const string& etype, const string& edata);
+void send_log(const std::string& s);
+
+class HandPointControl : public XnVPointControl {
+public:
+ HandPointControl(xn::DepthGenerator depthGenerator, XnVSessionManager* sessionManager):m_DepthGenerator(depthGenerator),m_SessionManager(sessionManager) {
+// m_pInnerFlowRouter = new XnVFlowRouter;
+ m_pPushDetector = new XnVPushDetector;
+ m_pSwipeDetector = new XnVSwipeDetector;
+ m_pSwipeDetector->SetMotionSpeedThreshold(0.8); //swipes should be faster then regular movement
+// m_pSteadyDetector = new XnVSteadyDetector;
+// m_pWaveDetector = new XnVWaveDetector;
+ m_pCircleDetector = new XnVCircleDetector;
+ m_pCircleDetector->SetMinRadius(80); //circles should be big enough to prevent confusion with random movement
+
+// m_pInnerFlowRouter->SetActive(m_pPushDetector);
+
+ // Add the push detector and flow manager to the broadcaster
+// m_Broadcaster.AddListener(m_pInnerFlowRouter);
+// m_Broadcaster.AddListener(m_pPushDetector);
+
+ // Push
+ m_pPushDetector->RegisterPush(this, &Push_Pushed);
+ m_pCircleDetector->RegisterCircle(this, &ACircle);
+ //m_pWaveDetector->RegisterWave(this, &Wave_Waved);
+ m_pSwipeDetector->RegisterSwipeLeft(this, &Swipe_Left);
+ m_pSwipeDetector->RegisterSwipeRight(this, &Swipe_Right);
+ m_pSwipeDetector->RegisterSwipeUp(this, &Swipe_Up);
+ m_pSwipeDetector->RegisterSwipeDown(this, &Swipe_Down);
+
+ send_log("HandPointControl() DONE");
+ }
+
+ void Update(XnVMessage* pMessage)
+ {
+ XnVPointControl::Update(pMessage);
+ //m_Broadcaster.Update(pMessage);
+ m_pPushDetector->Update(pMessage);
+// m_pWaveDetector->Update(pMessage);
+ m_pCircleDetector->Update(pMessage);
+ m_pSwipeDetector->Update(pMessage);
+ }
+
+ static void XN_CALLBACK_TYPE Swipe_Left(XnFloat fVelocity, XnFloat fAngle, void* pUserCxt) {
+ send_event("SwipeLeft", "");
+ }
+ static void XN_CALLBACK_TYPE Swipe_Right(XnFloat fVelocity, XnFloat fAngle, void* pUserCxt) {
+ send_event("SwipeRight", "");
+ }
+ static void XN_CALLBACK_TYPE Swipe_Up(XnFloat fVelocity, XnFloat fAngle, void* pUserCxt) {
+ send_event("SwipeUp", "");
+ }
+ static void XN_CALLBACK_TYPE Swipe_Down(XnFloat fVelocity, XnFloat fAngle, void* pUserCxt) {
+ send_event("SwipeDown", "");
+ }
+
+ // Push detector
+ static void XN_CALLBACK_TYPE Push_Pushed(XnFloat fVelocity, XnFloat fAngle, void* cxt)
+ {
+ printf("Push!\n");
+ send_event("Push", "");
+ }
+
+ static void XN_CALLBACK_TYPE ACircle(XnFloat fTimes, XnBool bConfident, const XnVCircle* pCircle, void* cxt) {
+ if(bConfident) {
+ printf("Bye Bye!\n");
+ ((HandPointControl*)cxt)->KillSession();
+ }
+ }
+
+ // Wave detector
+ static void XN_CALLBACK_TYPE Wave_Waved(void* cxt)
+ {
+ printf("Bye Bye!\n");
+ ((HandPointControl*)cxt)->KillSession();
+ }
+
+ void KillSession() { m_SessionManager->EndSession(); }
+
+ /**
+ * Handle creation of a new point
+ */
+ void OnPointCreate(const XnVHandPointContext* cxt) {
+ printf("** %d\n", cxt->nID);
+ send_event("Register", "");
+ }
+
+ /**
+ * Handle new position of an existing point
+ */
+ void OnPointUpdate(const XnVHandPointContext* cxt) {
+ // positions are kept in projective coordinates, since they are only used for drawing
+ XnPoint3D ptProjective(cxt->ptPosition);
+
+// printf("Point (%f,%f,%f)", ptProjective.X, ptProjective.Y, ptProjective.Z);
+ m_DepthGenerator.ConvertRealWorldToProjective(1, &ptProjective, &ptProjective);
+// printf(" -> (%f,%f,%f)\n", ptProjective.X, ptProjective.Y, ptProjective.Z);
+
+ //move to [0->100,0->100,0->2048]
+ stringstream ss;
+ ss << "\"x\":" << (int)(100.0*ptProjective.X/640.0)
+ << ",\"y\":" << (int)(100.0*ptProjective.Y/480.0)
+ << ",\"z\":" << (int)ptProjective.Z;
+ //cout << "move: " << ss.str() << endl;
+ send_event("Move", ss.str());
+ }
+
+ /**
+ * Handle destruction of an existing point
+ */
+ void OnPointDestroy(XnUInt32 nID) {
+ printf("OnPointDestroy\n");
+ send_event("Unregister", "");
+ }
+private:
+ xn::DepthGenerator m_DepthGenerator;
+ XnVSessionManager* m_SessionManager;
+
+// XnVBroadcaster m_Broadcaster;
+ XnVPushDetector* m_pPushDetector;
+ XnVSwipeDetector* m_pSwipeDetector;
+// XnVSteadyDetector* m_pSteadyDetector;
+// XnVFlowRouter* m_pInnerFlowRouter;
+//
+// XnVWaveDetector* m_pWaveDetector;
+ XnVCircleDetector* m_pCircleDetector;
+};
+
+#endif
@@ -0,0 +1,12 @@
+#include <CoreFoundation/CoreFoundation.h>
+#include "../gen/global/config.h"
+#include <string>
+
+std::string getResourcesDirectory() {
+ // Get the XML file for OpenNI from the resources directory of the plugin bundle
+ CFBundleRef bundleRef = CFBundleGetBundleWithIdentifier(CFSTR("com.depthjspluginLib.DepthJS Plugin"));
+ CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundleRef);
+ UInt8 cbuf[1024] = {0};
+ CFURLGetFileSystemRepresentation(resourcesURL,true,cbuf,1024);
+ return std::string((char*)cbuf);
+}
Oops, something went wrong.

0 comments on commit 33c3fc7

Please sign in to comment.