Platforms to show: All Mac Windows Linux Cross-Platform

Required plugins for this example: MBS Cameras Plugin, MBS Images Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Cameras/CanonEOSDigital/Example
This example is the version from Tue, 26th Sep 2016.
Project "Example.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Close() if inited then // you can have trouble if you don't cleanup properly EDSModuleMBS.Terminate end if End EventHandler
EventHandler Sub Open() DebugCopyFrameworks dim file as FolderItem // find DLL in application folder if TargetWin32 then file = FindFile("EDSDK.dll") elseif TargetMacOS then // find Framework in inside frameworks folder in app bundle dim frameworks as FolderItem = app.ExecutableFile.Parent.parent.Child("Frameworks") file = frameworks.Child("EDSDK.framework") else MsgBox "not supported." end if // pass true for version 2.x of SDK or false for 3.x dim isVersion2 as Boolean = true // load framework or DLL if EDSModuleMBS.LoadLibrary(file, isVersion2) then EDSModuleMBS.Initialize dim e as integer = EDSModuleMBS.Lasterror if e = 0 then Inited = true // okay, so wait for cameras cah = new MyEdsCameraAddedHandlerMBS MainWindow.OpenDevice else MsgBox "Failed to initialize: "+str(e) end if else MsgBox "Failed to load library." end if End EventHandler
Sub DebugCopyFrameworks() // for debug mode I used to copy the framework files into the app on startup // makes debugging much easier! if DebugBuild and TargetMachO then dim frameworks as FolderItem = app.ExecutableFile.Parent.parent.Child("Frameworks") dim f as FolderItem = FindFile("EDSDK.framework") f.CopyFileTo frameworks f = FindFile("DPP.framework") f.CopyFileTo frameworks end if End Sub
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
Property Inited As Boolean
Property cah As MyEdsCameraAddedHandlerMBS
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub Change() UpdateButton End EventHandler
EventHandler Sub ExpandRow(row As Integer) dim v as Variant = me.RowTag(row) if v isa EdsCameraMBS then dim camera as EdsCameraMBS = v camera.OpenSession dim u as integer = camera.ChildCount-1 CheckError camera for i as integer = 0 to u Add camera.Child(i) next elseif v isa EdsVolumeMBS then dim volume as EdsVolumeMBS = v dim u as integer = volume.ChildCount-1 System.DebugLog "Lasterror: "+str(volume.Lasterror) for i as integer = 0 to u add volume.Child(i) next elseif v isa EdsDirectoryItemMBS then dim folder as EdsDirectoryItemMBS = v dim u as integer = folder.ChildCount-1 System.DebugLog "Lasterror: "+str(folder.Lasterror) for i as integer = 0 to u add folder.Child(i) next end if End EventHandler
End Control
Control TakePictureButton Inherits PushButton
ControlInstance TakePictureButton Inherits PushButton
EventHandler Sub Action() // send take picture command // set save to host if you don't have a SD card 'camera.SetPropertyDataInt32(camera.kEdsPropID_SaveTo, 0, EDSModuleMBS.kEdsSaveTo_Host) 'CheckError camera camera.SendCommand camera.kEdsCameraCommand_TakePicture CheckError camera End EventHandler
End Control
Control ShowPictureButton Inherits PushButton
ControlInstance ShowPictureButton Inherits PushButton
EventHandler Sub Action() // download selected file dim c as EdsDirectoryItemMBS = List.RowTag(List.ListIndex) dim info as EdsDirectoryItemInfoMBS = c.DirectoryItemInfo dim file as FolderItem = SpecialFolder.Desktop.Child(info.FileName) stream = new EdsStreamMBS(file, EdsStreamMBS.kEdsFileCreateDisposition_CreateNew, EdsStreamMBS.kEdsAccess_Write) // with progress, so we install progress callback bar.Value = 0 bar.Visible = true Progress = new MyEdsProgressMBS stream.SetProgress Progress, c.kEdsProgressOption_Periodically CheckError c // run download c.Download(info.Size, stream) CheckError c // tell camera we are done c.DownloadComplete CheckError c // cleanup stream = nil bar.Visible = false // and show file file.Launch End EventHandler
End Control
Control bar Inherits ProgressBar
ControlInstance bar Inherits ProgressBar
End Control
Control DeleteFileButton Inherits PushButton
ControlInstance DeleteFileButton Inherits PushButton
EventHandler Sub Action() // delete a file dim c as EdsDirectoryItemMBS = List.RowTag(List.ListIndex) c.DeleteDirectoryItem CheckError c List.RemoveRow List.ListIndex End EventHandler
End Control
Control StartLiveButton Inherits PushButton
ControlInstance StartLiveButton Inherits PushButton
EventHandler Sub Action() StartLiveView camera End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() EDSModuleMBS.GetEvent if EDSModuleMBS.Lasterror <> 0 then me.Mode = 0 MsgBox "Error "+str(EDSModuleMBS.Lasterror)+": "+GetErrorMessage(EDSModuleMBS.Lasterror) end if End EventHandler
End Control
Sub Add(v as EdsDirectoryItemMBS) if v<>nil then dim info as EdsDirectoryItemInfoMBS = v.DirectoryItemInfo if info.IsFolder then List.AddFolder info.FileName else List.AddRow info.FileName end if List.RowTag(List.LastIndex) = v end if End Sub
Sub Add(v as EdsVolumeMBS) if v<>nil then dim info as EdsVolumeInfoMBS = v.VolumeInfo List.AddFolder info.VolumeLabel List.RowTag(List.LastIndex) = v end if End Sub
Sub Clear() List.DeleteAllRows TakePictureButton.Enabled = false StartLiveButton.Enabled = false camera = nil End Sub
Sub OpenDevice() if camera <> nil then Return // ignore second device List.DeleteAllRows dim c as EdsCameraListMBS = EDSModuleMBS.GetCameraList if c<>Nil then dim count as integer = c.ChildCount if count>0 then // we only care for first device camera = c.Child(0) camera.OpenSession // we install a couple of handlers to get events from device MyEdsObjectEventHandler = new MyEdsObjectEventHandlerMBS(camera, EDSModuleMBS.kEdsObjectEvent_All) MyEdsCameraStateEventHandler = new MyEdsCameraStateEventHandlerMBS(camera, EDSModuleMBS.kEdsStateEvent_All) MyEdsPropertyEventHandler = new MyEdsPropertyEventHandlerMBS(camera, EDSModuleMBS.kEdsPropertyEvent_All) = camera timer1.Mode = 2 dim d as EdsDeviceInfoMBS = camera.DeviceInfo List.AddFolder d.DeviceDescription List.RowTag(MainWindow.List.LastIndex) = camera TakePictureButton.Enabled = true StartLiveButton.Enabled = true end if end if End Sub
Sub StartLiveView(camera as EdsCameraMBS) // we set bit for redirecting output to PC, leave other bits as they are. dim device as UInt32 = camera.GetPropertyDataUInt32(camera.kEdsPropID_Evf_OutputDevice) CheckError camera if camera.lasterror = EDSModuleMBS.EDS_ERR_OK then device = Bitwise.BitOr(device, EDSModuleMBS.kEdsEvfOutputDevice_PC) camera.SetPropertyDataUInt32 camera.kEdsPropID_Evf_OutputDevice, 0, device CheckError camera System.DebugLog "Set Property" PicWindow.Camera = camera end if End Sub
Sub StopLiveView(camera as EdsCameraMBS) // we reset the output device bits to not include PC dim device as UInt32 = camera.GetPropertyDataUInt32(camera.kEdsPropID_Evf_OutputDevice) CheckError camera if camera.lasterror = EDSModuleMBS.EDS_ERR_OK then dim n as Uint32 = EDSModuleMBS.kEdsEvfOutputDevice_PC n = Bitwise.OnesComplement(n) device = Bitwise.BitAnd(device, n) camera.SetPropertyDataUInt32 camera.kEdsPropID_Evf_OutputDevice, 0, device end if End Sub
Sub UpdateButton() if camera<>nil then TakePictureButton.enabled = true StartLiveButton.Enabled = true else TakePictureButton.enabled = false StartLiveButton.Enabled = false end if if List.ListIndex >= 0 then dim v as Variant = List.RowTag(List.ListIndex) if v isa EdsCameraMBS then ShowPictureButton.Enabled = false DeleteFileButton.Enabled = false elseif v isa EdsDirectoryItemMBS then dim d as EdsDirectoryItemMBS = v if d.DirectoryItemInfo.IsFolder then ShowPictureButton.Enabled = false DeleteFileButton.Enabled = false else ShowPictureButton.Enabled = true DeleteFileButton.Enabled = true end if else ShowPictureButton.Enabled = false DeleteFileButton.Enabled = false end if else DeleteFileButton.Enabled = false ShowPictureButton.Enabled = false end if End Sub
Property MyEdsCameraStateEventHandler As MyEdsCameraStateEventHandlerMBS
Property MyEdsObjectEventHandler As MyEdsObjectEventHandlerMBS
Property MyEdsPropertyEventHandler As MyEdsPropertyEventHandlerMBS
Property Progress As MyEdsProgressMBS
Property camera As EdsCameraMBS
Property stream As EdsStreamMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyEdsProgressMBS Inherits EdsProgressMBS
EventHandler Function Progress(Percent as UInt32, byref Cancel as boolean) As integer // we got progress of a long time operation = Percent MainWindow.UpdateNow End EventHandler
End Class
Class MyEdsObjectEventHandlerMBS Inherits EdsObjectEventHandlerMBS
EventHandler Function ObjectChanged(EventCode as integer, obj as EdsBaseMBS) As integer System.DebugLog CurrentMethodName+": "+str(EventCode) if EventCode = EDSModuleMBS.kEdsObjectEvent_DirItemRequestTransfer then // cast object manually by moving handle. Plugin does not know this is a directory item! dim c as new EdsDirectoryItemMBS c.Handle = obj.Handle obj.Handle = 0 'MsgBox d.DirectoryItemInfo.FileName // download picture without progress dim info as EdsDirectoryItemInfoMBS = c.DirectoryItemInfo if info<>nil then dim file as FolderItem = SpecialFolder.Desktop.Child(info.FileName) dim stream as new EdsStreamMBS(file, EdsStreamMBS.kEdsFileCreateDisposition_CreateNew, EdsStreamMBS.kEdsAccess_Write) c.Download(info.Size, stream) CheckError c c.DownloadComplete CheckError c stream = nil file.Launch end if end if End EventHandler
End Class
Module Module1
Sub CheckError(o as EdsBaseMBS) dim n as integer = o.Lasterror if n = 0 then Return // ok dim message as string = getErrorMessage(n) dim m as string = "Error "+str(n)+": "+Message System.DebugLog m MsgBox m End Sub
Function GetErrorMessage(n as integer) As string dim message as string = "?" Select case n case EDSModuleMBS.EDS_ERR_UNIMPLEMENTED message = "Not implemented" case EDSModuleMBS.EDS_ERR_INTERNAL_ERROR message = "Internal error" case EDSModuleMBS.EDS_ERR_MEM_ALLOC_FAILED message = "Memory allocation error" case EDSModuleMBS.EDS_ERR_MEM_FREE_FAILED message = "Memory release error" case EDSModuleMBS.EDS_ERR_OPERATION_CANCELLED message = "Operation canceled" case EDSModuleMBS.EDS_ERR_INCOMPATIBLE_VERSION message = "Version error" case EDSModuleMBS.EDS_ERR_NOT_SUPPORTED message = "Not supported" case EDSModuleMBS.EDS_ERR_UNEXPECTED_EXCEPTION message = "Unexpected exception" case EDSModuleMBS.EDS_ERR_PROTECTION_VIOLATION message = "Protection violation" case EDSModuleMBS.EDS_ERR_MISSING_SUBCOMPONENT message = "Missing subcomponent" case EDSModuleMBS.EDS_ERR_SELECTION_UNAVAILABLE message = "Selection unavailable" case EDSModuleMBS.EDS_ERR_FILE_IO_ERROR message = "IO error" case EDSModuleMBS.EDS_ERR_FILE_TOO_MANY_OPEN message = "Too many files open" case EDSModuleMBS.EDS_ERR_FILE_NOT_FOUND message = "File does not exist" case EDSModuleMBS.EDS_ERR_FILE_OPEN_ERROR message = "Open error" case EDSModuleMBS.EDS_ERR_FILE_CLOSE_ERROR message = "Close error" case EDSModuleMBS.EDS_ERR_FILE_SEEK_ERROR message = "Seek error" case EDSModuleMBS.EDS_ERR_FILE_TELL_ERROR message = "Tell error" case EDSModuleMBS.EDS_ERR_FILE_READ_ERROR message = "Read error" case EDSModuleMBS.EDS_ERR_FILE_WRITE_ERROR message = "Write error" case EDSModuleMBS.EDS_ERR_FILE_PERMISSION_ERROR message = "Permission error" case EDSModuleMBS.EDS_ERR_FILE_DISK_FULL_ERROR message = "Disk full" case EDSModuleMBS.EDS_ERR_FILE_ALREADY_EXISTS message = "File already exists" case EDSModuleMBS.EDS_ERR_FILE_FORMAT_UNRECOGNIZED message = "Format error" case EDSModuleMBS.EDS_ERR_FILE_DATA_CORRUPT message = "Invaliddata" case EDSModuleMBS.EDS_ERR_FILE_NAMING_NA message = "File naming error" case EDSModuleMBS.EDS_ERR_DIR_NOT_FOUND message = "Directory does not exist" case EDSModuleMBS.EDS_ERR_DIR_IO_ERROR message = "I/O error" case EDSModuleMBS.EDS_ERR_DIR_ENTRY_NOT_FOUND message = "No file in directory" case EDSModuleMBS.EDS_ERR_DIR_ENTRY_EXISTS message = "File in directory" case EDSModuleMBS.EDS_ERR_DIR_NOT_EMPTY message = "Directory full" case EDSModuleMBS.EDS_ERR_PROPERTIES_UNAVAILABLE message = "Property (and additional property information) unavailable" case EDSModuleMBS.EDS_ERR_PROPERTIES_MISMATCH message = "Property mismatch" case EDSModuleMBS.EDS_ERR_PROPERTIES_NOT_LOADED message = "Property not loaded" case EDSModuleMBS.EDS_ERR_INVALID_PARAMETER message = "Invalid function parameter" case EDSModuleMBS.EDS_ERR_INVALID_HANDLE message = "Handle error" case EDSModuleMBS.EDS_ERR_INVALID_POINTER message = "Pointer error" case EDSModuleMBS.EDS_ERR_INVALID_INDEX message = "Index error" case EDSModuleMBS.EDS_ERR_INVALID_LENGTH message = "Length error" case EDSModuleMBS.EDS_ERR_INVALID_FN_POINTER message = "FN pointer error" case EDSModuleMBS.EDS_ERR_INVALID_SORT_FN message = "Sort FN error" case EDSModuleMBS.EDS_ERR_DEVICE_NOT_FOUND message = "Device not found" case EDSModuleMBS.EDS_ERR_DEVICE_BUSY message = "Device busy Note: If a device busy error occurs, reissue the command after a while. The camera will become unstable." case EDSModuleMBS.EDS_ERR_DEVICE_INVALID message = "Device error" case EDSModuleMBS.EDS_ERR_DEVICE_EMERGENCY message = "Device emergency" case EDSModuleMBS.EDS_ERR_DEVICE_MEMORY_FULL message = "Device memory full" case EDSModuleMBS.EDS_ERR_DEVICE_INTERNAL_ERROR message = "Internal device error" case EDSModuleMBS.EDS_ERR_DEVICE_INVALID_PARAMETER message = "Device parameter invalid" case EDSModuleMBS.EDS_ERR_DEVICE_NO_DISK message = "No disk" case EDSModuleMBS.EDS_ERR_DEVICE_DISK_ERROR message = "Disk error" case EDSModuleMBS.EDS_ERR_DEVICE_CF_GATE_CHANGED message = "The CF gate has been changed" case EDSModuleMBS.EDS_ERR_DEVICE_DIAL_CHANGED message = "The dial has been changed" case EDSModuleMBS.EDS_ERR_DEVICE_NOT_INSTALLED message = "Device not installed" case EDSModuleMBS.EDS_ERR_DEVICE_STAY_AWAKE message = "Device connected in awake mode" case EDSModuleMBS.EDS_ERR_DEVICE_NOT_RELEASED message = "Device not released" case EDSModuleMBS.EDS_ERR_STREAM_IO_ERROR message = "Stream I/O error" case EDSModuleMBS.EDS_ERR_STREAM_NOT_OPEN message = "Stream open error" case EDSModuleMBS.EDS_ERR_STREAM_ALREADY_OPEN message = "Stream already open" case EDSModuleMBS.EDS_ERR_STREAM_OPEN_ERROR message = "Failed to open stream" case EDSModuleMBS.EDS_ERR_STREAM_CLOSE_ERROR message = "Failed to close stream" case EDSModuleMBS.EDS_ERR_STREAM_SEEK_ERROR message = "Stream seek error" case EDSModuleMBS.EDS_ERR_STREAM_TELL_ERROR message = "Stream tell error" case EDSModuleMBS.EDS_ERR_STREAM_READ_ERROR message = "Failed to read stream" case EDSModuleMBS.EDS_ERR_STREAM_WRITE_ERROR message = "Failed to write stream" case EDSModuleMBS.EDS_ERR_STREAM_PERMISSION_ERROR message = "Permission error" case EDSModuleMBS.EDS_ERR_STREAM_COULDNT_BEGIN_THREAD message = "Could not start reading thumbnail" case EDSModuleMBS.EDS_ERR_STREAM_BAD_OPTIONS message = "Invalid stream option" case EDSModuleMBS.EDS_ERR_STREAM_END_OF_STREAM message = "Invalid stream termination" case EDSModuleMBS.EDS_ERR_COMM_PORT_IS_IN_USE message = "Port in use" case EDSModuleMBS.EDS_ERR_COMM_DISCONNECTED message = "Port disconnected" case EDSModuleMBS.EDS_ERR_COMM_DEVICE_INCOMPATIBLE message = "Incompatible device" case EDSModuleMBS.EDS_ERR_COMM_BUFFER_FULL message = "Buffer full" case EDSModuleMBS.EDS_ERR_COMM_USB_BUS_ERR message = "USB bus error" case EDSModuleMBS.EDS_ERR_USB_DEVICE_LOCK_ERROR message = "Failed to lock the UI" case EDSModuleMBS.EDS_ERR_USB_DEVICE_UNLOCK_ERROR message = "Failed to unlock the UI" case EDSModuleMBS.EDS_ERR_STI_UNKNOWN_ERROR message = "Unknown STI" case EDSModuleMBS.EDS_ERR_STI_INTERNAL_ERROR message = "Internal STI error" case EDSModuleMBS.EDS_ERR_STI_DEVICE_CREATE_ERROR message = "Device creation error" case EDSModuleMBS.EDS_ERR_STI_DEVICE_RELEASE_ERROR message = "Device release error" case EDSModuleMBS.EDS_ERR_DEVICE_NOT_LAUNCHED message = "Device startup failed" case EDSModuleMBS.EDS_ERR_ENUM_NA message = "Enumeration terminated (there was no suitableenumeration item)" case EDSModuleMBS.EDS_ERR_INVALID_FN_CALL message = "Called in a mode when the function could not be used" case EDSModuleMBS.EDS_ERR_HANDLE_NOT_FOUND message = "Handle not found" case EDSModuleMBS.EDS_ERR_INVALID_ID message = "Invalid ID" case EDSModuleMBS.EDS_ERR_WAIT_TIMEOUT_ERROR message = "Timeout" case EDSModuleMBS.EDS_ERR_SESSION_NOT_OPEN message = "Session open error" case EDSModuleMBS.EDS_ERR_INVALID_TRANSACTIONID message = "Invalid transaction ID" case EDSModuleMBS.EDS_ERR_INCOMPLETE_TRANSFER message = "Transfer problem" case EDSModuleMBS.EDS_ERR_INVALID_STRAGEID message = "Storage error" case EDSModuleMBS.EDS_ERR_DEVICEPROP_NOT_SUPPORTED message = "Unsupported device property" case EDSModuleMBS.EDS_ERR_INVALID_OBJECTFORMATCODE message = "Invalid object format code" case EDSModuleMBS.EDS_ERR_SELF_TEST_FAILED message = "Failed self-diagnosis" case EDSModuleMBS.EDS_ERR_PARTIAL_DELETION message = "Failed in partial deletion" case EDSModuleMBS.EDS_ERR_SPECIFICATION_BY_FORMAT_UNSUPPORTED message = "Unsupported format specification" case EDSModuleMBS.EDS_ERR_NO_VALID_OBJECTINFO message = "Invalid object information" case EDSModuleMBS.EDS_ERR_INVALID_CODE_FORMAT message = "Invalid code format" 'case EDSModuleMBS.EDS_ERR_UNKNOWN_VENDER_CODE 'message = "Unknown vendor code" case EDSModuleMBS.EDS_ERR_CAPTURE_ALREADY_TERMINATED message = "Capture already terminated" case EDSModuleMBS.EDS_ERR_INVALID_PARENTOBJECT message = "Invalid parent object" case EDSModuleMBS.EDS_ERR_INVALID_DEVICEPROP_FORMAT message = "Invalid property format" case EDSModuleMBS.EDS_ERR_INVALID_DEVICEPROP_VALUE message = "Invalid property value" case EDSModuleMBS.EDS_ERR_SESSION_ALREADY_OPEN message = "Session already open" case EDSModuleMBS.EDS_ERR_TRANSACTION_CANCELLED message = "Transaction canceled" case EDSModuleMBS.EDS_ERR_SPECIFICATION_OF_DESTINATION_UNSUPPORTED message = "Unsupported destination specification" case EDSModuleMBS.EDS_ERR_UNKNOWN_COMMAND message = "Unknown command" case EDSModuleMBS.EDS_ERR_OPERATION_REFUSED message = "Operation refused" case EDSModuleMBS.EDS_ERR_LENS_COVER_CLOSE message = "Lens cover closed" case EDSModuleMBS.EDS_ERR_OBJECT_NOTREADY message = "Image data set not ready for live view" case EDSModuleMBS.EDS_ERR_TAKE_PICTURE_AF_NG message = "Focus failed" case EDSModuleMBS.EDS_ERR_TAKE_PICTURE_RESERVED message = "Reserved" case EDSModuleMBS.EDS_ERR_TAKE_PICTURE_MIRROR_UP_NG message = "Currently configuring mirror up" case EDSModuleMBS.EDS_ERR_TAKE_PICTURE_SENSOR_CLEANING_NG message = "Currently cleaning sensor" case EDSModuleMBS.EDS_ERR_TAKE_PICTURE_SILENCE_NG message = "Currently performing silent operations" case EDSModuleMBS.EDS_ERR_TAKE_PICTURE_NO_CARD_NG message = "Card not installed" case EDSModuleMBS.EDS_ERR_TAKE_PICTURE_CARD_NG message = "Error writing to card" case EDSModuleMBS.EDS_ERR_TAKE_PICTURE_CARD_PROTECT_NG message = "Card write protected" end Select Return Message End Function
End Module
Class PicWindow Inherits Window
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() NextFrame End EventHandler
End Control
EventHandler Function CancelClose(appQuitting as Boolean) As Boolean if Camera<>nil then MainWindow.StopLiveView Camera end if End EventHandler
Sub NextFrame() System.DebugLog "Update live video..." dim stream as new EdsStreamMBS(0) // memory stream if stream.Lasterror = EDSModuleMBS.EDS_ERR_OK then dim image as new EdsEvfImageMBS(stream) if image.Lasterror = EDSModuleMBS.EDS_ERR_OK then Camera.DownloadEvfImage image, false if Camera.Lasterror = EDSModuleMBS.EDS_ERR_OK then 'dim zoom as UInt32 = image.GetPropertyDataUInt32(EdsEvfImageMBS.kEdsPropID_Evf_Zoom) 'dim zoompoint as EdsPointMBS = image.GetPropertyDataPoint(EdsEvfImageMBS.kEdsPropID_Evf_ZoomPosition) dim p as ptr = stream.Pointer dim len as UInt32 = stream.Length System.DebugLog "Got "+str(len)+" bytes." stream.Seek(0, stream.kEdsSeek_Begin) dim s as string = stream.Read(len) System.DebugLog "Read "+str(lenb(s))+" bytes." self.Backdrop = JPEGStringToPictureMBS(s,true) else System.DebugLog "Failed to download image with error "+str(Camera.Lasterror)+": "+GetErrorMessage(Camera.Lasterror) end if else System.DebugLog "Failed to create image with error "+str(image.Lasterror)+": "+GetErrorMessage(image.Lasterror) end if else System.DebugLog "Failed to create memory stream with error "+str(stream.Lasterror)+": "+GetErrorMessage(stream.Lasterror) end if End Sub
Property Camera As EdsCameraMBS
End Class
Class MyEdsPropertyEventHandlerMBS Inherits EdsPropertyEventHandlerMBS
EventHandler Function PropertyChanged(PropertyEvent as UInt32, PropertyID as UInt32, Param as UInt32) As integer System.DebugLog CurrentMethodName if PropertyID = EdsBaseMBS.kEdsPropID_Evf_OutputDevice then System.DebugLog "kEdsPropID_Evf_OutputDevice" dim device as UInt32 = camera.GetPropertyDataUInt32(camera.kEdsPropID_Evf_OutputDevice) if not Active and BitwiseAnd(device, EDSModuleMBS.kEdsEvfOutputDevice_PC)<>0 then System.DebugLog "Output To PC started..." Active = true PicWindow.timer1.Mode = 2 end if if Active and BitwiseAnd(device, EDSModuleMBS.kEdsEvfOutputDevice_PC) = 0 then System.DebugLog "Output To PC stopped..." 'PicWindow.timer1.Mode = 0 Active = false end if end if End EventHandler
Property Active As Boolean
Property camera As EdsCameraMBS
End Class
Class MyEdsCameraAddedHandlerMBS Inherits EdsCameraAddedHandlerMBS
EventHandler Function CameraAdded() As integer MainWindow.OpenDevice End EventHandler
End Class
Class MyEdsCameraStateEventHandlerMBS Inherits EdsCameraStateEventHandlerMBS
EventHandler Function StateChanged(StateEvent as UInt32, EventData as UInt32) As integer if StateEvent = EDSModuleMBS.kEdsStateEvent_Shutdown then PicWindow.close MainWindow.clear MsgBox "Camera disconnected." end if End EventHandler
End Class
End Project

The items on this page are in the following plugins: MBS Cameras Plugin.

Feedback: Report problem or ask question.

The biggest plugin in space...

Start Chat