         // Prepare output
         let out = AVCaptureVideoDataOutput()
         out.videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: Int(kCVPixelFormatType_32BGRA)]
+        out.alwaysDiscardsLateVideoFrames = true
         let queue = dispatch_queue_create("input frames queue", DISPATCH_QUEUE_SERIAL)
         out.setSampleBufferDelegate(self, queue:queue)
         if !session.canAddOutput(out) {


    var previewLayer: AVCaptureVideoPreviewLayer?
    var frameCount = 0

    var metalDevice: MTLDevice?
    var metalLib: MTLLibrary?

        let label = "\(net!.labels[idx]) - \(prob*100)%"
        let workTime = NSDate().timeIntervalSinceDate(startTime)
        print("net.forward is done within \(workTime) sec")
        objc_sync_enter(self.running)
        self.running = false
        objc_sync_exit(self.running)

        print("GoogLeNet: \(label)")
        dispatch_async(dispatch_get_main_queue(), {
