Setting CAMERA CONTROL PARAMETERS and LINE PROFILE PARAMETERS via FILES or CODE . . .

All --

I have an application where I would like to set the parameters for

    CAMERA CONTROL
    LINE PROFILE TOOL

for a user that is jumping back and forth between configurations A and B.

The CAMERA CONTROL has ICQ FILES to use with SAVE SETTINGS and LOAD SETTINGS and I have created

    A.ICQ
    B.ICQ

The LINE PROFILE TOOL has LPES FILES to use with SAVE SETTINGS and LOAD SETTINGS.

    A.LPES
    B.LPES

Unfortunately the ICQ FILES are not reliably setting the

    CAMERA CONTROL
        CONTRAST (A = 0, B = 4)
        GAMMA (A = 2, B = 1)

and the LPES FILES are not setting the

    LINE PROFILE TOOL
        LINE PROFILE INITIAL PROFILE = NONE (actually in PREMIER + FILE + OPTIONS + HISTOGRAM & PROFILE)
        MEASUREMENT TYPE (A = ORIGIN TO VALLEY, B = VALLEY TO VALLEY)

I have done a RECORD MACRO and I have code from the CAMERA CONTROL that seems to be the right commands but the CAMERA CONTROL and the LIVE IMAGE do not seem to be reacting properly to the commands when the code is run.

I have done a RECORD MACRO but the recorder does not seem to record the MEASUREMENT TYPES from LINE PROFILE and my attempts to get the syntax right have failed.

I would like to make an APP with a button for A and a button for B that would set everything up properly.

Can you please provide some guidance about this?

Thanks.

-- Matt

Best Answers

  • Accepted Answer
    Or you can set measurements from the macro if Line Profile engine already exists:

        Public Function SetLineProfileMeasurements() As SimpleScript
            SetLineProfileMeasurements = New SimpleScript
            Dim doc1
    
            With Application.DocumentCommands.Active(SetLineProfileMeasurements)
                .Run(doc1)
            End With
    
            With Measure.LineProfile.MeasurementsCommands.RemoveAll(SetLineProfileMeasurements)
                .Run(doc1)
            End With
    
            With Measure.LineProfile.MeasurementsCommands.Add(SetLineProfileMeasurements)
                .FromEdge = MeasurementTypes.Origin
                .FromClass = -1
                .ToEdge = MeasurementTypes.Valleys
                .ToClass = -1
                .Run(doc1)
            End With
    
            With Measure.LineProfile.MeasurementsCommands.Add(SetLineProfileMeasurements)
                .FromEdge = MeasurementTypes.Valleys
                .FromClass = -1
                .ToEdge = MeasurementTypes.Valleys
                .ToClass = -1
                .Run(doc1)
            End With
        End Function

    Nikita.
  • edited December 2016 Accepted Answer
    Matt,

    To follow up on the capture panel refresh issue, it appears that this is a bug when using scripting to change settings that are implemented just in software and not camera device specific. However, below is a workaround that will refresh the panel after changing the setting.

         Public Function TestCaptPanel() As SimpleScript
            TestCaptPanel = New SimpleScript
    
            ' Change capture naming options
            With Capture.CaptureCommands.Settings(TestCaptPanel)
                .AutoName = True
                .AutoNamePrefix = "TestPrefix"
                .AutoNameExtraLabel = 3
                .AutoNameExtraLabelAtEnd = True
                .Run()
            End With
    
            ' Refresh capture panel to show changes
            With Automate.ScriptingCommands.CodeCommand(TestCaptPanel)
                If .Run() Then
                    Dim captPanel As System.Windows.Forms.Control = Nothing
    
                    For Each panelControl As System.Windows.Forms.Control In ThisApplication.Panels.Controls
                        If panelControl.Name = "McCapturePanel" Then
                            captPanel = panelControl
                            Exit For
                        End If
                    Next
    
                    If captPanel IsNot Nothing Then
                        captPanel.Refresh()
                    End If
                End If
            End With
    
        End Function
    
     
    

Answers

  • Hi Matt,

    The initial profile option is not recorded in LPES file. As you noticed it is a global application option and should be set before Line Profile panel open.

    The measurements types saved in LPES file and should be loaded, but remember Line Profile engine should exist.

    For more in deep programming you can change "Default" settings (see MediaCy.Commands.LineProfile.AddIn.Default... properties). Remember these properties should be set before Line Profile engine created and will be used by Line Profile engine during initialization.

    Thanks,
    Nikita.
  • Nikita --

    Thank you for the guidance on the LINE PROFILE TOOL.

    I'll look into this immediately.

    Any thoughts on getting the CONTRAST and GAMMA within the CAMERA CONTROL to respond reliably to calls from CODE.

    Thanks.

    -- Matt
  • Nikita --

    I was unable to follow the path you suggested through the AUTOMATION HELP FILE to find

        MediaCy.Commands.LineProfile.AddIn.Default

    The feature that I think I need is

        Image-Pro Premier Automation Help
        MeasurementTypes Enumeration  

        Defines measurement types.

        Namespace: MediaCy.Commands.LineProfile
        Assembly: MediaCy.Commands.LineProfile (in MediaCy.Commands.LineProfile.dll)
        Version: 3.1.0.0
        Syntax
        VB
        CopyPublic Enumeration MeasurementTypes

    I have taken and attached below a SCREEN CAPTURE of the HELP SCREEN for this feature.

    Unfortunately my attempts to use this to establish

        MEASUREMENT TYPE = ORIGIN TO VALLEY

    or

        MEASUREMENT TYPE = VALLEY TO VALLEY

    via CODE have not worked.

    Can you please provide a CODE SAMPLE (and the LIBRARIES REQUIRED) that will set up LINE PROFILE to one of these configurations.  I think I can figure out how to modify it to do the other.

    Thanks.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-


  • edited December 2016
    Hi Matt,

    This function should be called before any Line Profile engine created:
    Imports MediaCy.Commands.LineProfile
    
    Public Module Macros
    
        Public Sub SetDefaultLineProfileMeasurements
            'Needs ref to MediaCy.Commands.LineProfile.dll
    
            Dim mOV As New McEdgeMeasurement(New McEdgeClass(mcEdgeTypes.mcetOrigin), New McEdgeClass(mcEdgeTypes.mcetValleys)) 'measurements O-V
            Dim mVV As New McEdgeMeasurement(New McEdgeClass(mcEdgeTypes.mcetValleys), New McEdgeClass(mcEdgeTypes.mcetValleys)) 'measurements V-V
            Dim mOVVV As New System.Collections.ArrayList({mOV, mVV}) 'measurements O-V and V-V
            Dim cl As System.Collections.ArrayList = MediaCy.Commands.LineProfile.AddIn.DefaultEdgeClasses 'collection of measurement classes
    
            MediaCy.Commands.LineProfile.AddIn.DefaultMeasurements(cl) = mOVVV
        End Sub
    
    End Module
    
    Thanks,
    Nikita.
  • Nikita --

    Thank you very much for the CODE SAMPLES.

    The SECOND that includes

        Function SetLineProfileMeasurements

    seems to be closest to what I need.

    I tried your FUNCTION and two versions of it that I created.

    I had to perform a RESET MEASUREMENTS before they worked but they did work.

    YAY!

    Your FUNCTION and my versions of it are below.

    Your assistance on this is very much appreciated.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
        Public Function SetLineProfileMeasurements() As SimpleScript
            SetLineProfileMeasurements = New SimpleScript
            Dim doc1
    
            With Application.DocumentCommands.Active(SetLineProfileMeasurements)
                .Run(doc1)
            End With
    
            With Measure.LineProfile.MeasurementsCommands.RemoveAll(SetLineProfileMeasurements)
                .Run(doc1)
            End With
    
            With Measure.LineProfile.MeasurementsCommands.Add(SetLineProfileMeasurements)
                .FromEdge = MeasurementTypes.Origin
                .FromClass = -1
                .ToEdge = MeasurementTypes.Valleys
                .ToClass = -1
                .Run(doc1)
            End With
    
            With Measure.LineProfile.MeasurementsCommands.Add(SetLineProfileMeasurements)
                .FromEdge = MeasurementTypes.Valleys
                .FromClass = -1
                .ToEdge = MeasurementTypes.Valleys
                .ToClass = -1
                .Run(doc1)
            End With
        End Function
    
    
        Public Function SetLineProfileMeasurementsOV() As SimpleScript
            SetLineProfileMeasurementsOV = New SimpleScript
            Dim doc1
    
            With Application.DocumentCommands.Active(SetLineProfileMeasurementsOV)
                .Run(doc1)
            End With
    
            With Measure.LineProfile.MeasurementsCommands.RemoveAll(SetLineProfileMeasurementsOV)
                .Run(doc1)
            End With
    
            With Measure.LineProfile.MeasurementsCommands.Add(SetLineProfileMeasurementsOV)
                .FromEdge = MeasurementTypes.Origin
                .FromClass = -1
                .ToEdge = MeasurementTypes.Valleys
                .ToClass = -1
                .Run(doc1)
            End With
    
    '        With Measure.LineProfile.MeasurementsCommands.Add(SetLineProfileMeasurements)
    '            .FromEdge = MeasurementTypes.Valleys
    '            .FromClass = -1
    '            .ToEdge = MeasurementTypes.Valleys
    '            .ToClass = -1
    '            .Run(doc1)
    '        End With
    
        End Function
    
        Public Function SetLineProfileMeasurementsVV() As SimpleScript
            SetLineProfileMeasurementsVV = New SimpleScript
            Dim doc1
    
            With Application.DocumentCommands.Active(SetLineProfileMeasurementsVV)
                .Run(doc1)
            End With
    
            With Measure.LineProfile.MeasurementsCommands.RemoveAll(SetLineProfileMeasurementsVV)
                .Run(doc1)
            End With
    
    '        With Measure.LineProfile.MeasurementsCommands.Add(SetLineProfileMeasurements)
    '            .FromEdge = MeasurementTypes.Origin
    '            .FromClass = -1
    '            .ToEdge = MeasurementTypes.Valleys
    '            .ToClass = -1
    '            .Run(doc1)
    '        End With
    
            With Measure.LineProfile.MeasurementsCommands.Add(SetLineProfileMeasurementsVV)
                .FromEdge = MeasurementTypes.Valleys
                .FromClass = -1
                .ToEdge = MeasurementTypes.Valleys
                .ToClass = -1
                .Run(doc1)
            End With
    
        End Function
    
  • Matt,

    The camera settings problem appears to be a bug when different cameras have been used previously on a system. Please try deleting the file at C:\Users\<username>\AppData\Roaming\Media Cybernetics\Image-Pro Premier 64-bit\9.3.6468.0, create the ICQ files again and see if it works.
  • Trey --

    Thanks for the info.

    Will do during next WEBEX with the customer and will provide a STATUS REPORT here.

    Thanks again.

    -- Matt
  • Nikita and Trey --

    The CODE that you provided is working well and I am able to reliably control the LINE PROFILE TOOL MEASUREMENT TYPE and the GAMMA SETTING and CAPTURE within the CAMERA TOOL.

    It seems that the CAMERA TOOL CONTRAST SETTING is not responding reliably though in PREMIER 9.2 though.

    The SET CONTRAST CODE that I am using is below.

    No errors are generated but the CONTRAST does not change on the customer's computer.  I cannot see this happen on my computer since I'm using the CAMERA SIMULATION and it does not have CONTRAST.

    Do you still recommend deleting the ICQ FILES in

        C:\Users\<username>\AppData\Roaming\Media Cybernetics\Image-Pro Premier 64-bit\*V*E*R*

    or is there another way to change the CONTRAST SETTING from an APPLICATION?

    Thanks.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
        Public Sub DFO_SetContrast(My_InContrast As Double)
    
            With Capture.CaptureCommands.Settings(Nothing)
                .PreviewSettings = True
                .contrast = My_InContrast
                .Run()
            End With
    
        End Sub
  • All --

    The CAMERA TOOL (9.1 or 9.2) does not seem to reflect the changes made by the code below until the CAPTURE TOOL is CLOSED and REOPENED.

    Is there CODE that would force a REFRESH of the CAMERA TOOL to reflect the new settings?

    Perhaps the issue with CONTRAST is related to this issue.

    Thanks.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
        With Capture.CaptureCommands.Settings(Nothing)
            .AutoName = True
            .AutoNamePrefix = textBox_CaptureNamePrefix.Text
            .AutoNameExtraLabel = 3
            .AutoNameExtraLabelAtEnd = TRUE
            .Run()
        End With

  • All --

    Any thoughts on how to get the CAMERA TOOL to update (specifically the AUTO NAMING OPTIONS) when its settings are changed by CODE and how to get the CONTRAST to respond to a change requested by CODE?

    Thanks.

    -- Matt
  • Hi Matt,

    Here is a function that will set the contrast value. It's not a part of the standard capture settings yet, and it's been implemented by certain capture interfaces as a custom control, so the access is different than most of the other camera settings. Also, a reference needs to be added to MediaCy.IQL.Capture.Manager.dll to use the function.

        Public Function ContrastControl() As SimpleScript
            ContrastControl = New SimpleScript
    
            Dim myCaptDev As MediaCy.IQL.Capture.Manager.McCaptureManagerDevice
            Dim myCaptAttr As MediaCy.IQL.Capture.McCaptDevAttribute
            Dim CaptIndex As Integer
    
            Dim myDevObjCmd As New MediaCy.Commands.Capture.GetDeviceObject
    
            With myDevObjCmd
                .CaptureDevice = -1
                .Run()
                myCaptDev = .Output.Value
            End With
    
            If myCaptDev IsNot Nothing Then
                If myCaptDev.CaptureDevice.Attributes.IsSupported("Contrast") <> 0 Then
                    myCaptAttr = myCaptDev.CaptureDevice.Attributes.Item("Contrast")
                End If
            End If
    
            If myCaptAttr IsNot Nothing Then
                myCaptAttr.Value = 10
            End If
    
        End Function
    

  • Trey --

    Thank you for the solutions to the CONTRAST ISSUE and the REFRESH ISSUE.

    I'll wire them into the PROJECT / APPLICATION shortly.

    Thanks again.

    -- Matt
  • Trey --

    Thanks again for the CODE to resolve the CONTRAST ISSUE and the REFRESH ISSUE.

    I condensed your CODE for the REFRESH ISSUE into

            '-- Refresh capture panel to show changes
    
            'FOR LOOP through the CONTROLS within this APPLICATION
            For Each panelControl As System.Windows.Forms.Control In ThisApplication.Panels.Controls
    
                    'If the current PANEL has the appropriate name
                    If panelControl.Name = "McCapturePanel" _
                        Then
    
                            'Refresh the capture panel
                            panelControl.Refresh
    
                            'Exit the FOR LOOP
                            Exit For
    
                        End If
    
                Next
    and it seems to be working great both on my computer and on the end user's computer.

    The code for the CONTRAST ISSUE is causing a headache though.

    Using your CODE for the CONTRAST ISSUE as a guide, I revised my CONTRAST SETTING ROUTINE to

        Public Sub DFO_SetContrast(My_InContrast As Double)
    
            'Declare local variables
            Dim myCaptDev As MediaCy.IQL.Capture.Manager.McCaptureManagerDevice
            Dim myCaptAttr As MediaCy.IQL.Capture.McCaptDevAttribute
            Dim CaptIndex As Integer
    
            'Query PREMIER to determine if a CAPTURE DEVICE is ON-LINE and how to access it if it exists
            Dim myDevObjCmd As New MediaCy.Commands.Capture.GetDeviceObject
            With myDevObjCmd
                    .CaptureDevice = -1
                    .Run()
                    myCaptDev = .Output.Value
                End With
    
            'If a CAPTURE DEVICE was found
            If myCaptDev IsNot Nothing _
                Then
    
                    'If there is a CONTRAST ITEM on the CAPTURE DEVICE ATTRIBUTES LIST
                    If myCaptDev.CaptureDevice.Attributes.IsSupported("Contrast") <> 0 _
                        Then
    
                            'Adjust the CONTRAST setting
                            myCaptDev.CaptureDevice.Attributes.Item("Contrast").Value = My_InContrast
    
                        Else
    
                            'If the CONTRAST MESSAGE FLAG is down
                            If ( DFO_ContrastMessageFlag = False ) _
                                Then
    
                                    'Raise the CONTRAST MESSAGE FLAG so this message will only be shown once
                                    DFO_ContrastMessageFlag = True
    
                                    'Give the user a message
                                    MsgBox _
                                        ( _
                                        "CONTRAST is not supported by CAMERA!", _
                                        vbInformation, _
                                        "'DFO_SetContrast' says . . ." _
                                        )
    
                                    label_Contrast.Text = _
                                        "* Contrast = "
    
                                    label_Contrast.BackColor = _
                                        System.Drawing.Color.FromArgb(CType(255, Byte),CType(255, Byte),CType(128, Byte))
    
                                    label_Warning.text = _
                                        "* = " & vbLf & "Not supported by CAMERA!"
    
                                    label_Warning.BackColor = _
                                        System.Drawing.Color.FromArgb(CType(255, Byte),CType(255, Byte),CType(128, Byte))
    
                                End If
    
                        End If
    
                End If
    
        End Sub
    
    

    I do not have a CAPTURE DEVICE with CONTRAST on my computer.  When this runs on the end user's computer, the CONTRAST responds but in a way that I do not understand.

    At first, I thought that the CAMERA CONTRAST VALUE needed to be 7 times the value of the CONTRAST SLIDER but that didn't hold up but testing that theory did not get me the result I was hoping for.

    I modified the CODE so I could follow the values as shown below.

                    'If there is a CONTRAST ITEM on the CAPTURE DEVICE ATTRIBUTES LIST
                    If myCaptDev.CaptureDevice.Attributes.IsSupported("Contrast") <> 0 _
                        Then

                            'Adjust the CONTRAST setting
                            Debug.Print "My_InContrast"
                            Debug.Print My_InContrast
                            Debug.Print "myCaptDev.CaptureDevice.Attributes.Item('Contrast').Value -- BEFORE"
                            Debug.Print myCaptDev.CaptureDevice.Attributes.Item("Contrast").Value
                            myCaptDev.CaptureDevice.Attributes.Item("Contrast").Value = Val(My_InContrast)
                            Debug.Print "myCaptDev.CaptureDevice.Attributes.Item('Contrast').Value -- AFTER"
                            Debug.Print myCaptDev.CaptureDevice.Attributes.Item("Contrast").Value

                        Else

    The SCREEN CAPTURE BELOW shows the start of a TESTING RUN that was done with the following modification to the CODE above to watch the CONTRAST VALUE.

    The output of the DEBUG WINDOW starting with a 10 as the CONTRAST SETTING (as shown in the SCREEN CAPTURE below) is in the TXT FILE that I have attached to this post.

    Please let me know what I am doing wrong in setting the value for the CONTRAST.

    Thanks.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-





  • Hi Matt,

    The Contrast setting is an Integer type, so the issue is likely that My_InContrast is declared as a Double. To resolve, either change the type of My_InContrast to Integer or wrap My_InContrast with CInt() before assigning:

     myCaptDev.CaptureDevice.Attributes.Item("Contrast").Value = CInt(My_InContrast)
  • Trey --

    I'll give that a try.

    I figured that by using the VAL FUNCTION that it would resolve the problem of mis-matched type but I should have tried INTEGER.

    I'll let you know how it goes.

    Thanks.

    -- Matt

  • Trey --

    I implemented the fix that you suggested and converted My_InContrast using cInt().

    Good news and bad news.  The results become predictable but there is an issue.

    The value that I am ASSIGNING is not the value that is being shown in the CAMERA TOOL as follows:

    ** when My_InContrast = 1, the CONTRAST VALUE AFTER = 7 (also shown in CAMERA TOOL)
    ** when My_InContrast = 2, the CONTRAST VALUE AFTER = 14 (also shown in CAMERA TOOL)
    ** when My_InContrast = 3, the CONTRAST VALUE AFTER = 21 (also shown in CAMERA TOOL)

    Since I cannot sent it REAL NUMBERS, I cannot send 1/7 to get a 1 or 2/7 to get a 2 . . .

    Any suggestions?

    Thanks.

    -- Matt


  • All --

    Any thoughts on how to resolve this issue?

    Thanks.

    -- Matt
  • Hi Matt,

    Unfortunately, the contrast setting for this capture interface is not functioning properly and there is no solution at this time to be able to set it properly either with scripting or by loading a settings file.

    One workaround that to consider is using the application contrast control that is located in the Adjust ribbon Display group. It is functional on both preview and captured images, although it will need to be explicitly set to the desired value for every preview start or acquisition. If this is something that you would like to explore, I could provide sample code to show how to manage it.


  • Trey --

    Thank you for the information about the CONTRAST SETTING.

    Your solution regarding the DISPLAY CONTRAST sounds like it might be a work around.  It might be necessary to wire an APPLY into a POST CAPTURE MACRO so that a SAVE of the IMAGE results in the CONTRAST going into the IMAGE as PIXELS rather than as a SETTING on top of the image.

    Any solution that would allow them to jump back and forth between their LOW POWER (10X) and HIGH POWER (50X) settings would be appreciated.

    Thanks again.

    -- Matt
  • Matt,

    Yes, the contrast could be applied to the image data before saving.

    I'll work on a sample to show how to set the display contrast on preview and captured images when they are created.
  • Trey --

    Super.

    Thanks.

    -- Matt
  • Trey --

    The end user is considering the pros and cons of the DISPLAY CONTRAST WORKAROUND that you suggested.

    They are also asking if there is any timetable available for CODE CONTROL of the CAMERA CONTRAST.

    Thanks.

    -- Matt
  • I'll be able to work on it today and will hopefully have something for you by tomorrow at the latest to show how it could work.
  • edited December 2016
    Hi Matt,

    Here is a simple App project that should handle the need for adjusting contrast with a capture device. Please let me know if you have any questions or run into any issues.
  • Trey --

    Thanks for the APP.

    I'll try it out and run it past the USER.

    Right now they are thinking they need to stick with the CAMERA CONTRAST in order to capture their images through this experiment in a consistent manner.

    Thanks again.

    -- Matt
Sign In or Register to comment.