title: Python call to Canon EDSDK 13.11.10 live view function for EdsDownloadEvfImage takes 2.6 secs
body: <p>I have the following issue with live view with my python ctypes interface to Canon EDSDK version 13.11.10 for windows 10: EdsDownloadEvfImage call takes about 2.6 secs. I am not sure how to improve the speed since this is a call to EDSDK function. </p>
  
  <p>Below is some timing info for the different functions called during download. These are called after receiving notification for change of display to PC. These tests were done on a Canon EOS Rebel SL3. </p>
  
  <pre><code>downloadEvfData: EdsCreateMemoryStream ok. time: 0.000
  downloadEvfData: EdsCreateEvfImageRef ok. time: 0.000
  downloadEvfData: EdsDownloadEvfImage ok, time: 2.589
  downloadEvfData: Length Ok = c_ulonglong(160035)
  downloadEvfData: Get length ok. time: 0.002
  downloadEvfData: Get pointer ok. time: 0.000
  downlaodEvfData: copy bytes time: 0.000
  downloadEvfData: full fn time: 2.598
  
  
  downloadEvfData: EdsCreateMemoryStream ok. time: 0.000
  downloadEvfData: EdsCreateEvfImageRef ok. time: 0.000
  downloadEvfData: EdsDownloadEvfImage ok, time: 2.587
  downloadEvfData: Length Ok = c_ulonglong(159924) 
  downloadEvfData: Get length ok. time: 0.002
  downloadEvfData: Get pointer ok. time: 0.001
  downlaodEvfData: copy bytes time: 0.000
  downloadEvfData: full fn time: 2.596
  </code></pre>
  
  <p>Once I get the notification for evf output change to PC - I start spawning threads at about the desired frame rate to start download process - the following functions are called for each frame of live data {get stream, get evf image reference, download evf image, get evf related parameters like zoom values, get length, get pointer, release evf image ref, release stream.} </p>
  
  <p>I can't seem to do any better than 2-3 fps. </p>
  
  <p>Below is a sample code from my download function using the Canon EDSDK version 13.11.10 for windows 10: </p>
  
  <pre><code>from ctypes import *
  
  err = c_int32(-1)        
  evfStream = c_void_p()
  evfImageRef = c_void_p()
  
  err = self.EDSDK64Dll.EdsCreateMemoryStream(0, byref(evfStream))
  
  err = self.EDSDK64Dll.EdsCreateEvfImageRef(evfStream, byref(evfImageRef))
  
  err = self.EDSDK64Dll.EdsDownloadEvfImage(inCameraRef, evfImageRef)
  
  outLength = c_uint64(0)
  err = self.EDSDK64Dll.EdsGetLength(evfStream, byref(outLength))
  
  image_data = (c_ubyte * outLength.value)()
  p_image_data = (POINTER(c_ubyte))(image_data)
  # get the pointer to the starting memory location of the stream
  err = self.EDSDK64Dll.EdsGetPointer(evfStream, byref(p_image_data))
  
  # copy over the data from obtained location of image_data
  # check if ctypes string_at can be used to speed up copy
  arr_bytes = bytearray(string_at(p_image_data, outLength.value)) 
  
  im = (Image.open(io.BytesIO(arr_bytes))).transpose(Image.FLIP_LEFT_RIGHT) # PIL image
  </code></pre>
  
  <p>A C# sample for live view works at a much faster frame rate on the same PC using the same EDSDK. </p>