Live View with Canon EDSDK 2.5.2 VB.NET

I am trying to do one of two things, preference number 1:

Enable Live View with VB.NET and Canon EDSDK 2.5.2 and output live output in the Windows Forms application. I'm currently trying to put it in a picture window; However, I am open to suggestions for sure.

The second option would be to at least enable Live View and transfer the stream through the video output to the camera on the monitor.

I really want to accomplish the first though! Below is my current code base, help!

Private Sub btnStartLiveView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartLiveView.Click Dim err As Integer = EDS_ERR_OK Dim prop As Integer = EdsEvfOutputDevice.kEdsEvfOutputDevice_PC Dim proptype As Integer = EDSDKTypes.kEdsPropID_Evf_OutputDevice '// Stock the property.' Dim wkIntPtr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(prop)) Marshal.StructureToPtr(prop, wkIntPtr, False) 'send property/command to the camera' EdsSetPropertyData(model.getCameraObject(), proptype, 0, Marshal.SizeOf(prop), prop) Dim stream As IntPtr Dim outMemoryRef As IntPtr Dim evfImage As IntPtr err = EdsCreateMemoryStream(0, stream) If err = EDS_ERR_OK Then err = EdsCreateImageRef(stream, outMemoryRef) '(stream, evfImage)' Else Dim str As String = Hex(err) MessageBox.Show(str) End If If err = EDS_ERR_OK Then err = EdsDownloadEvfImage(model.getCameraObject(), evfImage) Else Dim str As String = Hex(err) MessageBox.Show("&H" & str & "L") ' Shows &H2CL which = ERR_FILE_FORMAT_NOT_RECOGNIZED' End If ' Get the Incidental Data of the Image' If err = EDS_ERR_OK Then Dim zoom As UInt32 Dim point As IntPtr EdsGetPropertyData(outMemoryRef, kEdsPropID_Evf_ZoomPosition, 0, Marshal.SizeOf(zoom), zoom) EdsGetPropertyData(outMemoryRef, kEdsPropID_Evf_ZoomPosition, 0, Marshal.SizeOf(point), point) Else 'MessageBox.Show(err.ToString())' End If Dim buffer(Marshal.SizeOf(stream)) As Byte Dim mStream As System.IO.Stream = New System.IO.MemoryStream(Marshal.SizeOf(stream)) Dim gcTime As GCHandle = GCHandle.Alloc(0, GCHandleType.Pinned) Dim pTime As IntPtr = gcTime.AddrOfPinnedObject() Marshal.Copy(stream, buffer, 0, Marshal.SizeOf(stream)) mStream.Write(buffer, 0, Marshal.SizeOf(stream)) Me.PictureBox1.Image = Image.FromStream(mStream) EdsRelease(stream) End Sub 
+4
edsdk
source share
3 answers

Here's a .vb file in which I define a Camera class that allows you to do top-level things like

 Dim camera as New Camera camera.EstablishSession() camera.TakePicture("C:\path\to\save.jpg") camera.StartLiveView(me.LiveViewPictureBox) camera.StopLiveView() camera.FlushTransferQueue() 

I think you may find this useful:

 <snip> 

Over the years, I have received several emails for updates to this block of code, which is located on GitHub as an open source:

http://github.com/superjoe30/Camlift-Controller

The camera class is in slnCamliftController / src / Camera.vb

Some of this code is embarrassingly awful. For example, to make it work on the 5D and 7D cameras, I need to create a program that initializes the SDK and then works specifically. Awful I know! It is located in Klugesaurus. As with trying to connect to 5D or 7D, nothing works. There is a pit of thorns. So, we throw the peasant (Klugesaurus) onto the thorns, killing him (he fails), so we can safely walk through the sacral body.

This is terrible and terrible, but: It works every time. If you do not, it will not work. I asked Canon several times several times if I released the source code for EOS Utility, which integrates perfectly with 5D and 7D. They firmly refused every time. My colleague jokes that they do not want to disclose that they also use Klugesaurus. In any case, I just wanted to give you a head for this unpleasant detail.

I also created a Python module for interacting with the camera: http://github.com/superjoe30/pyedsdk

+2
source share

I was the one who originally posted this question. I see that there are others here who are still looking for an answer. I posted a solution that we finally came up with on my blog, http://www.overridepro.com/2009/06/28/canon-sdk-live-view/ .

+2
source share

There are examples of code and discussions on various ways to learn it.

0
source share

All Articles