TraceVision

public class TraceVision : ObservableObject

Main SDK class to get/create various objects and handlers

Use TraceVision.shared to access the singleton to interact with SDK.

Note

The SDK should be initialized with initSDK() method before using any other methods. You will need to provide the API token and secret that you should acquire from TraceVision.
  • Undocumented

    Declaration

    Swift

    public static let shared: TraceVision
  • Property to check if the SDK is initialized

    This property is set to true when the SDK is initialized. Initialization is asynchronous and can take some time. The property can have the following values:

    • true - SDK is initialized and ready to process requests
    • false - SDK is not initiliazed properly. Very likely that your consumer token or secret are no longer valid.
    • nil - SDK is not initialized yet. This is the initial value of the property.

    Note

    Listen to this observable property to know when the SDK is initialized and ready to work.

    Declaration

    Swift

    @Published
    public internal(set) var isSDKInited: Bool? { get set }
  • Initialize the SDK

    To properly use the SDK you need to initialize it with the consumer token and secret that you should acquire from TraceVision.

    Note

    This method should be called only once and before using any other methods of the SDK.

    Warning

    SDK will not work properly if invalid token or secret are provided. Requires working internet connection.

    Note

    Please listen to isSDKInited property to know when the SDK is initialized. Initialization is asynchronous and can take some time. When initialized, the property will be set to true.

    Declaration

    Swift

    public func initSDK(token: String, secret: String)
  • Get the current version of the SDK

    The version is a string with the format major.minor.patch. For example: 1.0.0

    Declaration

    Swift

    public var version: String { get }
  • Get the authorization handler

    Declaration

    Swift

    public func getAuthHandler() -> AuthHandlerProtocol

    Return Value

    AuthHandlerProtocol instance

  • Path to the folder where the full videos are stored

    Declaration

    Swift

    public var fullVideoPath: URL { get }
  • Path to the folder where the highlight videos are stored

    Declaration

    Swift

    public var highlightsPath: URL { get }
  • Create a new video record session

    Video session is used to record the video from the camera and process it on the fly with our detector to get the highlights. For more info see VideoRecordSessionProtocol.

    Note

    If exportFullVideo is set to true then the full video will be exported to the camera roll. If keepFullVideo is set to true then the full video will be kept in the internal storage and the url is provided via fullVideos. If both are set to false then the full video will not be written at all, but the highlights will have their own small videos regardless of the full one.

    Warning

    if exportFullVideo is set to true and fullVideoChunkSec > 0 then full video will be recorded and exported to the camera roll in chunks.

    Declaration

    Swift

    public func createVideoRecordSession(exportFullVideo: Bool = true,
                                         keepFullVideo: Bool = false,
                                         needAudio: Bool = true,
                                         fullVideoChunkSec: Double? = nil) -> VideoRecordSessionProtocol

    Parameters

    exportFullVideo

    if true, the full video will be exported to the camera roll

    keepFullVideo

    if true, the full video will be kept in the internal storage and the url is provided via fullVideos

    needAudio

    if true, the audio will be recorded with the video

    fullVideoChunkSec

    the chunk size for the full video in seconds. If set to 0 then the full video will be recorded as one chunk. If non-zero then new video file is created every fullVideoChunkSec seconds and file url is put into fullVideos.

    Return Value

    VideoRecordSessionProtocol instance

  • Create a new video import session

    Import session is used to import a video from the camera roll and analyze it with TraceHighlightDetector to get the highlights. Can be used to get the highlights metadata or to create highlight videos in addition to metadata

    Note

    if needVideoResults is set to false the results will be provided in VideoImportSessionProtocol.status.highlights and they won’t be available after the session is discarded. If set to true then the results will be saved to the internal DB and can be accessed later via TraceVision.getHighlightReader() reader.

    Declaration

    Swift

    public func createVideoImportSession(needVideoResults: Bool = true) -> VideoImportSessionProtocol

    Parameters

    needVideoResults

    do you want highlight metadata or metadata and video results

    Return Value

    VideoImportSessionProtocol instance

  • Create a new video session to process video frame by frame

    This is used to process the video frame by frame and get the highlights metadata. It’s your responsibility to get the video frames from the video and provide them to the session. See VideoByFrameSessionProtocol for more info.

    Declaration

    Swift

    public func createVideoByFramesSession(isSynchronous: Bool) -> VideoByFrameSessionProtocol

    Return Value

    VideoByFrameSessionProtocol instance

  • Return a highlight reader object that can be used to access saved highlights

    Declaration

    Swift

    public func getHighlightReader() -> HighlightReaderProtocol

    Return Value

    highlight reader