Skip to content

.NET Standard Library for Open Spherical Camera API

License

Notifications You must be signed in to change notification settings

OSC-Net/OSC.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NuGet Package

OSC.Net

.NET Standard Library for Open Spherical Camera API 2.0

Example

var cameraClient = new CameraClient();
cameraClient.TakePicture("test.jpg");

Client

The library exposes CameraClient class which implements an ICameraClient interface, which has a set of extension methods on it i.e. TakePicture().

Create client default IP (192.168.42.1) and Port (80)

var cameraClient = new CameraClient();

Create client supply IP and Port

var cameraClient = new CameraClient(new IPEndPoint(IPAddress.Parse("192.168.42.1"), 80));

Create client supply Uri

var cameraClient = new CameraClient(new Uri("https://192.168.42.1"));

HttpClientFactoryHandler

All CameraClient constructors takes an optional HttpClientFactoryHandler createClientparameter which allows you to override how the internally used HttpClient is created.

Example usage with System.Net IHttpClientFactory

var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider();
            var httpClientFactory = serviceProvider.GetService<IHttpClientFactory>();

var httpClientFactory = serviceProvider.GetService<IHttpClientFactory>();

var cameraClient = new CameraClient(createClient: httpClientFactory.CreateClient);

CreateFileHandler

All CameraClient constructors takes an optional CreateFileHandler createFileparameter which allows you to override how local files are created.

var cameraClient = new CameraClient(
    createFile: path => File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None));

Take Picture

Take picture and get uri to image

var pictureUri = await client.TakePicture();

Take picture and download image to supplied stream

var imageStream = new MemoryStream();
await client.TakePicture(imageStream);

Take picture and save to supplied local path

await client.TakePicture("test.jpg");

useLocalFileUri

All TakePicture methods takes an optional useLocalFileUri bool parameter, by default it's false. If set to true it'll use ICameraClient.EndPoint for construction an absolute uri to images. This is useful if using camera through proxy or firewall.

Supported cameras

This library has been tested with