Remarks

Vc0706
Status Status badge: in-progress
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Camera.Vc0706
Vc0706 camera;

//Uses SimpleJpegDecoder package for jpeg decoding
public MeadowApp()
{
    Console.WriteLine("Initialize hardware...");

    camera = new Vc0706(Device, Device.SerialPortNames.Com4, 38400);

    camera.SetImageSize(Vc0706.ImageSize._320x240);
    Console.WriteLine($"Image size is {camera.GetImageSize()}");

    camera.TakePicture();

    uint frameLen = camera.GetFrameLength();
    Console.WriteLine($"Frame length: {frameLen}");

    byte bytesToRead;
    byte[] jpg;

    var decoder = new JpegDecoder();

    using (var stream = new MemoryStream())
    {
        Console.WriteLine($"Decode jpeg - this operation may take serveral seconds");

        while (frameLen > 0)
        {
            bytesToRead = (byte)Math.Min(32, frameLen);

            var buffer = camera.ReadPicture(bytesToRead);

            stream.Write(buffer, 0, bytesToRead);
            frameLen -= bytesToRead;
        }
        jpg = decoder.DecodeJpeg(stream.ToArray());
    }

    Console.WriteLine($"Jpeg data length: {jpg.Length}");

    Console.WriteLine($"Jpeg decoded is {decoder.ImageSize} bytes");
    Console.WriteLine($"Width {decoder.Width}");
    Console.WriteLine($"Height {decoder.Height}");
    Console.WriteLine($"IsColor {decoder.IsColor}");
}

Sample project(s) available on GitHub

|

Code Example

Vc0706 camera;

public override Task Initialize()
{
    Console.WriteLine("Initialize...");

    camera = new Vc0706(Device, Device.SerialPortNames.Com4, 38400);

    return Task.CompletedTask;
}

public override Task Run()
{
    if (!camera.SetCaptureResolution(Vc0706.ImageResolution._160x120))
    {
        Console.WriteLine("Set resolution failed");
    }

    _ = TakePicture();

    return Task.CompletedTask;
}

async Task TakePicture()
{
    Console.WriteLine($"Image size is {camera.GetCaptureResolution()}");

    camera.CapturePhoto();

    using var jpegStream = await camera.GetPhotoStream();

    var jpeg = new JpegImage(jpegStream);
    Console.WriteLine($"Image decoded - width:{jpeg.Width}, height:{jpeg.Height}");
}

Sample project(s) available on GitHub

Characteristic Locus
Inheritance System.Object > Vc0706
Namespace Meadow.Foundation.Sensors.Camera
Assembly Vc0706.dll

Syntax

public class Vc0706 : ICamera

Constructors

Vc0706(ISerialController, SerialPortName, Int32)

Create a new VC0706 serial camera object

Declaration
public Vc0706(ISerialController device, SerialPortName portName, int baudRate)

Parameters

Type Name Description
ISerialController device
SerialPortName portName
System.Int32 baudRate

Properties

BytesAvailable

Number of bytes avaliable in the camera buffer

Declaration
public byte BytesAvailable { get; }

Property Value

Type Description
System.Byte

Methods

CapturePhoto()

Capture a new image

Declaration
public bool CapturePhoto()

Returns

Type Description
System.Boolean

true if successful

GetCaptureResolution()

Get the current image capture resolution

Declaration
public Vc0706.ImageResolution GetCaptureResolution()

Returns

Type Description
Vc0706.ImageResolution

the image resolution as an ImageResolution enum

GetColorMode()

Get the current camera color mode (Color, Black and White, automatic)

Declaration
public Vc0706.ColorMode GetColorMode()

Returns

Type Description
Vc0706.ColorMode

GetCompression()

Get compression (0-255)

Declaration
public byte GetCompression()

Returns

Type Description
System.Byte

compression value

GetDownsize()

Get the downsize value

Declaration
public byte GetDownsize()

Returns

Type Description
System.Byte

GetFrameLength()

Get the length of the current frame

Declaration
public uint GetFrameLength()

Returns

Type Description
System.UInt32

GetMotionDetectMode()

Get the motion detection mode

Declaration
public bool GetMotionDetectMode()

Returns

Type Description
System.Boolean

true if enabled, false if not enabled or command failed

GetMotionStatus(Byte)

Get the motion detection mode

Declaration
public bool GetMotionStatus(byte x)

Parameters

Type Name Description
System.Byte x

Returns

Type Description
System.Boolean

GetPanTiltZoom()

Get Pan, Tilt and Zoom values

Declaration
public (ushort width, ushort height, ushort horizonalZoom, ushort verticalZoom, ushort pan, ushort tilt) GetPanTiltZoom()

Returns

Type Description
System.ValueTuple<System.UInt16, System.UInt16, System.UInt16, System.UInt16, System.UInt16, System.UInt16>

GetPhotoData()

Retreive the image data from the camera

Declaration
public Task<byte[]> GetPhotoData()

Returns

Type Description
Task<System.Byte[]>

The image data as a jpeg in a byte array

GetPhotoStream()

Retreive the image data from the camera

Declaration
public Task<MemoryStream> GetPhotoStream()

Returns

Type Description
Task<MemoryStream>

The image data as a jpeg in a MemoryStream

GetVersion()

Get the camera version

Declaration
public string GetVersion()

Returns

Type Description
System.String

the version as a string

IsMotionDetected()

Check if camera has detected recent motion

Declaration
public bool IsMotionDetected()

Returns

Type Description
System.Boolean

IsPhotoAvailable()

Check if there is picture data on the camera

Declaration
public bool IsPhotoAvailable()

Returns

Type Description
System.Boolean

true is data is avaliable

ReadPicture(Byte)

Read bytes from the camera buffer

Declaration
public byte[] ReadPicture(byte length)

Parameters

Type Name Description
System.Byte length

Returns

Type Description
System.Byte[]

ResumeVideo()

Resume live video over composite

Declaration
public bool ResumeVideo()

Returns

Type Description
System.Boolean

SetCaptureResolution(Vc0706.ImageResolution)

Set the image resolution

Declaration
public bool SetCaptureResolution(Vc0706.ImageResolution resolution)

Parameters

Type Name Description
Vc0706.ImageResolution resolution

the new image capture resolution

Returns

Type Description
System.Boolean

true if succesful

SetColorMode(Vc0706.ColorMode)

Set the camera color mode (Color, Black and White, automatic)

Declaration
public void SetColorMode(Vc0706.ColorMode colorControl)

Parameters

Type Name Description
Vc0706.ColorMode colorControl

SetCompression(Byte)

Set compression (0-255)

Declaration
public bool SetCompression(byte compression)

Parameters

Type Name Description
System.Byte compression

Returns

Type Description
System.Boolean

true if succesful

SetDownsize(Byte)

Set downsize

Declaration
public bool SetDownsize(byte downsize)

Parameters

Type Name Description
System.Byte downsize

Returns

Type Description
System.Boolean

SetMotionDetect(Boolean)

Enable or disable motion detection

Declaration
public bool SetMotionDetect(bool enable)

Parameters

Type Name Description
System.Boolean enable

true to enable

Returns

Type Description
System.Boolean

true if succesful

SetMotionStatus(Byte, Byte, Byte)

Set the motion detection mode

Declaration
public bool SetMotionStatus(byte x, byte d1, byte d2)

Parameters

Type Name Description
System.Byte x
System.Byte d1
System.Byte d2

Returns

Type Description
System.Boolean

SetOnScreenDisplay(Byte, Byte, String)

Enable onscreen display for composite output (may not work)

Declaration
public void SetOnScreenDisplay(byte x, byte y, string message)

Parameters

Type Name Description
System.Byte x

x location of display in pixels

System.Byte y

y location of dispaly in pixels

System.String message

text to display

SetPanTiltZoom(UInt16, UInt16, UInt16, UInt16)

Set Pan, tilt and zoom

Declaration
public bool SetPanTiltZoom(ushort horizontalZoom, ushort verticalZoom, ushort pan, ushort tilt)

Parameters

Type Name Description
System.UInt16 horizontalZoom
System.UInt16 verticalZoom
System.UInt16 pan
System.UInt16 tilt

Returns

Type Description
System.Boolean

TvOff()

Disable TV output over composite

Declaration
public bool TvOff()

Returns

Type Description
System.Boolean

TvOn()

Enable TV output over composite

Declaration
public bool TvOn()

Returns

Type Description
System.Boolean