 //    -1 , 0, 0, 1];
 
 class OSBaseFrame : OSContentLoadingProtocol{
-//    let image : UIImage;
-//    var height : Int{
-//        get {
-//            return (Int)(self.image.size.height);
+    let image : UIImage;
+    var height : Int{
+        get {
+            return (Int)(self.image.size.height);
+        }
+    }
+    var width : Int{
+        get{
+            return (Int)(self.image.size.width);
+        }
+    }
+//    private (set) var calibratedDepth : [Float];
+    private var notCalibratedDepth: [Float]?;
+    
+    var pointCloud : [OSPoint]?;
+    
+    init(image :UIImage, depth: [Float]){
+        let size : Int = (Int)(image.size.width) * (Int)(image.size.height)
+
+        assert(size == depth.count, "depth frame and image must be equal size");
+        
+        self.image = image;
+        self.notCalibratedDepth = depth;
+//        self.calibratedDepth = [Float](count: depth.count, repeatedValue: -1.0);//-1 will be the invalid depth data value
+        self.pointCloud = [OSPoint](count: size, repeatedValue: OSPoint());
+    }
+    
+    subscript(row : Int, col : Int) -> OSPoint{
+        get {
+            return (self.pointCloud?[row * self.width + col])!;
+        }
+//        set (newValue) {
+//            self.pointCloud[row * self.width + col] = newValue;
 //        }
-//    }
-//    var width : Int{
-//        get{
-//            return (Int)(self.image.size.width);
-//        }
-//    }
-//    private (set) var calibratedDepth : [Float];
-    private var notCalibratedDepth: [Float] = [Float](count: dummyDataSize, repeatedValue: -1.0);
+    }
     
-    var pointCloud : [OSPoint] = [OSPoint](count: dummyDataSize, repeatedValue: OSPoint());
-    
-//    init(image :UIImage, depth: [Float]){
-//        var size : Int = (Int)(image.size.width) * (Int)(image.size.height)
-//
-//        assert(size == depth.count, "depth frame and image must be equal size");
-//        
-//        self.image = image;
-//        self.notCalibratedDepth = depth;
-//        self.calibratedDepth = [Float](count: depth.count, repeatedValue: -1.0);//-1 will be the invalid depth data value
-//        self.pointCloud = [OSPoint](count: size, repeatedValue: OSPoint());
-//        
-//        self.prepareMetalForSurgery();
-//    }
-    
-//    subscript(row : Int, col : Int) -> OSPoint{
-//        get {
-//            return self.pointCloud[row * self.width + col];
-//        }
-////        set (newValue) {
-////            self.pointCloud[row * self.width + col] = newValue;
-////        }
-//    }
-    
-    //MARK: Metal
+//MARK: Metal
     
     static private let device : MTLDevice = MTLCreateSystemDefaultDevice()!;
     static private let commandQueue : MTLCommandQueue = device.newCommandQueue();

    private var commandBuffer : MTLCommandBuffer?;
    private var computeCommandEncoder : MTLComputeCommandEncoder?;
    
    private func prepareMetalForSurgery()
    {
        let startTime = CACurrentMediaTime();
        

        
        self.computeCommandEncoder?.endEncoding();
        
        self.commandBuffer?.addCompletedHandler({[unowned self] (commandBuffer : MTLCommandBuffer) -> Void in
            let data = NSData(bytesNoCopy: outputBuffer.contents(), length: (self.pointCloud?.count)! * sizeof(OSPoint), freeWhenDone: false);
            data.getBytes(&self.pointCloud, length: outputByteLength);
            
            let elapsedTime : CFTimeInterval = CACurrentMediaTime() - startTime;
            print("Total process \(elapsedTime) seconds");
            
            completionHandler?();
        });
        
        self.commandBuffer?.commit();
    }
    
// MARK: OSContentLoadingProtocol

    static func loadContent(completionHandler : (() -> Void)!)
    {
