Canon SDK Live View

Okay, recently we needed to make a Canon EOS40D capture a Live Stream (keep in mind this is a Still Camera not a video camera) and pull the Live Stream back to a Windows Forms application and perform interactions with another system via Serial Commands.  The biggest struggle throughout the project was the Live Stream.  Taking pictures and the rest of the project was a snap (bad pun)….

There was absolutely NO documentation provided in a managed code such as .NET (which is what we were writing it in), Canon does not support the SDK, and documentation on the internet is nearly nothing.

Below is a sample of the LiveView loop and how to call it in a separate thread to make it run.

***************** UPDATE ********************************************

Due to the enormous popularity of this post we have made access to our SVN Repository for this project open.

You can download the sample from – the access is read only using the following credentials:

Username:  public
Password:  hostoverride2012

Let me know if you have any questions

49 Comments for this entry

  • Wes, October 1st, 2012 on 5:14 pm

    I’m not familiar with the 60D, does it have a mode dial?
    The reason I ask is the following statement from the SDK:

    5.2.18 kEdsPropID_AEModeSelect
    You cannot set (that is, Write) this property on cameras with a mode dial.
    If the target object is EdsCameraRef, you can use GetPropertyDesc to access this property and get a list of property values that can currently be set.
    However, you cannot get a list of settable values from models featuring a dial. The GetPropertyDesc return value will be EDS_ERR_OK, and no items will be listed as values you can set.

  • Duc, July 12th, 2012 on 6:02 pm

    Hi Justin,
    I have solved the problem (1).
    about problem (2), I described it incorrectly. Actually, I tried to retrieve the available list of values of AE mode,but they are nonsense values so I couldn’t set to the property.Do you know why?
    Problem (3) is still there.

    What do you think?

  • Duc, July 12th, 2012 on 1:35 am

    Hi Justin,
    I’m developing a C# app (with Canon 60D) for LiveView using separate thread as your idea. It’s working fine. However, when I extended some new features, for ex: setting camera’s shooting properties, I got 3 problems:
    1) I already got the available list of values of a particular property, but how can I get the property’s value of current shooting setting (e.g. Tv,Av, ISO,…) in the camera, so that I can show that info to user?
    2) How can i change the AE mode (shooting mode) using the SDK, instead of having to switch the menus button? I got the available list of values of AE mode,but I don’t know how to set the chosen value mode.
    3) I think due to the separating thread of LiveView, when clicking the combobox (which contains a list of available values of a shooting property), its dropdown list shows shortly then disapear. Hence, I couldn’t choose the new setting for that property :(
    Do you have any idea?

    Any help would be appreciated.

  • Cokiki, July 5th, 2012 on 12:09 am

    Hi justin… i’m using esdk 2.10 with 450D n C# as my language… i’m trying to convert the LiveView code to C# but i got problem, variable Integer and IntPtr… whats the different… if you are not busy, could you explain to me…

  • K12, May 19th, 2012 on 9:37 am

    I Have some problem when start Live view

    Error is :

    A call to PInvoke function ‘CameraController!CameraController.EDSDK::EdsCreateEvfImageRef’ has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

    Can some one help me…

    Sorry for my english

  • awinash kumar, April 20th, 2012 on 2:59 am

    Thank you your reply.

    I’m using canon T3i camera for recording movie in live mode because camera support movie dial mode. I am using below code for start and stop movie recording but it generate “Access Protection Violation” error.

    I want to know property ID and correspondig value is true or not? If not please help me.

    EdsError startRecording(EdsCameraRef cameras)
    EdsUInt32 value = 4;
    EdsUInt32 dataSize;
    return EdsSetPropertyData(cameras, 0x01000510, 0 , sizeof(dataSize), &value);

    EdsError stopRecording(EdsCameraRef cameras)
    EdsUInt32 value = 0;
    EdsUInt32 dataSize;
    return EdsSetPropertyData(cameras, 0x01000510, 0 , sizeof(dataSize), &value);

  • justin, April 19th, 2012 on 10:52 am

    When we wrote this it only did LivePreview, not recording, and I am not sure the Canon even has a mechanism for recording audio. Sorry I can’t be of more help on this one.

  • awinash kumar, April 19th, 2012 on 10:49 am

    Hi All,

    I am facing one problem related to live video recording using EDSDK. when i run cimmand using propertyId and corresponding value then it generate “Access Protection violation” error.
    Please give me solution how to record video with audio using EDSDK.

    Any help would be appreciated.


  • admin, April 11th, 2012 on 8:38 am

    Hi Ron–

    It is not VPN, it is SVN, not sure if you are familiar, it is a source control management system. You will need a client like either TortoiseSVN on Windows, SlickSVN (which is command line) or if you are on a Mac you can use Terminal once SVN is installed.

    You can use the following user:

    Username: public
    Password: hostoverride2012

  • Ron Holder, April 10th, 2012 on 5:00 pm


    For some reason I cannot access the VPN file area. I get a dialog that requires a user name and password, and I can’t get past it. Is there a secret I have not learned? I tried various anonymous names and standard passwords.


  • admin, April 9th, 2012 on 10:51 am

    Hi @ronholder, I am updating the post above to include access to download the entire codeset from our SVN Repository. I have made it support anonymous access. Download it from there, that should give you what you need to know how to turn liveview on and off.

  • Ron holder, April 6th, 2012 on 3:38 pm

    I hate to bother you, but I’m having difficulties getting the live view to work.
    I added the code to vb sample. I have no errors until I run the code. The thread gets started but it gets stuck at downloading the evfimage. Error 2003-session not open. Since I am about five days into trying to understand the SDK, I may be entering the previewon command at the wrong location. I was entering it at the bottom of vb sample.load

  • admin, April 6th, 2012 on 11:52 am

    Basically the way we did it was start a separate thread which checks for a Boolean value, I think we called it LiveViewRunning. That thread just runs and when you want to turn on LiveView we would just set the Boolean value to true in the Main Thread. I will post our full code for everyone which should answer a lot of questions.

  • Greg, April 6th, 2012 on 10:44 am

    Yes, turning live view on and off.
    Something like EdsSetPropertyData with EdsEvfOutputDevice.kEdsEvfOutputDevice_PC which is missing in your code and gave me errors or frezes image (when I use Marc’s code).
    I use a CANON EOS 1000D.

  • admin, April 2nd, 2012 on 9:51 am

    Not sure what you mean, are you saying you need to know how to turn live view on and off?

  • Greg, April 2nd, 2012 on 9:34 am

    Your code works fine for me. But can you add code to set live view mode to the camera?

  • admin, March 21st, 2012 on 6:27 pm

    Glad you got it working! Seems like it is always something small and stupid. Let me cleanse the code of any database or server specific information and I will post it in a public SVN repo for you, and future readers on this site to download.

  • Ron Holder, March 21st, 2012 on 5:05 pm

    Well, I finally have the basic Canon sample ap working with the camera and took my first photo!
    I spent 2 wonderful hours with the Microsoft support guy. He was very helpful, but we only discovered that putting the dll in the debug directory looked hopeful, but still didn’t work. He said version 2010 did not allow for referencing of unmanaged dlls using the referencing technique. He suggested I need to use pinvoke for each of the functions.
    While I was staring at the sample code from Canon I noticed the dll was referenced in the code as “EDSDK”. I changed the code to read “EDSDK.dll” and the whole ap came to life! I did search and replace on 30 some instances and I am in picture business!
    I would very much appreciate a post of the code, as I am now behind schedule and can use every bit of help available. I honestly can’t thank you enough for leading the way and dropping the bread crumbs for me to follow.

  • admin, March 21st, 2012 on 11:51 am

    @ron – if you want I can post our code for you to download

  • Ron Holder, March 21st, 2012 on 11:32 am

    I downloaded the SDK again. Then I tested on a second Windows 7 – 64 bit machine, same error. I loaded Windows 7 as a 32 bit system. Same error. The error I get when browsing to add a reference is:

    A reference to ‘C:\…\EDSDK.dll’ could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.

    I guess my next step is to contact Microsoft. I am persistant and will figure this out. I will post my results.

    Thanks for all your help!

  • admin, March 19th, 2012 on 8:01 pm

    @ron – if memory serves unless they updated it the sdk works on 32 bit OS. You should be able to manage this in your build preferences though. Let me know what a clean download yields for you.

  • Ron Holder, March 19th, 2012 on 4:56 pm

    Hi, the camera is supported as of February. I cannot reference the SDK. I get an error message as stated earlier. That must be the problem. I am running a 64 bit Windows 7, which is another possibility. Maybe I have a corrupt SDK. I will try to download again.

  • admin, March 19th, 2012 on 1:06 pm

    @ron – I am not familiar with that Camera so I can’t speak directly to whether it will or won’t work, you would have to check the SDK documentation. We used a Canon EOS-50D for the implementation we did for Disney. Another user on here in the past 6 months used this code set to implement a liveview scenario out in Salt Lake City and he used a 5D I believe. I did do a quick Google Search and it appears that your camera does support live view but I did not verify via the SDK documentation whether or not it works with Liveview WITH the SDK.

    As far as referencing the DLL, I know you are putting it in the bin directory of your project which is fine but are you actually going in and referencing the DLL via Solution Manager?

  • Ron Holder, March 19th, 2012 on 10:41 am

    I’m using a T3i

  • admin, March 18th, 2012 on 4:38 pm

    @george yes, this solution was used 24/7/365 in our product in Epcot at Disneyworld and I know another user on this site used the code for a 24/7/365 live view solution in Salt Lake City.

    What are your questions?

  • admin, March 18th, 2012 on 4:36 pm

    @ronholder what Camera are you using?

  • Ron Holder, March 18th, 2012 on 4:14 pm

    I appreciate your post. I have been days trying to get the SDK to work for me. I cannot get the EDSDK.dll to be ‘referenced’ by VB2010 Pro, only error messages ‘A reference cannot …please make sure it is accessable or a valid com…. I have no luck when putting it in the bin or other directories. “I have copied it everywhere!” I have tried c++, C# and VB samples with zero luck. In vb and c++ I get ‘cannot detect camera’ error. The variable isSDKloaded = false. The camera works in its software and with ‘breezesystems’ software, using the SDK.

  • George Williams, March 16th, 2012 on 1:29 pm

    Hey guys – did you settle on a decent solution for a canon camera, sdk version, and operating system ?

    I am making a product that needs liveview and pictures, unattended, operating 24 hours a day.

    I will be happy to share code as well…

    Thanks !

  • Jaka, February 4th, 2012 on 12:30 pm

    After sidnepng the best part of a day figuring this out for myself, I was relieved to find someone else had encountered the same ambiguities and posted such an astute article on it. Thank you.

  • lily, January 8th, 2012 on 7:30 pm

    hi eric,
    could u get me right on the code… ‘im getting error on the EdsGetPointer…
    how could i solve this?
    i’m really beginner with SDk’s things… thx

  • zb, December 29th, 2011 on 5:26 am

    Hi Justin,

    I am facing problem in line 41
    ” result = EDSDK.EdsDownloadEvfImage(pCamera, pImageEvf) ”

    with result value 41218

    Any help would be appreciated


  • Soke, December 9th, 2011 on 3:18 am

    Hi Justin!
    Your code works fine for me, on Pentium IV, dual core etc. Thanks for that.
    Just one problem: live view is freezing when the code is running on Pentium I3 and camera is moving left/right, up/down…
    And one more thing: I can’t figure out how to start live view on camera, programmatically, without manually press that button,
    Obs. I’m using Canon EOS 600D.

    Any help will be appreciated!

  • justin, October 27th, 2011 on 9:36 am

    Hi Eric,

    Wow, taking me back on this one. I spent several months each and every night at Disney working on these EXACT same issues – live view works, then stops, only way to fix is to power cycle the camera, I mean the exact same issues. While I am not familiar with the 60D the 50D that we settled on helped us to resolve all these issues so there is hope. I am sending an email to the email you listed with the subject CANON LIVE VIEW. You can respond with more detailed questions if you prefer. I will have to think back about how we solved each issue but we did solve them. Respond to my email and we will figure it out.

  • Eric, October 27th, 2011 on 9:23 am

    Hi Justin,

    We are seeing a strange error, wondering if you could offer an opinion? With our EOS60D, the liveveiw stuff works great, it also takes pictures great, but we are experiencing a couple of strange things. First, if we do nothing but start up live view, it invariably crashes. (Takes a while, like an hour or more). The place in the program where it hangs is ‘EDS_ERR_OBJECT_NOTREADY’, it appears that even repeatedly waiting, it just never ends being notready. But the bad thing is the camera at that point does not seem to be in a good mode, because even with a fresh program restart, liveview will not work. Simpley power cycling the camera fixes that. The other strange thing we see, when trying to share liveview and picture taking (toggling between threads essentially) we can seemingly get into the liveview thread where it just doesn’t seem to exit on its own. Curious if I might be able to ask you more about the threading parts of this process? We appear to have no heat issues with the liveview, unless this might be symptom of the camera heating? Thanks!

  • justin, October 17th, 2011 on 1:05 pm

    Your first issue is most likely a thread issue yes. We had several other methods that are not listed in this code snippet on how to handle threads.

    Yes, we did encounter the heat issue. Initially this was written for a EOS40D which did not even support Live VIdeo directly so we really stretched its limitations. The client was EPCOT (Disney) and the shows ran for 15 minutes at a time. What would happen was at the last queue the actor would not move the show into the wait mode which would turn live view off. When the camera hit a total of a couple hours of live view it would just shut off and would have to cool down for nearly an hour. This also led to burning out several cameras (3 I think). Once we moved the Canon 50D we no longer had these issues.

    To confirm testing I wrote a separate program that ran the live view continuously and snapped a photo every 20 minutes. Leaving it to run overnight and the next day (24 hours later) the program was still running fine with Live View. I believe the newer versions of the camera, 50D and now 60D have solved the heat issue. Let me know if you find out differently.

    Glad our code could help. Have a blessed day.

  • Eric, October 17th, 2011 on 12:36 pm

    Another thank you for putting this code out there. I have gotten this to work on an EOS60D, VB .NET 2010, SDK 2.10 and running on Win7. End user wanted to see live video of the shot before taking the picture. This works quite nicely. I did have to put invoke commands around the picture box update and refresh commands though, otherwise my program would crash. (thread issue?) It appears you did not have this problem… ? Also, in my varied reading and research on using these cameras like this, it seems that some people indicate that leaving it on continuously in live view mode is not good due to heat build up, leading to some type of problem? Have you ever encountered any issues running for days at at time?

  • Aleks, October 12th, 2011 on 5:25 am

    Greetings Justin! We’ve tested your piece of code with our Canon EOS 1000D. Our programme works fine. Presents Live View, takes pictures! We used Custom Canon provided SDK 2.10 vb wrapper and optimised it with the one you wrote. We succeeded! We also used Microsoft Visual Studio 2010, os Microsoft Windows XP Home Edition Version 2002 Service Pack 3.
    Thank you for your code and sharing. That’s well done! (by the way we encountered no error with “EdsDownloadEvfImage” or “error Unable to download Evf image – A102” like it was mentioned above, thus you piece of code is fine)

  • John, October 4th, 2011 on 12:35 am

    hi justin,

    got an error Unable to download Evf image – A102
    EdsGetPointer failed… how to do i fixed this one…

  • justin, September 24th, 2011 on 7:53 pm

    Are you saying when you run it through debug you see it work for 4 cycles and then it throws the error Cannot Download Evf Image?

  • jhandrew, September 24th, 2011 on 11:50 am

    I have try using EOS 1000D, its work only for 4 loop while liveview and get error download Evf image

  • justin, September 12th, 2011 on 10:34 am

    Hey Chris– Depends on the camera. With the 40D we started with it was very choppy. The 50D actually has video capabilities built in so it was a whole lot better. It ran live to Disney guests so it did turn out okay in the end. Is it super choppy or just not smooth enough for you? Also, what camera?

  • Chris, September 12th, 2011 on 4:08 am

    Have you guys been able to get a decent frame rate? Whenever I use live view the frame rate seems to be only a few frames per second.

  • marc, August 16th, 2011 on 1:05 pm

    Hi justin,

    Thanks for your help, you drove me in the right direction.

    I finally found a solution, the problem wasn’t caused by EdsDownloadEvfImage. I combined your code with another one and finally solved it.

    Here is a working code sample for LiveView using a Canon 40D and EDSDK v2.10 using VB.NET:

    There are some variables wich are Public Shared to comunicate with other classes, and avoid EdsDownloadEvfImage conflicts. Hope I solve someone else problems.

    #Region “Live View part”

    ‘// Creates an execute a thread with LiveView Function code
    Public Sub PreviewOn()


    LVThread = New Thread(AddressOf LiveView)

    LiveViewRunning = True


    End Sub

    Friend Sub LiveView()
    Dim first_time As Boolean = True

    While LiveViewRunning

    If LiveViewPaused Then ‘// pauses the LiveView to avoid conflicts while taking a picture
    first_time = True

    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 evfImage As IntPtr
    Dim pCamera As IntPtr

    err = EdsCreateMemoryStream(0, stream)

    If err = EDS_ERR_OK Then
    err = EdsCreateEvfImageRef(stream, evfImage)
    Dim str As String = Hex(err)
    End If

    If err = EDS_ERR_OK Then
    pCamera = model.getCameraObject()
    ‘// if it is the first time to execute the preview loop, waits 1,5 sec to avoid EDS_ERR_OBJECT_NOTREADY
    If first_time Then
    first_time = False
    End If
    err = EdsDownloadEvfImage(pCamera, evfImage)
    Dim str As String = Hex(err)
    MessageBox.Show(“&H” & str & “L”) ‘ Shows &H2CL which = ERR_FILE_FORMAT_NOT_RECOGNIZED’
    End If

    ”// PART WEB
    Dim n As Integer = 0
    err = EdsDownloadEvfImage(pCamera, evfImage)
    n = n + 1
    If n = 4 Then
    End If
    End While

    If err EDS_ERR_OK Then
    ‘Program.log(LogCategory.[Error], “Unable to download Evf image:{0:X}”, result)

    MessageBox.Show(“Unable to download Evf image – ” & Hex(err))
    Exit Sub
    End If

    ‘Program.log(LogCategory.Debug, “Downloaded Evf image data.”)

    ‘ extract image data into

    Dim ipData As IntPtr
    err = EdsGetPointer(stream, ipData)
    If err EDS_ERR_OK Then
    ‘Program.log(LogCategory.[Error], “EdsGetPointer failed: {0:X}”, result)

    MessageBox.Show(“EdsGetPointer failed”)
    Exit Sub
    End If

    Dim len As UInteger
    err = EDSDK.EdsGetLength(stream, len)
    If err EDS_ERR_OK Then
    ‘Program.log(LogCategory.[Error], “EdsGetLength failed:{0:X}”, result)

    MessageBox.Show(“EdsGetLength failed”)
    Exit Sub
    End If

    Dim buffer() As Byte = New Byte(CInt(len)) {}
    Marshal.Copy(ipData, buffer, 0, CInt(len))
    Dim memStream As New System.IO.MemoryStream(buffer)

    ‘ get the bitmap and draws the PictureBox
    Dim bitmap As Bitmap
    bitmap = bitmap.FromStream(memStream)
    LiveViewPictureBox.Image = bitmap

    ‘ cleanup

    End If
    End While
    Preview_Running = False
    End Sub

    #End Region

  • justin, August 15th, 2011 on 1:32 pm

    Hi Marc–

    We originally set out with the 40D and ended up with the 50D because the 40D has gobs of problems with Live View, it will still work though it was just too spotty for us to use inside of Disney.

    Basically what it is telling you is that the camera is not ready. Are you sure you are executing the commands prior to that to get the camera ready?

    I know what they mean with doing the loop. Basically the camera can sometimes get ready immediately and sometimes take 2 or 3 seconds.

    See if you can get the camera to initialize and let me know.

  • marc, August 15th, 2011 on 10:34 am


    I am working on my final career project and I am trying to use your code to make the liveview work, but I am having some problems.

    When executing this result = EDSDK.EdsDownloadEvfImage(pCamera, pImageEvf) it returns EDS_ERR_OBJECT_NOTREADY error. I decided to look on Internet and on documentation but they only recommend to do a loop and execute until error = EDS_ERR_OK.

    Did you had any problem with this error? Or do you know anyway to solve it?

    I am using a Canon 40D just like you, but wasn’t able to run this program properly.

    Thanks in advance.

  • justin, July 6th, 2011 on 9:06 am

    To see what this solution was actually used in at EPCOT take a look at this post. Should give you some ideas of how stable it ended up and what it is capable of. Keep up the work! I pulled out my hair for 4 months getting this to work so you guys get the leg up from that effort!

  • justin, July 6th, 2011 on 9:05 am

    Also, got this comment in email but no way to reply as no email address was left. My response is listed below

    Hi, i’m a complete newb to VB and using Visual Basic 2010 Express to try to create our own imaging application which would take picture(s) in live view and store them in the current record of a database.

    I’ve gotten the sample program to compile and added your code from your post on the subject but can’t get a “live view” window to open.

    I added a Picture Box (PictureBox1) to my VB Sample form, but don’t know how to get it to “attach” to the live view from the camera.

    I’m not even sure i’m editing the correct file (CameraControlDlg.vb), should i be editing CameraController.vb?

    I can send my current code if you can help. Or just offer some pointers?


    ———– ANSWER ———————–

    You need to name the Picture box the way it is named in the form and make sure it is on the same form as the main app. Then when the method runs it will run the Live View to the Picture Box.

  • justin, July 6th, 2011 on 8:58 am

    It seems there may be enough interest that I could post an anonymous read only access into our SVN repo to grab a snapshot of this code. It would be offered as is.

    I will gladly offer support but at this time I no longer have access to a camera as they were all sent to Disney when the Attraction went live.

  • justin, July 6th, 2011 on 8:56 am


    The issue Roberto had was referencing the DLL.

    You should be able to simply add the DLL to your BIN folder and then create a Reference to it. Simply Right Click on your project in Solution Explorer and click “Add Reference”.

    Browse for the DLL – now in your BIN folder and add it. This should make it available throughout the project.