I’m wanting to write the following code for our robot code:
Startup:
- create USBCamera object
- set the brightness and exposure from stored preferences
- disconnect from camera
- run GRIP
Currently when I try this, GRIP says that the frame grabber could not connect to the camera.
Here’s what I know so far:
- I have created my own USBCamera class that is an exact copy of the WPI lib version, but gives me the ability to set the exposure with better control
- The constructor for USBCamera calls openCamera() which calls NIVision.IMAQdxOpenCamera()
- The USBCamera method closeCamera() calls NIVision.IMAQdxCloseCamera
- I do not use the autocpature feature, I call getImage() and push that to the CameraServer object so startCapture() is never called.
I assumed that NIVision.IMAQdxCloseCamera() would close the connection to the camera, but that does not seem to be the case. I am calling that and then trying to start GRIP and grip fails connecting to the frame grabber for cam0 (the same camera I just used in USBCamera).
Does anyone have any idea how to do this? Any idea why calling USBCamera.closeCamera() does not disconnect from the camera object?
Thanks in advance
What model camera is it? For many types of USB cameras, the driver comes with a dashboard program that lets you persistently set things like brightness and exposure while it’s plugged into your laptop, then you can just move it over to the RIO.
Also, a lot of webcams have an LED that turns on when it’s connected. Can you verify that IMAQdxCloseCamera causes the LED to turn off?
I’m using the LifeCamHD. I did some more digging. You’re right about the light. It turns out that it IS disconnecting from the camera. GRIP is connecting to the camera. The exceptions I saw were anomalies. It turns out the real issue is this exception:
eb 06, 2016 4:27:56 PM edu.wpi.grip.core.operations.composite.PublishVideoOperation lambda$new$17
WARNING: Address already in use
java.net.BindException: Address already in use
So the closeCamera does actually disconnect (and you do see the blue light turn off). I’m going to move this discussion to a new thread that discusses the above issue.
As far as I can tell, A) there is no program that comes with the camera. It uses the USB standard camera interface. B) if you power the camera off, it loses it’s settings. I do have an app for controlling the settings from my laptop, but as soon as you unplug and re-plug, you lose the settings.