コード例 #1
0
        internal void UpdateOptions(ref DepthDataCleanerOptions depthDataCleanerOptions, ref CloudGeneratorOptions cloudGeneratorOptions, IPointCloudSource <PointXYZConfidence> pointCloudSource)
        {
            // -- Set Generation Options
            cloudGeneratorOptions.clusterRadius = clusterRadius;
            cloudGeneratorOptions.debugDisplay  = debugDisplay;

            // -- Set DepthData Cleaner Options
            depthDataCleanerOptions.maximumNoise            = maximumNoise;
            depthDataCleanerOptions.minimumDepth            = minimumDepth;
            depthDataCleanerOptions.maximumDepth            = maximumDepth;
            depthDataCleanerOptions.minimumConfidence       = minimumConfidence;
            depthDataCleanerOptions.medianFilterSize        = medianFilterSize;
            depthDataCleanerOptions.morphologicalFilterSize = morphologicalFilterSize;
            depthDataCleanerOptions.morpholicalIteration    = morpholicalIteration;
            depthDataCleanerOptions.debugDisplay            = debugDisplay;
            depthDataCleanerOptions.cameraRotated180        = debugDisplay;



            // -- Set DepthData Cleaner Options
            HandKernelInterop.SetDepthDataCleanerOptions(ref depthDataCleanerOptions);

            // -- Set PointCloudSource Generation Options
            pointCloudSource.SetPointCloudGeneratorOptions(cloudGeneratorOptions);
        }
コード例 #2
0
        /// <summary>   Call plugin at end of frames. </summary>
        /// <returns>   An IEnumerator. </returns>
        internal IEnumerator CallPluginAtEndOfFrames()
        {
            while (true)
            {
                // Wait until all frame rendering is done
                yield return(new WaitForEndOfFrame());

                if (initlialzed && _textureCreated)
                {
                    // Set time for the plugin
                    HandKernelInterop.SetTimeFromUnity(Time.timeSinceLevelLoad);

                    // Issue a plugin event with arbitrary integer identifier.
                    // The plugin can distinguish between different
                    // things it needs to do based on this ID.
                    // For our simple plugin, it does not matter which ID we pass here.
                    GL.IssuePluginEvent(HandKernelInterop.GetRenderEventFunc(), 1);

                    if (_meshesDisabled)
                    {
                        EnableMeshObjects();
                        _meshesDisabled = false;
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>   Late update. </summary>
        private void LateUpdate()
        {
            HandKernelInterop.SetDepthDataCleanerOptions(ref depthDataCleanerOptions);

            if (_pointCloudSource != null)
            {
                _pointCloudSource.SetPointCloudGeneratorOptions(cloudGeneratorOptions);
            }
            if (_handDataSource != null)
            {
                _handDataSource.SetHandOptions(handProcessorOptions);
            }
        }
コード例 #4
0
        /// <summary>   Creates texture and pass to plugin. </summary>
        /// <param name="height">   The height. </param>
        /// <param name="width">    The width. </param>
        public void CreateTextureAndPassToPlugin(int height, int width)
        {
            // Create a texture
            tex = new Texture2D(height, width, TextureFormat.RGBAFloat, false, true);

            // Use bilinear, point caused issues with striations in the depth image
            // bilinear also causes issues but they are handled in the DepthMapOcclusion.shader
            tex.filterMode = FilterMode.Bilinear;

            // Call Apply() so it's actually uploaded to the GPU
            tex.Apply();

            // Pass texture pointer to the plugin
            HandKernelInterop.SetTextureFromUnity(tex.GetNativeTexturePtr(), height, width);
        }
コード例 #5
0
 /// <summary>  MetaBehavior Update. </summary>
 private void Update()
 {
     if (initlialzed && !_textureCreated)
     {
         currentNativeTexture.CreateTextureAndPassToPlugin((int)height, (int)width);
         InitOclussionManager();
         _textureCreated = true;
     }
     else if (!initlialzed)
     {
         if (HandKernelInterop.GetSensorMetaData(ref _sensorMetaData))
         {
             height      = (uint)_sensorMetaData.width;
             width       = (uint)_sensorMetaData.height;
             initlialzed = true;
         }
     }
 }
コード例 #6
0
 private void Update()
 {
     if (!_sensorsInitialized)
     {
         Internal.SensorMetaData sensorMetaData = new Internal.SensorMetaData();
         if (HandKernelInterop.GetSensorMetaData(ref sensorMetaData))
         {
             OnSensorInitialized();
             _sensorsInitialized = true;
         }
     }
     else if (!_initializedHandsModule)
     {
         var context = Object.FindObjectOfType <MetaContextBridge>().CurrentContext;
         context.Get <HandsModule>().Initialized = true;
         _initializedHandsModule = true;
     }
 }
コード例 #7
0
        /// <summary>   Updates the point cloud interop data from kernel. </summary>
        private void UpdatePointCloudInteropDataFromKernel()
        {
            if (_pointCloudData == null)
            {
                this.GetPointCloudMetaData();
                return;
            }
            if (!HandKernelInterop.GetPointCloudData(ref _pointCloudInteropData))
            {
                return;
            }

            Marshal.Copy(_pointCloudInteropData.data, _pointCloudVertices, 0, _pointCloudInteropData.size * (_pointCloudMetaData.pointSize / 4));

            lock (_cloudDataLock)
            {
                PointCloudData <TPoint> .ConvertFromInteropData(ref _pointCloudData, _pointCloudMetaData, _pointCloudInteropData, _pointCloudVertices);
            }
        }
コード例 #8
0
        /// <summary>   Handler, called when the new point cloud meta data. </summary>
        public void GetPointCloudMetaData()
        {
            if (!HandKernelInterop.GetPointCloudMetaData(ref _pointCloudInteropMetaData))
            {
                return;
            }
            lock (_cloudDataLock)
            {
                _pointCloudMetaData = new PointCloudMetaData(_pointCloudInteropMetaData);

                //todo: make this be able to handle data other than XYZConfidence
                //hack
                _pointCloudMetaData.field   = PointCloudDataType.XYZCONFIDENCE;           //todo: not do this.
                _pointCloudVertices         = new float[_pointCloudMetaData.maxSize * 4]; // better way to do this
                _pointCloudRawData          = new char[_pointCloudMetaData.maxSize * _pointCloudMetaData.pointSize];
                _pointCloudDataHandle       = GCHandle.Alloc(_pointCloudRawData, GCHandleType.Pinned);
                _pointCloudInteropData.data = _pointCloudDataHandle.AddrOfPinnedObject();
                _pointCloudDataHandle.Free();
                _pointCloudInteropData.valid = false;
                _pointCloudData = new PointCloudData <TPoint>(_pointCloudMetaData.maxSize);
                //end hack
            }
        }
コード例 #9
0
        /// <summary>   Sets point cloud generator options. </summary>
        ///
        /// <param name="cloudGeneratorOptions">    Options for controlling the cloud generator. </param>
        ///
        /// <returns>   true if it succeeds, false if it fails. </returns>

        public bool SetPointCloudGeneratorOptions(CloudGeneratorOptions cloudGeneratorOptions)
        {
            HandKernelInterop.SetPointCloudGeneratorOptions(ref cloudGeneratorOptions);
            return(false);
        }
コード例 #10
0
 /// <summary>   Initialises the point cloud source. </summary>
 public void InitPointCloudSource()
 {
     _newPointCloudDataHandler = this.NewPointCloudDataHandler;
     HandKernelInterop.RegisterNewPointCloudDataEventHandler(_newPointCloudDataHandler);
 }
コード例 #11
0
 /// <summary>   Awakes this object. Build Hand Consumer </summary>
 private void Awake()
 {
     //todo : generalize this
     HandKernelInterop.BuildHandConsumer(_handConsumerType);
 }