Live View with Canon EDSDK 2.5.2 VB.NET


SUBMITTED BY: Guest

DATE: Nov. 20, 2013, 7:09 a.m.

FORMAT: Text only

SIZE: 31.0 kB

HITS: 711

  1. Private Sub btnStartLiveView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartLiveView.Click
  2. Dim err As Integer = EDS_ERR_OK
  3. Dim prop As Integer = EdsEvfOutputDevice.kEdsEvfOutputDevice_PC
  4. Dim proptype As Integer = EDSDKTypes.kEdsPropID_Evf_OutputDevice
  5. '// Stock the property.'
  6. Dim wkIntPtr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(prop))
  7. Marshal.StructureToPtr(prop, wkIntPtr, False)
  8. 'send property/command to the camera'
  9. EdsSetPropertyData(model.getCameraObject(), proptype, 0, Marshal.SizeOf(prop), prop)
  10. Dim stream As IntPtr
  11. Dim outMemoryRef As IntPtr
  12. Dim evfImage As IntPtr
  13. err = EdsCreateMemoryStream(0, stream)
  14. If err = EDS_ERR_OK Then
  15. err = EdsCreateImageRef(stream, outMemoryRef) '(stream, evfImage)'
  16. Else
  17. Dim str As String = Hex(err)
  18. MessageBox.Show(str)
  19. End If
  20. If err = EDS_ERR_OK Then
  21. err = EdsDownloadEvfImage(model.getCameraObject(), evfImage)
  22. Else
  23. Dim str As String = Hex(err)
  24. MessageBox.Show("&H" & str & "L") ' Shows &H2CL which = ERR_FILE_FORMAT_NOT_RECOGNIZED'
  25. End If
  26. ' Get the Incidental Data of the Image'
  27. If err = EDS_ERR_OK Then
  28. Dim zoom As UInt32
  29. Dim point As IntPtr
  30. EdsGetPropertyData(outMemoryRef, kEdsPropID_Evf_ZoomPosition, 0, Marshal.SizeOf(zoom), zoom)
  31. EdsGetPropertyData(outMemoryRef, kEdsPropID_Evf_ZoomPosition, 0, Marshal.SizeOf(point), point)
  32. Else
  33. 'MessageBox.Show(err.ToString())'
  34. End If
  35. Dim buffer(Marshal.SizeOf(stream)) As Byte
  36. Dim mStream As System.IO.Stream = New System.IO.MemoryStream(Marshal.SizeOf(stream))
  37. Dim gcTime As GCHandle = GCHandle.Alloc(0, GCHandleType.Pinned)
  38. Dim pTime As IntPtr = gcTime.AddrOfPinnedObject()
  39. Marshal.Copy(stream, buffer, 0, Marshal.SizeOf(stream))
  40. mStream.Write(buffer, 0, Marshal.SizeOf(stream))
  41. Me.PictureBox1.Image = Image.FromStream(mStream)
  42. EdsRelease(stream)
  43. End Sub
  44. Dim camera as New Camera
  45. camera.EstablishSession()
  46. camera.TakePicture("C:pathtosave.jpg")
  47. camera.StartLiveView(me.LiveViewPictureBox)
  48. camera.StopLiveView()
  49. camera.FlushTransferQueue()
  50. Imports CanonCamera.Sdk ' the .vb header file for the EDSDK
  51. Imports System.Runtime.InteropServices
  52. Imports System.Threading
  53. Imports System.Drawing
  54. Imports System.IO
  55. Public Class Camera
  56. Implements IDisposable
  57. Private m_cam As IntPtr
  58. Private m_oeh As EdsObjectEventHandler
  59. Private m_seh As EdsStateEventHandler
  60. Private m_peh As EdsPropertyEventHandler
  61. Private Shared s_instance As Camera = Nothing
  62. Private m_waitingOnPic As Boolean
  63. Private m_picOutFile As String
  64. ' live view
  65. Private Const LiveViewDelay = 200
  66. Private Const LiveViewFrameBufferSize = &H80000
  67. Private m_liveViewThread As Thread
  68. Private m_liveViewOn As Boolean
  69. Private m_waitingToStartLiveView As Boolean
  70. Private m_liveViewPicBox As PictureBox
  71. Private m_stoppingLiveView As Boolean
  72. Private m_liveViewFrameBuffer As Byte()
  73. Private m_liveViewBufferHandle As GCHandle
  74. Private m_liveViewStreamPtr As IntPtr
  75. Private Const SleepTimeout = 20000 ' how many milliseconds to wait before giving up
  76. Private Const SleepAmount = 50 ' how many milliseconds to sleep before doing the event pump
  77. Private m_transferQueue As Queue(Of TransferItem)
  78. Public Sub New()
  79. If s_instance Is Nothing Then
  80. s_instance = Me
  81. m_waitingOnPic = False
  82. m_liveViewOn = False
  83. m_waitingToStartLiveView = False
  84. m_liveViewPicBox = Nothing
  85. m_liveViewThread = Nothing
  86. m_stoppingLiveView = False
  87. ReDim m_liveViewFrameBuffer(0)
  88. m_liveViewBufferHandle = Nothing
  89. m_liveViewStreamPtr = IntPtr.Zero
  90. m_transferQueue = New Queue(Of TransferItem)
  91. CheckError(EdsInitializeSDK())
  92. Else
  93. Throw New OnlyOneInstanceAllowedException
  94. End If
  95. End Sub
  96. ''' <summary>
  97. ''' connect the computer to the camera. must be called before doing anything else.
  98. ''' </summary>
  99. ''' <remarks></remarks>
  100. Public Sub EstablishSession()
  101. Dim camList As IntPtr
  102. Dim numCams As Integer
  103. CheckError(EdsGetCameraList(camList))
  104. CheckError(EdsGetChildCount(camList, numCams))
  105. If numCams > 1 Then
  106. CheckError(EdsRelease(camList))
  107. Throw New TooManyCamerasFoundException
  108. ElseIf numCams = 0 Then
  109. CheckError(EdsRelease(camList))
  110. Throw New NoCameraFoundException
  111. End If
  112. 'get the only camera
  113. CheckError(EdsGetChildAtIndex(camList, 0, m_cam))
  114. 'release the camera list data
  115. CheckError(EdsRelease(camList))
  116. 'open a session
  117. CheckError(EdsOpenSession(m_cam))
  118. ' handlers
  119. m_seh = New EdsStateEventHandler(AddressOf StaticStateEventHandler)
  120. CheckError(EdsSetCameraStateEventHandler(m_cam, kEdsStateEvent_All, m_seh, New IntPtr(0)))
  121. m_oeh = New EdsObjectEventHandler(AddressOf StaticObjectEventHandler)
  122. CheckError(EdsSetObjectEventHandler(m_cam, kEdsObjectEvent_All, m_oeh, New IntPtr(0)))
  123. m_peh = New EdsPropertyEventHandler(AddressOf StaticPropertyEventHandler)
  124. CheckError(EdsSetPropertyEventHandler(m_cam, kEdsPropertyEvent_All, m_peh, New IntPtr(0)))
  125. 'set default options
  126. 'save to computer, not memory card
  127. CheckError(EdsSetPropertyData(m_cam, kEdsPropID_SaveTo, 0, Marshal.SizeOf(GetType(Integer)), CType(EdsSaveTo.kEdsSaveTo_Host, Integer)))
  128. ' enforce JPEG format
  129. Dim qs As New StructurePointer(Of UInt32)
  130. CheckError(EdsGetPropertyData(m_cam, kEdsPropID_ImageQuality, 0, qs.Size, qs.Pointer))
  131. ' clear the old image type setting and set the new one
  132. qs.Value = qs.Value And &HFF0FFFFFL Or (EdsImageType.kEdsImageType_Jpeg << 20)
  133. CheckError(EdsSetPropertyData(m_cam, kEdsPropID_ImageQuality, 0, qs.Size, qs.Value))
  134. End Sub
  135. Public Sub Dispose() Implements System.IDisposable.Dispose
  136. StopLiveView() 'stops it only if it's running
  137. FlushTransferQueue()
  138. CheckError(EdsCloseSession(m_cam))
  139. CheckError(EdsRelease(m_cam))
  140. CheckError(EdsTerminateSDK())
  141. s_instance = Nothing
  142. End Sub
  143. Private Sub CheckError(ByVal Err As Integer)
  144. ' throw errors if necessary
  145. If Err <> EDS_ERR_OK Then Throw New SdkException(Err)
  146. End Sub
  147. Private Shared Function StaticObjectEventHandler(ByVal inEvent As Integer, ByVal inRef As IntPtr, ByVal inContext As IntPtr) As Long
  148. 'transfer from static to member
  149. s_instance.ObjectEventHandler(inEvent, inRef, inContext)
  150. Return 0
  151. End Function
  152. Private Shared Function StaticStateEventHandler(ByVal inEvent As Integer, ByVal inParameter As Integer, ByVal inContext As IntPtr) As Long
  153. 'transfer from static to member
  154. s_instance.StateEventHandler(inEvent, inParameter, inContext)
  155. Return 0
  156. End Function
  157. Private Shared Function StaticPropertyEventHandler(ByVal inEvent As Integer, ByVal inPropertyID As Integer, ByVal inParam As Integer, ByVal inContext As IntPtr) As Long
  158. 'transfer from static to member
  159. s_instance.PropertyEventHandler(inEvent, inPropertyID, inParam, inContext)
  160. Return 0
  161. End Function
  162. Private Sub ObjectEventHandler(ByVal inEvent As Integer, ByVal inRef As IntPtr, ByVal inContext As IntPtr)
  163. Select Case inEvent
  164. Case kEdsObjectEvent_DirItemRequestTransfer
  165. ' queue up the transfer request
  166. Dim transfer As New TransferItem
  167. transfer.sdkRef = inRef
  168. transfer.outFile = m_picOutFile
  169. m_transferQueue.Enqueue(transfer)
  170. m_waitingOnPic = False ' allow other thread to continue
  171. Case Else
  172. Debug.Print(String.Format("ObjectEventHandler: event {0}", inEvent))
  173. End Select
  174. End Sub
  175. Public Sub FlushTransferQueue()
  176. While m_transferQueue.Count > 0
  177. ' transfer the image in memory to disk
  178. Dim transfer As TransferItem = m_transferQueue.Dequeue()
  179. Dim dirItemInfo As EdsDirectoryItemInfo = Nothing
  180. Dim outStream As IntPtr
  181. CheckError(EdsGetDirectoryItemInfo(transfer.sdkRef, dirItemInfo))
  182. ' This creates the outStream that is used by EdsDownload to actually grab and write out the file.
  183. CheckError(EdsCreateFileStream(transfer.outFile, EdsFileCreateDisposition.kEdsFileCreateDisposition_CreateAlways, EdsAccess.kEdsAccess_Write, outStream))
  184. ' do the transfer
  185. CheckError(EdsDownload(transfer.sdkRef, dirItemInfo.size, outStream))
  186. CheckError(EdsDownloadComplete(transfer.sdkRef))
  187. CheckError(EdsRelease(outStream))
  188. End While
  189. End Sub
  190. Private Sub StateEventHandler(ByVal inEvent As Integer, ByVal inParameter As Integer, ByVal inContext As IntPtr)
  191. Debug.Print(String.Format("stateEventHandler: event {0}, parameter {1}", inEvent, inParameter))
  192. End Sub
  193. Private Sub PropertyEventHandler(ByVal inEvent As Integer, ByVal inPropertyID As Integer, ByVal inParam As Integer, ByVal inContext As IntPtr)
  194. Select Case inPropertyID
  195. Case kEdsPropID_Evf_OutputDevice
  196. If m_waitingToStartLiveView Then
  197. 'start live view thread
  198. m_liveViewThread = New Thread(AddressOf UpdateLiveView)
  199. m_liveViewThread.Start()
  200. 'save state
  201. m_waitingToStartLiveView = False
  202. m_liveViewOn = True
  203. End If
  204. Case Else
  205. Debug.Print("property event handler called, propid = " & inPropertyID)
  206. End Select
  207. End Sub
  208. '''<summary>snap a photo with the camera and write it to outfile</summary>
  209. ''' <param name="OutFile">the file to save the picture to</param>
  210. Public Sub TakePicture(ByVal OutFile As String)
  211. Dim interuptingLiveView As Boolean = m_liveViewOn
  212. Dim lvBox As PictureBox = m_liveViewPicBox
  213. If m_waitingOnPic Or m_waitingToStartLiveView Then
  214. ' bad programmer. should have disabled user controls
  215. Throw New CameraIsBusyException
  216. Exit Sub
  217. End If
  218. If interuptingLiveView Then StopLiveView()
  219. ' set flag indicating we are waiting on a callback call
  220. m_waitingOnPic = True
  221. m_picOutFile = OutFile
  222. ' take a picture with the camera and save it to outfile
  223. Dim err As Integer = EdsSendCommand(m_cam, EdsCameraCommand.kEdsCameraCommand_TakePicture, 0)
  224. If err <> EDS_ERR_OK Then
  225. m_waitingOnPic = False
  226. CheckError(err)
  227. End If
  228. Dim I As Integer
  229. For I = 0 To SleepTimeout / SleepAmount
  230. System.Threading.Thread.Sleep(SleepAmount)
  231. Application.DoEvents()
  232. If Not m_waitingOnPic Then
  233. If interuptingLiveView Then StartLiveView(lvBox)
  234. Exit Sub 'success
  235. End If
  236. Next I
  237. ' we never got a callback. throw an error
  238. If interuptingLiveView Then StartLiveView(lvBox)
  239. m_waitingOnPic = False
  240. Throw New TakePictureFailedException
  241. End Sub
  242. Private Sub StartBulb()
  243. Dim err As Integer
  244. CheckError(EdsSendStatusCommand(m_cam, EdsCameraStatusCommand.kEdsCameraStatusCommand_UILock, 0))
  245. err = EdsSendCommand(m_cam, EdsCameraCommand.kEdsCameraCommand_BulbStart, 0)
  246. ' call ui unlock if bulbstart fails
  247. If err <> EDS_ERR_OK Then
  248. EdsSendStatusCommand(m_cam, EdsCameraStatusCommand.kEdsCameraStatusCommand_UIUnLock, 0)
  249. CheckError(err)
  250. End If
  251. End Sub
  252. Private Sub StopBulb()
  253. Dim err As Integer, err2 As Integer
  254. ' call ui unlock even if bulb end fails
  255. err = EdsSendCommand(m_cam, EdsCameraCommand.kEdsCameraCommand_BulbEnd, 0)
  256. err2 = EdsSendCommand(m_cam, EdsCameraStatusCommand.kEdsCameraStatusCommand_UIUnLock, 0)
  257. CheckError(err)
  258. CheckError(err2)
  259. End Sub
  260. '''<summary>start streaming live video to pbox</summary>
  261. '''<param name="pbox">the picture box to send live video to</param>
  262. ''' <remarks>you can only have one live view going at a time.</remarks>
  263. Public Sub StartLiveView(ByVal pbox As PictureBox)
  264. While m_stoppingLiveView
  265. Application.DoEvents()
  266. End While
  267. If m_waitingToStartLiveView Then
  268. m_liveViewPicBox = pbox
  269. Return
  270. ElseIf m_liveViewOn Then
  271. StopLiveView()
  272. End If
  273. Dim device As New StructurePointer(Of UInt32)
  274. ' tell the camera to send live data to the computer
  275. CheckError(EdsGetPropertyData(m_cam, kEdsPropID_Evf_OutputDevice, 0, device.Size, device.Pointer))
  276. device.Value = device.Value Or EdsEvfOutputDevice.kEdsEvfOutputDevice_PC
  277. CheckError(EdsSetPropertyData(m_cam, kEdsPropID_Evf_OutputDevice, 0, device.Size, device.Value))
  278. ' get ready to stream
  279. m_liveViewPicBox = pbox
  280. m_waitingToStartLiveView = True
  281. ' set up buffer
  282. ReDim m_liveViewFrameBuffer(LiveViewFrameBufferSize)
  283. m_liveViewBufferHandle = GCHandle.Alloc(m_liveViewFrameBuffer, GCHandleType.Pinned)
  284. CheckError(EdsCreateMemoryStreamFromPointer(m_liveViewBufferHandle.AddrOfPinnedObject, LiveViewFrameBufferSize, m_liveViewStreamPtr))
  285. ' pause this thread until live view starts
  286. Dim I As Integer
  287. For I = 0 To SleepTimeout / SleepAmount
  288. System.Threading.Thread.Sleep(SleepAmount)
  289. Application.DoEvents()
  290. If Not m_waitingToStartLiveView Then Exit Sub 'success
  291. Next I
  292. ' we never got a callback. throw an error
  293. StopLiveView()
  294. Throw New LiveViewFailedException
  295. End Sub
  296. ''' <summary>
  297. ''' stop streaming live video
  298. ''' </summary>
  299. ''' <remarks></remarks>
  300. Public Sub StopLiveView()
  301. Dim device As New StructurePointer(Of UInt32)
  302. If m_stoppingLiveView Or (Not m_waitingToStartLiveView And Not m_liveViewOn) Then Exit Sub
  303. If m_liveViewOn Then
  304. ' stop thread
  305. m_stoppingLiveView = True
  306. m_liveViewThread.Join()
  307. End If
  308. ' save state
  309. m_liveViewOn = False
  310. m_waitingToStartLiveView = False
  311. m_liveViewPicBox = Nothing
  312. m_stoppingLiveView = False
  313. ' tell the camera not to send live data to the computer
  314. CheckError(EdsGetPropertyData(m_cam, kEdsPropID_Evf_OutputDevice, 0, device.Size, device.Pointer))
  315. device.Value = device.Value And Not EdsEvfOutputDevice.kEdsEvfOutputDevice_PC
  316. CheckError(EdsSetPropertyData(m_cam, kEdsPropID_Evf_OutputDevice, 0, device.Size, device.Value))
  317. ' clean up
  318. CheckError(EdsRelease(m_liveViewStreamPtr))
  319. m_liveViewBufferHandle.Free()
  320. End Sub
  321. Private Sub UpdateLiveView()
  322. Dim nowPlusInterval As Long
  323. While Not m_stoppingLiveView
  324. nowPlusInterval = Now.Ticks + LiveViewDelay
  325. ShowLiveViewFrame()
  326. Thread.Sleep(Math.Max(nowPlusInterval - Now.Ticks, 0))
  327. End While
  328. End Sub
  329. Private Sub ShowLiveViewFrame()
  330. Dim err As Integer = 0
  331. Dim imagePtr As IntPtr
  332. ' create image
  333. CheckError(EdsCreateEvfImageRef(m_liveViewStreamPtr, imagePtr))
  334. ' download the frame
  335. Try
  336. CheckError(EdsDownloadEvfImage(m_cam, imagePtr))
  337. Catch ex As SdkException When ex.SdkError = SdkErrors.ObjectNotready
  338. CheckError(EdsRelease(imagePtr))
  339. Exit Sub
  340. End Try
  341. ' get it into the picture box image
  342. Dim canonImg As Image = Image.FromStream(New MemoryStream(m_liveViewFrameBuffer)) 'do not dispose the MemoryStream (Image.FromStream)
  343. Dim oldImg As Image = m_liveViewPicBox.Image
  344. m_liveViewPicBox.Image = canonImg
  345. If oldImg IsNot Nothing Then oldImg.Dispose() 'really is required.
  346. ' release image
  347. CheckError(EdsRelease(imagePtr))
  348. End Sub
  349. Protected Overrides Sub Finalize()
  350. Dispose()
  351. MyBase.Finalize()
  352. End Sub
  353. Private Class StructurePointer(Of T As Structure)
  354. Implements IDisposable
  355. Private m_Size As Integer 'in bytes
  356. Private m_ptr As IntPtr
  357. Public ReadOnly Property Size() As Integer
  358. Get
  359. Return m_Size
  360. End Get
  361. End Property
  362. Public ReadOnly Property Pointer() As IntPtr
  363. Get
  364. Return m_ptr
  365. End Get
  366. End Property
  367. Public Property Value() As T
  368. Get
  369. Return Marshal.PtrToStructure(m_ptr, GetType(T))
  370. End Get
  371. Set(ByVal value As T)
  372. Marshal.StructureToPtr(value, m_ptr, True)
  373. End Set
  374. End Property
  375. Public Sub New()
  376. m_Size = Marshal.SizeOf(GetType(T))
  377. m_ptr = Marshal.AllocHGlobal(m_Size)
  378. End Sub
  379. Public Sub Dispose() Implements IDisposable.Dispose
  380. Marshal.FreeHGlobal(m_ptr)
  381. End Sub
  382. Protected Overrides Sub Finalize()
  383. Dispose()
  384. MyBase.Finalize()
  385. End Sub
  386. End Class
  387. Private Structure TransferItem
  388. Public sdkRef As IntPtr
  389. Public outFile As String
  390. End Structure
  391. End Class
  392. Public Class SdkException
  393. Inherits Exception
  394. Private m_Message As String
  395. Public ReadOnly Property SdkError() As String
  396. Get
  397. Return m_Message
  398. End Get
  399. End Property
  400. Public Sub New(ByVal errCode As Integer)
  401. m_Message = SdkErrors.StringFromErrorCode(errCode)
  402. End Sub
  403. Public Overrides ReadOnly Property Message() As String
  404. Get
  405. Return m_Message
  406. End Get
  407. End Property
  408. End Class
  409. Public NotInheritable Class SdkErrors
  410. Private Sub New() 'static class
  411. End Sub
  412. Private Shared m_dict As Dictionary(Of Integer, String)
  413. Public Shared Function StringFromErrorCode(ByVal errCode As Integer) As String
  414. If m_dict Is Nothing Then initDict()
  415. If m_dict.ContainsKey(errCode) Then
  416. Return m_dict.Item(errCode)
  417. Else
  418. Return "Error code: " & errCode
  419. End If
  420. End Function
  421. #Region "Generated Code"
  422. Private Shared Sub initDict()
  423. m_dict = New Dictionary(Of Integer, String)(117)
  424. ' Miscellaneous errors
  425. m_dict.Add(EDS_ERR_UNIMPLEMENTED, Unimplemented)
  426. m_dict.Add(EDS_ERR_INTERNAL_ERROR, InternalError)
  427. m_dict.Add(EDS_ERR_MEM_ALLOC_FAILED, MemAllocFailed)
  428. m_dict.Add(EDS_ERR_MEM_FREE_FAILED, MemFreeFailed)
  429. m_dict.Add(EDS_ERR_OPERATION_CANCELLED, OperationCancelled)
  430. m_dict.Add(EDS_ERR_INCOMPATIBLE_VERSION, IncompatibleVersion)
  431. m_dict.Add(EDS_ERR_NOT_SUPPORTED, NotSupported)
  432. m_dict.Add(EDS_ERR_UNEXPECTED_EXCEPTION, UnexpectedException)
  433. m_dict.Add(EDS_ERR_PROTECTION_VIOLATION, ProtectionViolation)
  434. m_dict.Add(EDS_ERR_MISSING_SUBCOMPONENT, MissingSubcomponent)
  435. m_dict.Add(EDS_ERR_SELECTION_UNAVAILABLE, SelectionUnavailable)
  436. ' File errors
  437. m_dict.Add(EDS_ERR_FILE_IO_ERROR, FileIoError)
  438. m_dict.Add(EDS_ERR_FILE_TOO_MANY_OPEN, FileTooManyOpen)
  439. m_dict.Add(EDS_ERR_FILE_NOT_FOUND, FileNotFound)
  440. m_dict.Add(EDS_ERR_FILE_OPEN_ERROR, FileOpenError)
  441. m_dict.Add(EDS_ERR_FILE_CLOSE_ERROR, FileCloseError)
  442. m_dict.Add(EDS_ERR_FILE_SEEK_ERROR, FileSeekError)
  443. m_dict.Add(EDS_ERR_FILE_TELL_ERROR, FileTellError)
  444. m_dict.Add(EDS_ERR_FILE_READ_ERROR, FileReadError)
  445. m_dict.Add(EDS_ERR_FILE_WRITE_ERROR, FileWriteError)
  446. m_dict.Add(EDS_ERR_FILE_PERMISSION_ERROR, FilePermissionError)
  447. m_dict.Add(EDS_ERR_FILE_DISK_FULL_ERROR, FileDiskFullError)
  448. m_dict.Add(EDS_ERR_FILE_ALREADY_EXISTS, FileAlreadyExists)
  449. m_dict.Add(EDS_ERR_FILE_FORMAT_UNRECOGNIZED, FileFormatUnrecognized)
  450. m_dict.Add(EDS_ERR_FILE_DATA_CORRUPT, FileDataCorrupt)
  451. m_dict.Add(EDS_ERR_FILE_NAMING_NA, FileNamingNa)
  452. ' Directory errors
  453. m_dict.Add(EDS_ERR_DIR_NOT_FOUND, DirNotFound)
  454. m_dict.Add(EDS_ERR_DIR_IO_ERROR, DirIoError)
  455. m_dict.Add(EDS_ERR_DIR_ENTRY_NOT_FOUND, DirEntryNotFound)
  456. m_dict.Add(EDS_ERR_DIR_ENTRY_EXISTS, DirEntryExists)
  457. m_dict.Add(EDS_ERR_DIR_NOT_EMPTY, DirNotEmpty)
  458. ' Property errors
  459. m_dict.Add(EDS_ERR_PROPERTIES_UNAVAILABLE, PropertiesUnavailable)
  460. m_dict.Add(EDS_ERR_PROPERTIES_MISMATCH, PropertiesMismatch)
  461. m_dict.Add(EDS_ERR_PROPERTIES_NOT_LOADED, PropertiesNotLoaded)
  462. ' Function Parameter errors
  463. m_dict.Add(EDS_ERR_INVALID_PARAMETER, InvalidParameter)
  464. m_dict.Add(EDS_ERR_INVALID_HANDLE, InvalidHandle)
  465. m_dict.Add(EDS_ERR_INVALID_POINTER, InvalidPointer)
  466. m_dict.Add(EDS_ERR_INVALID_INDEX, InvalidIndex)
  467. m_dict.Add(EDS_ERR_INVALID_LENGTH, InvalidLength)
  468. m_dict.Add(EDS_ERR_INVALID_FN_POINTER, InvalidFnPointer)
  469. m_dict.Add(EDS_ERR_INVALID_SORT_FN, InvalidSortFn)
  470. ' Device errors
  471. m_dict.Add(EDS_ERR_DEVICE_NOT_FOUND, DeviceNotFound)
  472. m_dict.Add(EDS_ERR_DEVICE_BUSY, DeviceBusy)
  473. m_dict.Add(EDS_ERR_DEVICE_INVALID, DeviceInvalid)
  474. m_dict.Add(EDS_ERR_DEVICE_EMERGENCY, DeviceEmergency)
  475. m_dict.Add(EDS_ERR_DEVICE_MEMORY_FULL, DeviceMemoryFull)
  476. m_dict.Add(EDS_ERR_DEVICE_INTERNAL_ERROR, DeviceInternalError)
  477. m_dict.Add(EDS_ERR_DEVICE_INVALID_PARAMETER, DeviceInvalidParameter)
  478. m_dict.Add(EDS_ERR_DEVICE_NO_DISK, DeviceNoDisk)
  479. m_dict.Add(EDS_ERR_DEVICE_DISK_ERROR, DeviceDiskError)
  480. m_dict.Add(EDS_ERR_DEVICE_CF_GATE_CHANGED, DeviceCfGateChanged)
  481. m_dict.Add(EDS_ERR_DEVICE_DIAL_CHANGED, DeviceDialChanged)
  482. m_dict.Add(EDS_ERR_DEVICE_NOT_INSTALLED, DeviceNotInstalled)
  483. m_dict.Add(EDS_ERR_DEVICE_STAY_AWAKE, DeviceStayAwake)
  484. m_dict.Add(EDS_ERR_DEVICE_NOT_RELEASED, DeviceNotReleased)
  485. ' Stream errors
  486. m_dict.Add(EDS_ERR_STREAM_IO_ERROR, StreamIoError)
  487. m_dict.Add(EDS_ERR_STREAM_NOT_OPEN, StreamNotOpen)
  488. m_dict.Add(EDS_ERR_STREAM_ALREADY_OPEN, StreamAlreadyOpen)
  489. m_dict.Add(EDS_ERR_STREAM_OPEN_ERROR, StreamOpenError)
  490. m_dict.Add(EDS_ERR_STREAM_CLOSE_ERROR, StreamCloseError)
  491. m_dict.Add(EDS_ERR_STREAM_SEEK_ERROR, StreamSeekError)
  492. m_dict.Add(EDS_ERR_STREAM_TELL_ERROR, StreamTellError)
  493. m_dict.Add(EDS_ERR_STREAM_READ_ERROR, StreamReadError)
  494. m_dict.Add(EDS_ERR_STREAM_WRITE_ERROR, StreamWriteError)
  495. m_dict.Add(EDS_ERR_STREAM_PERMISSION_ERROR, StreamPermissionError)
  496. m_dict.Add(EDS_ERR_STREAM_COULDNT_BEGIN_THREAD, StreamCouldntBeginThread)
  497. m_dict.Add(EDS_ERR_STREAM_BAD_OPTIONS, StreamBadOptions)
  498. m_dict.Add(EDS_ERR_STREAM_END_OF_STREAM, StreamEndOfStream)
  499. ' Communications errors
  500. m_dict.Add(EDS_ERR_COMM_PORT_IS_IN_USE, CommPortIsInUse)
  501. m_dict.Add(EDS_ERR_COMM_DISCONNECTED, CommDisconnected)
  502. m_dict.Add(EDS_ERR_COMM_DEVICE_INCOMPATIBLE, CommDeviceIncompatible)
  503. m_dict.Add(EDS_ERR_COMM_BUFFER_FULL, CommBufferFull)
  504. m_dict.Add(EDS_ERR_COMM_USB_BUS_ERR, CommUsbBusErr)
  505. ' Lock/Unlock
  506. m_dict.Add(EDS_ERR_USB_DEVICE_LOCK_ERROR, UsbDeviceLockError)
  507. m_dict.Add(EDS_ERR_USB_DEVICE_UNLOCK_ERROR, UsbDeviceUnlockError)
  508. ' STI/WIA
  509. m_dict.Add(EDS_ERR_STI_UNKNOWN_ERROR, StiUnknownError)
  510. m_dict.Add(EDS_ERR_STI_INTERNAL_ERROR, StiInternalError)
  511. m_dict.Add(EDS_ERR_STI_DEVICE_CREATE_ERROR, StiDeviceCreateError)
  512. m_dict.Add(EDS_ERR_STI_DEVICE_RELEASE_ERROR, StiDeviceReleaseError)
  513. m_dict.Add(EDS_ERR_DEVICE_NOT_LAUNCHED, DeviceNotLaunched)
  514. m_dict.Add(EDS_ERR_ENUM_NA, EnumNa)
  515. m_dict.Add(EDS_ERR_INVALID_FN_CALL, InvalidFnCall)
  516. m_dict.Add(EDS_ERR_HANDLE_NOT_FOUND, HandleNotFound)
  517. m_dict.Add(EDS_ERR_INVALID_ID, InvalidId)
  518. m_dict.Add(EDS_ERR_WAIT_TIMEOUT_ERROR, WaitTimeoutError)
  519. ' PTP
  520. m_dict.Add(EDS_ERR_SESSION_NOT_OPEN, SessionNotOpen)
  521. m_dict.Add(EDS_ERR_INVALID_TRANSACTIONID, InvalidTransactionid)
  522. m_dict.Add(EDS_ERR_INCOMPLETE_TRANSFER, IncompleteTransfer)
  523. m_dict.Add(EDS_ERR_INVALID_STRAGEID, InvalidStrageid)
  524. m_dict.Add(EDS_ERR_DEVICEPROP_NOT_SUPPORTED, DevicepropNotSupported)
  525. m_dict.Add(EDS_ERR_INVALID_OBJECTFORMATCODE, InvalidObjectformatcode)
  526. m_dict.Add(EDS_ERR_SELF_TEST_FAILED, SelfTestFailed)
  527. m_dict.Add(EDS_ERR_PARTIAL_DELETION, PartialDeletion)
  528. m_dict.Add(EDS_ERR_SPECIFICATION_BY_FORMAT_UNSUPPORTED, SpecificationByFormatUnsupported)
  529. m_dict.Add(EDS_ERR_NO_VALID_OBJECTINFO, NoValidObjectinfo)
  530. m_dict.Add(EDS_ERR_INVALID_CODE_FORMAT, InvalidCodeFormat)
  531. m_dict.Add(EDS_ERR_UNKNOWN_VENDER_CODE, UnknownVenderCode)
  532. m_dict.Add(EDS_ERR_CAPTURE_ALREADY_TERMINATED, CaptureAlreadyTerminated)
  533. m_dict.Add(EDS_ERR_INVALID_PARENTOBJECT, InvalidParentobject)
  534. m_dict.Add(EDS_ERR_INVALID_DEVICEPROP_FORMAT, InvalidDevicepropFormat)
  535. m_dict.Add(EDS_ERR_INVALID_DEVICEPROP_VALUE, InvalidDevicepropValue)
  536. m_dict.Add(EDS_ERR_SESSION_ALREADY_OPEN, SessionAlreadyOpen)
  537. m_dict.Add(EDS_ERR_TRANSACTION_CANCELLED, TransactionCancelled)
  538. m_dict.Add(EDS_ERR_SPECIFICATION_OF_DESTINATION_UNSUPPORTED, SpecificationOfDestinationUnsupported)
  539. m_dict.Add(EDS_ERR_UNKNOWN_COMMAND, UnknownCommand)
  540. m_dict.Add(EDS_ERR_OPERATION_REFUSED, OperationRefused)
  541. m_dict.Add(EDS_ERR_LENS_COVER_CLOSE, LensCoverClose)
  542. m_dict.Add(EDS_ERR_LOW_BATTERY, LowBattery)
  543. m_dict.Add(EDS_ERR_OBJECT_NOTREADY, ObjectNotready)
  544. m_dict.Add(EDS_ERR_TAKE_PICTURE_AF_NG, TakePictureAfNg)
  545. m_dict.Add(EDS_ERR_TAKE_PICTURE_RESERVED, TakePictureReserved)
  546. m_dict.Add(EDS_ERR_TAKE_PICTURE_MIRROR_UP_NG, TakePictureMirrorUpNg)
  547. m_dict.Add(EDS_ERR_TAKE_PICTURE_SENSOR_CLEANING_NG, TakePictureSensorCleaningNg)
  548. m_dict.Add(EDS_ERR_TAKE_PICTURE_SILENCE_NG, TakePictureSilenceNg)
  549. m_dict.Add(EDS_ERR_TAKE_PICTURE_NO_CARD_NG, TakePictureNoCardNg)
  550. m_dict.Add(EDS_ERR_TAKE_PICTURE_CARD_NG, TakePictureCardNg)
  551. m_dict.Add(EDS_ERR_TAKE_PICTURE_CARD_PROTECT_NG, TakePictureCardProtectNg)
  552. ' 44313 ???
  553. End Sub
  554. ' Miscellaneous errors
  555. Public Const Unimplemented = "Unimplemented"
  556. Public Const InternalError = "Internal Error"
  557. Public Const MemAllocFailed = "Mem Alloc Failed"
  558. Public Const MemFreeFailed = "Mem Free Failed"
  559. Public Const OperationCancelled = "Operation Cancelled"
  560. Public Const IncompatibleVersion = "Incompatible Version"
  561. Public Const NotSupported = "Not Supported"
  562. Public Const UnexpectedException = "Unexpected Exception"
  563. Public Const ProtectionViolation = "Protection Violation"
  564. Public Const MissingSubcomponent = "Missing Subcomponent"
  565. Public Const SelectionUnavailable = "Selection Unavailable"
  566. ' File errors
  567. Public Const FileIoError = "File IO Error"
  568. Public Const FileTooManyOpen = "File Too Many Open"
  569. Public Const FileNotFound = "File Not Found"
  570. Public Const FileOpenError = "File Open Error"
  571. Public Const FileCloseError = "File Close Error"
  572. Public Const FileSeekError = "File Seek Error"
  573. Public Const FileTellError = "File Tell Error"
  574. Public Const FileReadError = "File Read Error"
  575. Public Const FileWriteError = "File Write Error"
  576. Public Const FilePermissionError = "File Permission Error"
  577. Public Const FileDiskFullError = "File Disk Full Error"
  578. Public Const FileAlreadyExists = "File Already Exists"
  579. Public Const FileFormatUnrecognized = "File Format Unrecognized"
  580. Public Const FileDataCorrupt = "File Data Corrupt"
  581. Public Const FileNamingNa = "File Naming NA"
  582. ' Directory errors
  583. Public Const DirNotFound = "Dir Not Found"
  584. Public Const DirIoError = "Dir IO Error"
  585. Public Const DirEntryNotFound = "Dir Entry Not Found"
  586. Public Const DirEntryExists = "Dir Entry Exists"
  587. Public Const DirNotEmpty = "Dir Not Empty"
  588. ' Property errors

comments powered by Disqus