public void flushColor(KinectAdapter adapter, byte[] colorPixels) { if (this._config.ColorStreamFlush) { this.colorPixelList.Add(colorPixels); if (this.colorPixelList.Count > this._config.ColorStreamFlushSize) { List <byte[]> serializeList = new List <byte[]>(colorPixelList); string flushPath = Path.Combine(this.ColorStreamPath, (this.colorFlushCount.ToString() + ".json")); try { using (StreamWriter sw = new StreamWriter(flushPath)) using (JsonWriter writer = new JsonTextWriter(sw)) { serializer.Serialize(writer, serializeList); } } catch (Exception e) { Logger.Error("Error occured during flushing Color: {0}", e.ToString()); } this.colorFlushCount += 1; // Clear List this.colorPixelList.Clear(); } } }
public void flushDepth(KinectAdapter adapter, DepthImagePixel[] depthImage) { if (this._config.DepthStreamFlush) { this.depthList.Add(depthImage); if (this.depthList.Count >= this._config.DepthStreamFlushSize) { // freeze to serialize List <DepthImagePixel[]> serializeList = new List <DepthImagePixel[]>(depthList); string flushPath = Path.Combine(this.DepthStreamPath, (this.depthFlushCount.ToString() + ".json")); try { using (StreamWriter sw = new StreamWriter(flushPath)) using (JsonWriter writer = new JsonTextWriter(sw)) { serializer.Serialize(writer, serializeList); } } catch (Exception e) { Logger.Error("Error occured during flushing Depth: {0}", e.ToString()); } this.depthFlushCount += 1; // Clear the List this.depthList.Clear(); } } }
public KinectOutputHandler(IConfigurationService configurationService, Configuration.Adapter _config, KinectAdapter adapter) { this._configurationService = configurationService; this._config = _config; this.adapter = adapter; this.DataDir = Path.Combine(this._configurationService.GetConfiguration().HomeDir, this._config.DataDir); this.ColorStreamPath = Path.Combine(this.DataDir, this._config.ColorStreamFlushDir); this.DepthStreamPath = Path.Combine(this.DataDir, this._config.DepthStreamFlushDir); this.SkeletonStreamPath = Path.Combine(this.DataDir, this._config.SkeletonStreamFlushDir); // Subscribe Frame Available Event this.adapter.FrameAvailable += flushFrames; // Subscribe to DepthAvailable Event this.adapter.DepthFramAvailable += flushDepth; // Subscribe to ColorAvailable Event this.adapter.ColorFramAvailable += flushColor; // Check if the DataDirectory exists if (!(Directory.Exists(this.DataDir))) { // Create the DataDirectory Directory.CreateDirectory(this.DataDir); } // ColorStream if (this._config.ColorStreamEnabled && this._config.ColorStreamFlush) { if (!Directory.Exists(this.ColorStreamPath)) { Directory.CreateDirectory(this.ColorStreamPath); } } // DepthStream if (this._config.DepthStreamEnabled && this._config.DepthStreamFlush) { if (!Directory.Exists(this.DepthStreamPath)) { Directory.CreateDirectory(this.DepthStreamPath); } } // SkeletonStream if (this._config.SkeletonStreamFlush) { if (!Directory.Exists(this.SkeletonStreamPath)) { Directory.CreateDirectory(this.SkeletonStreamPath); } } }
public KinectEventHandler(KinectAdapter adapter, Configuration.Adapter _config) { this._config = _config; this.adapter = adapter; }