Skip to content
This repository has been archived by the owner on Nov 7, 2020. It is now read-only.

Documentation of this edsdk wrapper #1

Open
ThorPets opened this issue Feb 25, 2015 · 6 comments
Open

Documentation of this edsdk wrapper #1

ThorPets opened this issue Feb 25, 2015 · 6 comments
Assignees

Comments

@ThorPets
Copy link

I have browsed through the zip file and can not see any documentation of the wrapper classes or any samples of how it is used. is it possible that you set out some samples or documentation for evaluating the wrapper.

ThorPets

@tlhintoq
Copy link

tlhintoq commented Mar 6, 2015

Have you tried looking at the sample project? Seems like the best example: A working program.

@jossef jossef self-assigned this Mar 7, 2015
@jossef
Copy link
Owner

jossef commented Mar 7, 2015

👍 Thanks! i will add documentation

@Ghini76
Copy link

Ghini76 commented Feb 13, 2016

Where can I find the sample project or documentation?
Thanks so much

@manit77
Copy link

manit77 commented Sep 28, 2016

Here is sample code that I wrote using the library. I added a new delegate named OnFileDownloadedComplete to fire after the file transfer from the camera completes.

`public partial class Form1 : Form
{
FrameworkManager frameworkManager = new FrameworkManager();
Camera camera = null;
public Form1()
{
this.FormClosed += Form1_FormClosed;

        InitializeComponent();

        camera = this.frameworkManager.Cameras.First();
        camera.OnFileDownloadedComplete += camera_OnFileDownloadedComplete;
    }

    void camera_OnFileDownloadedComplete(string filepath)
    {
        this.Invoke(new Action(() =>
        {
            //Bitmap bitmap;

            using (var fs = new System.IO.FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                System.Drawing.Image image = System.Drawing.Image.FromStream(fs);
                pictureBox1.Image = image;
            }

        }));
    }

    private void button1_Click(object sender, EventArgs e)
    {
        camera.StartLiveView();
        Application.Idle += Application_Idle;
    }

    void Application_Idle(object sender, EventArgs e)
    {
        if (!camera.LiveViewEnabled)
        {
            return;
        }

        int exceptionCount = 0;
        try
        {
            var stream = camera.GetLiveViewImage();
            var bmp = Bitmap.FromStream(stream);
            this.Invoke(new Action(() => { this.pictureBox1.Image = bmp; }));
            exceptionCount = 0;
        }
        catch
        {
            System.Threading.Thread.Sleep(100);
            if (++exceptionCount > 10)
            {
                throw;
            }
        }
    }

    void Form1_FormClosed(object sender, FormClosedEventArgs e)
    {
        camera.Dispose();
        frameworkManager.Dispose();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        camera.StopLiveView();
        Application.Idle -= Application_Idle;
    }

    private void ctlTakePhoto_Click(object sender, EventArgs e)
    {
        camera.StopLiveView();
        Application.Idle -= Application_Idle;
        camera.TakePhoto();
    }
}`

@Ghini76
Copy link

Ghini76 commented Sep 28, 2016

Manit77 Hello, thank you for the example.
You have this example also in VB.NET?
I try this code and will also try to translate it in VB.NET ...

@manit77
Copy link

manit77 commented Sep 29, 2016

sorry I haven't programmed in VB.NET in 10 years.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants