我正在使用 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 (我相信这是我希望将命令发送到的相机的句柄)。我假设相机类中有一个属性会返回这个,但我不确定。
有没有人使用过这个包装器,或者他们可以推荐一个好的佳能 SDK 包装器?时间是一种宝贵的财富,我已经在互联网上搜索了太长时间。