VisionPortal throws exception when getActiveCamera is used before OpModeIsActive

I have constructed a VisionPortal object with a switchable camera in the runOpMode method, before IsOpModeActive.
Any attempt to set or query the active camera results in an exception being thrown.
Debugging revealed that the field is null until OpModeIsActive.

Two questions.

  1. Is this expected behaviour?
  2. How can you use VisionPortal to process images in Init so the position of a game piece on a spike line can be determined?

Most teams are using vision in INIT.

Please post a link here, to your code shared online. Please also post an image of the exception message.

Here is the source.

in particular. AutoBase uses a VisionSystem that ultimately creates the VisionPortal.

At the outermost level Auto1_BlueFieldLeft

I have been getting some feedback on the /r/FTC subreddit and they are suggesting that you HAVE to put in
// Check CameraState here, and break if STREAMING
} ‘’’
in the init phase, BEFORE messing with the VIsionPortal. Is this the strategy for using the VisionPortal? I looked at the example in the FTC distribution, SwitchableCamera and it doesn’t do it, but it does do it’s work in the active phase and a great deal of cycles will pass before a user presses a button to switch the camera. It may be just relying on that time and not doing the check.

Right, checking camera state does work. I have found just sleep(50) does the trick, which is no problem one time in INIT.

Feel free to post again, If this remains an issue for you. I can post a dead simple OpMode, adapted from FTC sample “”, but with the switching happening in INIT. It does work fine, and DS Camera Stream is available.

I put in the while() and it worked like a charm! Thanks!