Вопрос

I'm writing a VB.NET application using the Canon SDK and the EDSDKWrapper C# library (https://edsdkwrapper.codeplex.com/), as my programming skills aren't quite up to tackling C code or dealing with pointers, handlers and stuff. Here's my code so far, which displays the LiveView image in a picture box using a timer:

Public Class Form1

Dim frameworkManager As New EDSDKWrapper.Framework.Managers.FrameworkManager
Dim camera As EDSDKWrapper.Framework.Objects.Camera

Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
    tmrLiveView.Enabled = False
    camera.StopLiveView() ' Clean up
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    camera = frameworkManager.GetCameras().FirstOrDefault ' Get our first or default camera that's plugged in
    camera.LiveViewOutputDevice = EDSDKWrapper.Framework.Enums.LiveViewOutputDevice.Computer ' LiveView on the computer only, please
    camera.StartLiveView() ' Begin the LiveView
    tmrLiveView.Enabled = True ' Turn our timer on
End Sub

Private Sub tmrLiveView_Tick(sender As Object, e As EventArgs) Handles tmrLiveView.Tick
    Dim str As IO.Stream ' Holds our LiveView image
    str = camera.GetLiveViewImage() ' Get the image (which comes back as a stream)
    picLiveview.Image = System.Drawing.Image.FromStream(str) ' To the picturebox from the stream
End Sub

Private Sub btnFocus_Click(sender As Object, e As EventArgs) Handles btnFocus.Click
    ' But what goes here?
End Sub

End Class

But how do I take a photo? As far as I can tell, I need to do this:

EDSDKWrapper.Framework.Invokes.EDSDKInvokes.SendCommand(inCameraRef, EDSDKWrapper.Framework.Enums.CameraCommand.PressShutterButton,0)

But I'm not sure how to get inCameraRef (which I believe is the handle of the camera I wish to send the command to). I assumed there was a property in the camera class that would return this, but I'm not sure.

Has anyone used this wrapper before, or can they recommend a good Canon SDK wrapper? Time is at a sort of premium, and I've scoured the internet for far too long about this.

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top