Giter Site home page Giter Site logo

Comments (6)

tlhintoq avatar tlhintoq commented on August 26, 2024

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

from edsdk-wrapper.

jossef avatar jossef commented on August 26, 2024

👍 Thanks! i will add documentation

from edsdk-wrapper.

Ghini76 avatar Ghini76 commented on August 26, 2024

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

from edsdk-wrapper.

manit77 avatar manit77 commented on August 26, 2024

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();
    }
}`

from edsdk-wrapper.

Ghini76 avatar Ghini76 commented on August 26, 2024

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 ...

from edsdk-wrapper.

manit77 avatar manit77 commented on August 26, 2024

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

from edsdk-wrapper.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.