Simple CSharp Client Library for DeepAI's APIs
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
DeepAI.Client
.gitignore
DeepAI.sln
LICENSE
README.md

README.md

DeepAI CSharp Client

Simple CSharp Client Library for Deep AI's APIs

Installation:

Get this package from NuGet: https://www.nuget.org/packages/DeepAI.Client/

Or clone and build this repository with Visual Studio 2013 or later.

Reference

(generated from XMLDOC with Vsxmd):

Contents #

DeepAI # =

DeepAI_API # =

Namespace

DeepAI

Summary

Main API Client class - create an instance of the api by calling: DeepAI_API api = new DeepAI_API(apiKey: "...");

#ctor(apiKey) constructor # =

Summary

Call this to create a new DeepAI_API instance.

Parameters
Name Type Description
apiKey System.String Your DeepAI key as found in your DeepAI dashboard.

realtimeStreamUtilities constants # =

Summary

Object with helper utilities for sending input to and playing back a realtime stream.

callStandardApi(model,inputs_and_options) method # =

Summary

Call a standard API to run a model on a single image or other input, such as text file.

Returns

Reponse object with either URL or immediate data.

Parameters
Name Type Description
model System.String The name of the model to run.
inputs_and_options System.Object An anonymous object containing the inputs and options needed by the model, such as "image" or "style"

callStandardApiWithBinaryResponse(model,inputs_and_options) method # =

Summary

Call a standard API to run a model on a single image or other input, such as text file. Returns raw bytes of the output, such as JPEG data.

Returns

Byte array representing the output of the model, typically in JPEG format.

Parameters
Name Type Description
model System.String The name of the model to run.
inputs_and_options System.Object An anonymous object containing the inputs and options needed by the model, such as "image" or "style"

getAccountInfo() method # =

Summary

Get basic infomation about the account associated with the API Key

Returns

DeepAIAccountInfo object

Parameters

This method has no parameters.

getAvailableModelOptionsForModelName(modelName) method # =

Summary

Get the available model options for a given model name

Returns

Object representing the possible choices of various fields

Parameters
Name Type Description
modelName System.String Name of the model to get options for

getRealtimeStream(id) method # =

Summary

Get the info for a single realtime stream. Useful for continuously polling the status of a stream.

Returns

Stream Info object

Parameters
Name Type Description
id System.Int32 ID of the stream to get

getRealtimeStreams() method # =

Summary

Get the full list of your active realtime streams, plus streams started or stopped in the last hour

Returns

List of stream info objects

Parameters

This method has no parameters.

getVideoJob(id) method # =

Summary

Get status and basic information about a video job.

Returns

VideoJob information object

Parameters
Name Type Description
id System.Int32 The numeric Job ID of the video to get.

modifyRealtimeStream(id,output_bitrate_kbps) method # =

Summary

Modify a single realtime stream.

Returns

RealtimeStream object

Parameters
Name Type Description
id System.Int32 ID of the stream to modify
output_bitrate_kbps System.Int32 If provided, set the output bitrate of the stream to this value.

objectAsJsonString(a) method # =

Summary

Simple helper method to pretty-print an object response of any API call for easier viewing.

Returns
Parameters
Name Type Description
a System.Object

startRealtimeStream(model,input_type,output_type,fps,width,height,output_bitrate_kbps,model_options) method # =

Summary

Creates a new real-time stream. The status field will initially be "PENDING" which will transition to "RUNNING" within 5 minutes. If the provided stream does not match the width and height values passed, it will be rescaled.

Returns

RealtimeStream object containing URLs which may be used to connect to the stream by sending input and receiving output.

Parameters
Name Type Description
model System.String Name of the model to process the video with, such as "deepdream" or "fast-style-transfer"
input_type System.String Stream descriptor of in the input video stream. Possible values are "tcp/mpegts" or "udp/mpegts".
output_type System.String Stream descriptor of in the output video stream. Possible values are "tcp/mpegts" or "udp/mpegts".
fps System.Single Frames per second of the input video stream. The output stream will be the same frame rate.
width System.Int32 width of the video to process in pixels
height System.Int32 height of the video to process in pixels
output_bitrate_kbps System.Int32 Bitrate of the output video stream in kbps. If not provided, the system default will be used.
model_options System.Collections.Generic.Dictionary{System.String,System.Object} Dictionary of options to send to the processing model. Possible values may be retrieved with api.getAvailableModelOptionsForModelName(...)

startVideoJob(model,video,fps,model_options) method # =

Summary

Creates a new single-model video job using either a file upload or a URL of the video to process.

Returns

Object with the ID and status of the new video job.

Parameters
Name Type Description
model System.String The model name to process the video with
video System.Object The FileStream of video data to process, or a URL to download.
fps System.Single Frames per second to process. If not given, the frame rate will be chosen automatically, typically the same as the input video, or 2fps for object detection models.
model_options System.Object Dictionary of options to pass to the given model, such as {"style": "YOUR_STYLE_CHOICE"}

stopRealtimeStream(id) method # =

Summary

Abort a single realtime stream.

Returns

RealtimeStream object

Parameters
Name Type Description
id System.Int32 ID of the stream to stop

DeepAIAccountInfo # =

Namespace

DeepAI

Summary

Basic information about a DeepAI account

ObjectDictionary # =

Namespace

DeepAI.DeepAI_API

#ctor(a_source) constructor # =

Summary

Construct.

Parameters
Name Type Description
a_source System.Object Source object.

ParseObject(a_source) method # =

Summary

Create a dictionary from the given object (a_source).

Returns

Created dictionary.

Parameters
Name Type Description
a_source System.Object Source object.
Exceptions
Name Description
System.ArgumentNullException Thrown if a_source is null.

RealtimeStream # =

Namespace

DeepAI

Summary

Represents the status and configuration for a single Realtime video stream.

input_url property # =

Summary

URL at which you should send your input. This URL is compatible with ffmpeg and tools based upon it.

model_options property # =

Summary

Currently active model options of the stream.

output_url property # =

Summary

URL at which the results can be streamed back. This URL is compatible with ffmpeg and tools based upon it, like Ventuz.

state_change_reason property # =

Summary

The description of the reason for the change in status if it is known. For example, if transitioned to STOPPED due to inactivity, or FAILED due to DeepAI internal error.

status property # =

Summary

One of PENDING, RUNNING, STOPPED, FAILED

RealtimeStreamUtilities # =

Namespace

DeepAI

Summary

A collection of helper functions for use with real time streams, such as sending webcam input to a stream, or playing the output of a stream.

#ctor() constructor # =

Summary

Construct a new instance - this is done automatically as this object will be available on all DeepAI_API objects.

Parameters

This constructor has no parameters.

getPlayerCmdForRealtimeStream(stream) method # =

Summary

Get the program name and arguments to launch a process that will play the output of a realtime stream.

Returns

program name and arguments as array

Parameters
Name Type Description
stream DeepAI.RealtimeStream The realtime stream to play.

getVideoCaptureDevices() method # =

Summary

Get a list of availabe video capture device names.

Returns

List of string device names

Parameters

This method has no parameters.

getVideoStreamFormatsForDeviceName(deviceName) method # =

Summary

Get the frame rate and frame size combinations that the given input device supports.

Returns

Array of supported formats for the device.

Parameters
Name Type Description
deviceName System.String The input device to get capabilities for.

launchPlayerForStream(stream,showWindow) method # =

Summary

Launches a new process to play the output of a realtime stream in a window.

Returns

Windows Process handle

Parameters
Name Type Description
stream DeepAI.RealtimeStream The stream to play back.
showWindow System.Boolean Set to false to hide the command prompt. (Not recommended.)

launchWebcamSenderForStream() method # =

Returns

Windows Process handle

Parameters

This method has no parameters.

Resources # =

Namespace

DeepAI.Properties

Summary

A strongly-typed resource class, for looking up localized strings, etc.

Culture property # =

Summary

Overrides the current thread's CurrentUICulture property for all resource lookups using this strongly typed resource class.

ffmpeg property # =

Summary

Looks up a localized resource of type System.Byte[].

ffplay property # =

Summary

Looks up a localized resource of type System.Byte[].

ResourceManager property # =

Summary

Returns the cached ResourceManager instance used by this class.

StandardApiResponse # =

Namespace

DeepAI

output property # =

Summary

The immediate output of the model

output_url property # =

Summary

The private URL at which the results are available, if present.

VideoJob # =

Namespace

DeepAI

Summary

Represents the status and output for a single Video job.

est_total_cost property # =

Summary

The estimated cost of the job if it runs to completion.

results property # =

Summary

The private URL at which the results are available, if present.

status property # =

Summary

One of: complete, in-progress, failed

VideoStreamFormat # =

Namespace

DeepAI.RealtimeStreamUtilities

Summary

Represents the framerate and frame size of a video stream.