Home Image-Pro Automation (Macros, Apps, Reports)

How to check if camera is set after running macro

Hi Specialist:
                  In macro, I try to setup camera initially by macro. However, I can not check if this set has been successfully made. There is a "auto exposure" button in camera control. But it is not sure if this button is triggered. In addition, where to find brightness value, contrast and hue value? Please give some advice, thank you.
                    

Answers

  • HI StanleyH,

    Below is some code which will retrieve the status code after the auto-exposure has completed. Also, the camera settings can be checked if they are supported by the camera. If the camera doesn't support the setting, then it has no use with the Settings command.

    Note that you may need to add a reference to MediaCy.IQL.Capture and MediaCy.Commands.Capture for some of the code to work.

    Public Const AE_NO_ERROR = 0            ' No error
    Public Const AE_REACH_MAX_EXP = 1       ' Reached maximum exposure time
    Public Const AE_CONVERGE_FAIL = 2       ' Failed to converge on an exposure time
    Public Const AE_SNAP_ERROR = 3          ' Capture failure
    Public Const AE_UNDERSATURATE = 4       ' Image does not saturate
    Public Const AE_REACH_MIN_EXP = 5       ' Reached minimum exposure time
    Public Const AE_UNKNOWN_ERROR = 6       ' Any other error
    
    
    Public Sub DoAutoExposure()
        
        ' Run auto-exposure
        Dim AEStatus As Integer = AE_NO_ERROR
        With Capture.CaptureCommands.AutoExposure(Nothing)
            .CaptureDevice = -1
           .Run()
        End With
    
        ' Get the AE command attribute and check the status property to check the result of the AE
        With Capture.CaptureCommands.GetAttribute(Nothing)
            .CaptureDevice = -1
            .AttrID = mcCaptAttrIDs.mcatAutoExpCmd
            .Run()
            If .Attribute IsNot Nothing Then
                AEStatus = .Attribute.Status
            End If
        End With
    
        ' Set camera settings only if they are supported by the camera
        With Capture.CaptureCommands.Settings(Nothing)
            If Capture.Common.IsSupported(-1, mcCaptAttrIDs.mcatExposure) Then
                .Exposure = 50
            End If
            If Capture.Common.IsSupported(-1, mcCaptAttrIDs.mcatBrightness) Then
                .Brightness = 50
            End If
            .Run()
        End With
    End Sub
  • Hi Trey:
                 Thanks for your solution, it looks great.
  • Hi Trey:
                I have checked and it looks like that Infinity 1-1M camera does not support Brightness, Hue, Contrast. Thank you.
Sign In or Register to comment.