如何使用EDSDKWrapper C#库用佳能相机拍照?

时间:2013-11-26 22:59:56

标签: vb.net camera wrapper canon-sdk

我正在使用Canon SDK和EDSDKWrapper C#库(https://edsdkwrapper.codeplex.com/)编写VB.NET应用程序,因为我的编程技巧不仅仅是处理C代码或处理指针,处理程序和东西。这是我的代码到目前为止,它使用计时器在图片框中显示LiveView图像:

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

但我该如何拍照呢?据我所知,我需要这样做:

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

但我不确定如何获得inCameraRef(我认为是我希望发送命令的相机的手柄)。我假设相机类中有一个属性会返回,但我不确定。

之前有没有人使用过这个包装器,或者他们能推荐一个好的Canon SDK包装器吗?时间是一种溢价,我已经在互联网上浏览了太长时间。

0 个答案:

没有答案