0

I am trying to initialize the API for Canon EDSDK, but for some reason the err = EdsInitializeSDK() is not returing the correct value "0" or EDS_ERR_OK. This is causing it to skip all of the remaning if statements.

Here is the code:

 Private Sub VBSample_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim err As Integer = EDS_ERR_OK
    Dim cameraList As IntPtr = Nothing
    Dim camera As IntPtr = Nothing
    Dim count As Integer = 0
    Dim isSDKLoaded As Boolean = False
    Dim propObj As New CameraProperty

    ' connect property id to combobox. 
    m_cmbTbl.Add(kEdsPropID_AEMode, Me.AEModeCmb)
    m_cmbTbl.Add(kEdsPropID_ISOSpeed, Me.ISOSpeedCmb)
    m_cmbTbl.Add(kEdsPropID_Av, Me.AvCmb)
    m_cmbTbl.Add(kEdsPropID_Tv, Me.TvCmb)
    m_cmbTbl.Add(kEdsPropID_MeteringMode, Me.MeteringModeCmb)
    m_cmbTbl.Add(kEdsPropID_ExposureCompensation, Me.ExposureCompCmb)
    m_cmbTbl.Add(kEdsPropID_ImageQuality, Me.ImageQualityCmb)


    err = EdsInitializeSDK()

    If err = EDS_ERR_OK Then

        isSDKLoaded = True

    End If

    If err = EDS_ERR_OK Then

        err = EdsGetCameraList(cameraList)

    End If


    If err = EDS_ERR_OK Then

        err = EdsGetChildCount(cameraList, count)
        If count = 0 Then
            err = EDS_ERR_DEVICE_NOT_FOUND
        End If

    End If

    '// Get the first camera.
    If err = EDS_ERR_OK Then

        err = EdsGetChildAtIndex(cameraList, 0, camera)

    End If


    Dim deviceInfo As EdsDeviceInfo = Nothing

    If err = EDS_ERR_OK Then

        err = EdsGetDeviceInfo(camera, deviceInfo)

        If err = EDS_ERR_OK And IsNothing(camera) = True Then
            err = EDS_ERR_DEVICE_NOT_FOUND
        End If

    End If


    If IsNothing(cameraList) = False Then

        EdsRelease(cameraList)

    End If


    '// Create the camera model 
    If err = EDS_ERR_OK Then

        model = cameraModelFactory(camera, deviceInfo)

        If IsNothing(model) = True Then
            err = EDS_ERR_DEVICE_NOT_FOUND

        End If
    End If


    If err <> EDS_ERR_OK Then

        MessageBox.Show("Cannot detect camera")

    End If"

I think I have the API set up correctly, but I could be wrong.

This code might be helpful:

Option Strict Off
Option Explicit On 

Imports System.Runtime.InteropServices

Public Module EDSDK

'===================================================
'
' EDSDK.h
'
'===================================================

'/******************************************************************************
'*******************************************************************************
'//
'//  initialize / terminate
'//
'*******************************************************************************
'******************************************************************************/

'/*-----------------------------------------------------------------------------
'//
'//  Function:   EdsInitializeSDK
'//
'//  Description:
'//      Initializes the libraries. 
'//      When using the EDSDK libraries, you must call this API once  
'//          before using EDSDK APIs.
'//
'//  Parameters:
'//       In:    None
'//      Out:    None
'//
'//  Returns:    Any of the sdk errors.
'-----------------------------------------------------------------------------*/
Public Declare Function EdsInitializeSDK Lib "EDSDK" () As Integer"

Should I be doing something else when I delare the function?

sac
  • 1
  • 1
  • And what doesn't work? I.e. what errors do you get? – Aleksander Lidtke Nov 08 '13 at 22:50
  • I'm not getting an error persay. It just will not execute my if statements because the correct value is not being returned. The function EDSInitializeSDK is what is not working. If you do not have the actual SDK it might be a little tricky to answer this question. – sac Nov 12 '13 at 18:27

0 Answers0