         do {
             let input = try AVCaptureDeviceInput(device: captureDevice)
             captureSession = AVCaptureSession()
-            #if swift(>=4.0)
-                captureSession.sessionPreset = AVCaptureSession.Preset.high
-            #else
-                captureSession.sessionPreset = AVCaptureSessionPresetHigh
-            #endif
+            captureSession.sessionPreset = AVCaptureSession.Preset.high
             captureSession.addInput(input)
             
             captureImageOutput = AVCaptureStillImageOutput()

        }
        var videoConnection: AVCaptureConnection? = nil
        for connection in captureImageOutput.connections {
            #if swift(>=4.0)
                if (connection.inputPorts.contains { $0.mediaType == AVMediaType.video }) {
                    videoConnection = connection
                    break
                }
                if videoConnection != nil {
                    break
                }
            #else
                if let connection = connection as? AVCaptureConnection {
                    if (connection.inputPorts.contains {
                        if let inputPort = $0 as? AVCaptureInputPort {
                            return inputPort.mediaType == AVMediaTypeVideo
                        }
                        return false
                    }) {
                        videoConnection = connection
                        break
                    }
                    if videoConnection != nil {
                        break
                    }
                }
            #endif
        }
        
        captureImageOutput.captureStillImageAsynchronously(from: videoConnection!) { (imageSampleBuffer: CMSampleBuffer?, _: Error?) -> Void in

    }
    
    // AVCaptureMetadataOutputObjectsDelegate delegate
    public func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
        if !isReading {
            isReading = true
            guard
                let metadataObj = metadataObjects.first as? AVMetadataMachineReadableCodeObject
                else { return }
            asyncMain {
                let objectFrame = UIView()
                objectFrame.backgroundColor = UIColor.clear
                
                //self.highlightView.frame = self.videoPreviewLayer.transformedMetadataObjectForMetadataObject(metadataObj).bounds
                //self.highlightView.hidden = false
                self.captureImage { image in
                    self.delegate?.codeScanner(self, didScanObject: metadataObj, screenshot: image)
                    self.stopReading()
                }
            }
        }
