hollance / Inception-CoreML

Running Inception-v3 on Core ML
97 stars 28 forks source link

improve FPS #7

Closed hakS07 closed 5 years ago

hakS07 commented 5 years ago

@hollance thanx for the project it was helpful for deeplab real-time segmentation but the capture was very slow even with desiredFrameRate = 30, I tried to improve it to 60 or 240 but i got "libc++abi.dylib: terminating with uncaught exception of type NSException" error . do you have any idea how can I solve it? ` private func configureSession() {

    guard permissionGranted else { return }

    captureSession.sessionPreset = quality

    guard let captureDevice = selectCaptureDevice() else { return }

           guard let captureDeviceInput = try? AVCaptureDeviceInput(device: captureDevice) else { 

return }

    guard captureSession.canAddInput(captureDeviceInput) else { return }  

   captureSession.addInput(captureDeviceInput)
    do {

        try captureDevice.lockForConfiguration()

        captureDevice.activeVideoMinFrameDuration = CMTimeMake(1, Int32(desiredFrameRate))

        captureDevice.activeVideoMaxFrameDuration = CMTimeMake(1, Int32(desiredFrameRate))

        captureDevice.unlockForConfiguration()
    } catch {print("dd")}

    let videoOutput = AVCaptureVideoDataOutput()

    videoOutput.setSampleBufferDelegate(self, queue: DispatchQueue(label: "sample buffer"))

    guard captureSession.canAddOutput(videoOutput) else { return }

    captureSession.addOutput(videoOutput)

    guard let connection = videoOutput.connection(withMediaType: 

AVFoundation.AVMediaTypeVideo) else { return }

    guard connection.isVideoOrientationSupported else { return }

    guard connection.isVideoMirroringSupported else { return }

    connection.videoOrientation = .portrait

    connection.isVideoMirrored = position == .front
}`

ios:12.3.1 iphone:6+ xcode:10.1

hollance commented 5 years ago

It is not slow because of the FPS but because DeepLab is simply slow.

hakS07 commented 5 years ago

@hollance ok thank you