Skip to content

Get gain control returns a null pointer for a switchable camera #764

@trc492

Description

@trc492

The following code caused a NullPointerException because gainControl was null, so I had to add code to test for null before using it.

    /**
     * This method returns the camera min and max gain setting.
     *
     * @return array containing min and max gain values, null if unsuccessful.
     */
    public int[] getGainSetting()
    {
        int[] gains = null;

        if (visionPortal.getCameraState() == VisionPortal.CameraState.STREAMING)
        {
            GainControl gainControl = visionPortal.getCameraControl(GainControl.class);

            if (gainControl != null)
            {
                gains = new int[2];
                gains[0] = gainControl.getMinGain();
                gains[1] = gainControl.getMaxGain();
            }
            // TODO: Figure out why gainControl is NULL?!
        }

        return gains;
    }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions