![]() |
Toggle Between Two Cameras in Vision Processing
Hello, I am trying to make it to where I can toggle between two cameras in vision processing, and I tried to toggle between the cameras with a button on the joystick, but it did not work. How would I fix this?
![]() ![]() |
Re: Toggle Between Two Cameras in Vision Processing
Are you using Axis cameras or USB cameras?
|
Re: Toggle Between Two Cameras in Vision Processing
I'm not saying that this is going to fix everything, but the code is only reading the joystick once, outside the loop.
So move the Get Value inside each loop and at least at that point, you can probe and see that the buttons are working. Greg McKaskle |
Re: Toggle Between Two Cameras in Vision Processing
Ok, I am using USB Cameras, and I will try to place the get values into the loop. Thanks you all!
|
Re: Toggle Between Two Cameras in Vision Processing
I'm planning to do this on our robot with USB cameras. My goal is to get the code done by tomorrow evening. If I can get it done, I'll post it.
|
Re: Toggle Between Two Cameras in Vision Processing
Quote:
That would be great! I'm still actually getting no connection between both cameras at the same time. I also tried to put the values into the loops, and there was still no change. But thank you for your idea. This is what it looks like right now: ![]() |
Re: Toggle Between Two Cameras in Vision Processing
As I said, it may not fix all of the issues, but I guarantee that if you do not put the Joystick Get Values inside of each loop, you are only reading them once at the beginning. That is, I assume a part of the bug you are reporting.
Greg McKaskle |
Re: Toggle Between Two Cameras in Vision Processing
Quote:
|
Re: Toggle Between Two Cameras in Vision Processing
When toggling, are you by chance expecting the camera image on the Dashboard to change?
It won't, since the Dashboard forwarding is handled in the Camera IP & Dash vi. Since you aren't doing anything in the Vision Processing loop, you won't see any effect of your joystick button, even if it weren't stuck at the first and only read. |
Re: Toggle Between Two Cameras in Vision Processing
I had a bit more time to look at this.
As Mark mentioned, the actual code for sending USB camera images to the DB is inside of the IP & Dash VI. What type of cameras do you have? The current WPI VIs are setup to handle one USB camera forwarded to the DB. They don't have a ready mechanism to swap cameras, but it wouldn't be hard to add it. If one of the cameras were IP, it would be even simpler. So, what types of cameras do you have? Greg McKaskle |
Re: Toggle Between Two Cameras in Vision Processing
Greg, I'm assuming that this is a boolean function, so I will do some testing today with it. I'm also going to work with the dash vi today, so I will start working with it. Thanks
|
Re: Toggle Between Two Cameras in Vision Processing
Quote:
|
Re: Toggle Between Two Cameras in Vision Processing
Quote:
|
Re: Toggle Between Two Cameras in Vision Processing
1 Attachment(s)
Ok, I hacked this together in about 90 minutes and verified it works with two of our HD-3000 cams. Everything is located in the "Vision Processing.vi". It uses the "DB/Button 1" switch on the dashboard. True will give you one camera, false the other. It only runs in "HW Mode". There is a small switching delay.
*Edit* now with file. |
Re: Toggle Between Two Cameras in Vision Processing
Quote:
|
Re: Toggle Between Two Cameras in Vision Processing
Quote:
|
Re: Toggle Between Two Cameras in Vision Processing
Quote:
|
Re: Toggle Between Two Cameras in Vision Processing
It's designed to be run unmodified with the default dashboard. You shouldn't have needed to modify any globals. DB/Button 1 is one of the default buttons on the default dashboard.
|
Re: Toggle Between Two Cameras in Vision Processing
Would this work with Axis cameras or would it need to be fine tuned?
|
Re: Toggle Between Two Cameras in Vision Processing
I am now in a recursive loop WRT cameras.
Please see the thread below for some code which should work with Axis cameras. I wasn't able to test that code on a robot so it may have some issues. If so, please let me know. http://www.chiefdelphi.com/forums/sh...d.php?t=133559 |
Re: Toggle Between Two Cameras in Vision Processing
Just wanted to say that you are the man adciv. Using your code to switch between two USB cameras, and it works fine. I switched the toggle to happen on a joystick button press, to be easy for our driver. Now he has the stationary camera at the bottom of the lift, to help line up crates, and a camera at the top of the lift attached to a pan/tilt to get a better view of the field.
|
Re: Toggle Between Two Cameras in Vision Processing
Thanks adciv.
I used your code with JS to switch cams. The BOT Drivers were complaining about switching delay, so I tried opening two cameras and just switching the image source. Didn't work. LV doesn't seem to like me opening two USB cameras. I get this error when I try to set the FPS on the second camera. ERROR -1074360319 occurred at IMAQdx Start Acquisition.vi NI-IMAQdx: (Hex 0xBFF69001) Internal error I've included a simple example without the actual switching. http://www.GEARSinc.org/images/cap.png Everything work fine till I add the second cam. Any idea why LV is getting upset? |
Re: Toggle Between Two Cameras in Vision Processing
I've definitely opened multiple USB cams on a roboRIO with no problem. I was processing them and not streaming. Are you sure that is the first call to fail?
Greg McKaskle |
Re: Toggle Between Two Cameras in Vision Processing
Quote:
I'll try doing one camera setup at a time. Phil. |
Re: Toggle Between Two Cameras in Vision Processing
2 Attachment(s)
Still hunting this down..
Stringing all the camera setup mods in-line didn't help. In trying to identify the point of the error, I probed all the error outs of the first and second camera setups. Interesting to note that even though the open to the second camera works, the SET FPS does generate an error. See the attached probe sequence. A final point. If I just swap the USB0 and USB1 constants, the second camera is successfully displayed, so I know the second cam is functional and configurable. Phil. |
Re: Toggle Between Two Cameras in Vision Processing
1 Attachment(s)
Starting to get worn out...
I reduced my problem down to two camera opens.... I open and start two cameras. The second start fails... From the FP you can see that the system has identified the cameras properly. Any idea why the second start doesn't work? |
Re: Toggle Between Two Cameras in Vision Processing
Quote:
The first call is fine, but the second call to IMAQdx Configure Grab is erroring out. I can't tell if the "Cameras Address" is a valid input for the "Session" input of the Configure Grab function. It's being coerced. The default "Start" action for an unopened USB cam is to open cam0. Is it trying to do this default action twice? Phil. |
Re: Toggle Between Two Cameras in Vision Processing
I have been able to reproduce the issue here and I'm speaking with the IMAQ group. I'll let you know what I find out.
Greg McKaskle |
Re: Toggle Between Two Cameras in Vision Processing
Sorry for taking so long to pop in, been working on the robot too many hours.
I think I saw this problem when initially developing this code (Added about 40 min or so to the dev time). It would explain why I couldn't do an instant switch like I wanted. |
Re: Toggle Between Two Cameras in Vision Processing
Quote:
|
Re: Toggle Between Two Cameras in Vision Processing
Good news and bad.
The vision team now has a reproducible case of this. It only occurs on the ARM linux target with certain cameras. Unfortunately, the camera that shows it most easily is the MS 3000. I had four camera types and didn't do all combos of two, but did enough to see that some worked and some resulted in the internal error in Start. I saw it fail with two MS 3000 and one MS3000 and one high end Logitech. I saw it succeed with one MS3000 and a lower end logitech. And saw it succeed with two Logitech cams. My only suggestion at this point is a workaround of trying there models or makes of camera. Sorry. Thanks for reporting the bug. They should have it fixed for an upcoming release. But that will probably be after the season ends. Greg McKaskle |
Re: Toggle Between Two Cameras in Vision Processing
I have an update. The error message is occurring when the addition of this camera stream will overwhelm the USB bus. If the camera framerate or resolution are lowered, they claim that the error won't happen. It is a pretty lousy error message, and that is what they will try to improve.
This matches my earlier testing in that my earlier tests were with a lower res camera. Please let me know if this doesn't solve your issues. Greg McKaskle |
Re: Toggle Between Two Cameras in Vision Processing
Quote:
Do you mean that this is error occurs if the system calculates that the total stream requirements are too high? In other words, it's a protective issue rather than an actual detected error condition? I'm a little surprised, since my setup was only trying to run the cameras at 320x240, with a reduced frame-rate (15fpm) and reasonable compression (30). Do you know if it uses the MAX throughput requirements, or the limited throughput based on the Camera's current settings? The reason I ask is that I would think that two 320x240 streams would have less throughput requirements than a single 640x480 stream. I guess I need to do a super limited test. Phil. |
Re: Toggle Between Two Cameras in Vision Processing
OK, some updated information.
I can get both USB Camera streams to start if I go low enough in image size. The requested frame rate or compression don't seem to have any impact. If I set BOTH cameras to 160x120 they work.... However, if I put just ONE of them up to 320x240, the second stream does not start. This is oddly annoying, since the system is quite capable of sending one stream at 640x480. If the system can handle an uncompressed 640x680 image (307K pixels), the you'd think it could handle two 320x240 images (153K pixels), or certainly a 320x240 image plus an 160x120 image (115K Pixels). Thanks Greg, for the insight. Phil. |
Re: Toggle Between Two Cameras in Vision Processing
Are you running at 30fps or 15 fps?
|
Re: Toggle Between Two Cameras in Vision Processing
Quote:
Is there anything magic about 15 FPS. I may not have tried that value: I did try 12,10,5 etc.. Update: I just tried 15 FPS. No change. Still fails with two 320x240 videos. |
Re: Toggle Between Two Cameras in Vision Processing
The MSHD3000 cameras natively support only two framerates. One is 30fps, the other is 15fps. In all other cases, the FRC LabView VIs are running the camera at a higher FPS and only taking "every so many" frames. I wonder if the cameras are both be running at 30fps and the VIs are just notifying at the lower rates. I'll have to dig out my code on how to set them at the lower fps.
The cameras, as is, have about 103 settings for video. This is a large combination of Frame Rates, Resolutions, and if the image is compressed or not. The FRC VIs don't directly show these and the native IMAQ one which does it is something like Imaq Get All Camera Resolutions. |
Re: Toggle Between Two Cameras in Vision Processing
I believe that this is based on the camera mode at the time of start. It is also affected somewhat on the lower level drivers, as we tested this on an Intel embedded system and didn't see this error. So this is an error propagated from the lower level drivers saying that they will not start because they cannot or will not try to attempt the USB transfers.
I no longer have the cameras, since the other group wanted to borrow them. Please open the camera and set the resolution, framerate, and compression before doing the start. See if that will convince it to startup. Please keep me updated and when I get the cameras back, I'll do the same. Greg McKaskle |
Re: Toggle Between Two Cameras in Vision Processing
1 Attachment(s)
Quote:
It occurred to me that if it's the start that is causing the problem, then the start and stop could be moved into the source switching loop, and the whole open/setup/close could be left out of the loop. This may shorten the time taken to switch cameras to a less noticeable pause. Since I'm just discovering all this code, what is the purpose of the "notify" code in the error case? The original only checks the notification status of USB 0. Does this indicate when the camera is up and running again? |
Re: Toggle Between Two Cameras in Vision Processing
Some updated information.
I'm explicitly setting the FPS to 15, however, if I enumerate the Camera modes and display the current mode, I get mode 29, which is 320x240 at 30FPS. So there is a disconnect here somewhere. |
Re: Toggle Between Two Cameras in Vision Processing
I'm basing this on memory, so I may be a little off. The way the VIs select the camera mode is they enumerate all modes and then search for the first one which meets the resolution asked for. I suspect the 30fps modes come first. In order to select a 15fps mode, it may have to be done by explicitly selecting which mode you want to use and sending that to the appropriate IMAQ VI for setting up the camera.
|
Re: Toggle Between Two Cameras in Vision Processing
The code I just stepped through picks the smallest fps that is bigger than the requested image. With the Logitech I have plugged in, it lists 7 fps rates for 320x240.
Inside of WPI_CameraSet Framerate, you can prove the array of videoModes returned from the enumeration function and you can probe the videoMode sent into the GetSafe function on the right. Use the index sent into getSafe to look at the array description. Greg McKaskle |
Re: Toggle Between Two Cameras in Vision Processing
Was there any significant progress by now?
I have tried to use the exact same code earlier this season and got the same error on the Open vi. We now open the camera which we want to use on each switch and the lag is very noticeable. We use 2 Lifecams 3000, one for far shooting and one for close shooting and switching during a match makes the driver wait for the other camera to show an image. We really need a solution for this! Will using a different camera model fix this? |
Re: Toggle Between Two Cameras in Vision Processing
Quote:
1. Exposure setting VI. Zero sets image pretty dark (but seems workable), 1-100 appears to all be the same. 2. Sometimes exposure settings "take" on boot-up, sometimes not. No rhyme or reason. With low sample size, restarting robot code from DS seems to fix this. I suspect a boot-up sequence issue with camera settings being set before camera is up and running. We tried implementing a button to set the exposure again to Zero during teleop...does nothing. We saw this behavior with both 1 and 2 camera scenarios. -Steve |
Re: Toggle Between Two Cameras in Vision Processing
Quote:
http://www.chiefdelphi.com/forums/sh....php?p=1560711 |
Re: Toggle Between Two Cameras in Vision Processing
The good/bad news post is from last season, and I believe fixed. Though I didn't personally verify this, I did file the bug report.
The camera exposure settings for all MS LifeCams seems to be odd on UVC/linux devices. The parameters are described and given ranges that various APIs will use to communicate requested properties to the camera. The MS LifeCam exposure is described as going from 5 to 20,000, with increment of one. That is a lot of range. http://comments.gmane.org/gmane.linu...uvc.devel/5717 That link is to a 2011 forum post about a lifeCam 5000, but explains the same behavior. I does list the magic values, which are twelve geometrically scaled numbers centered around 156. I don't have a camera to try, but if you can use the percentage equivalents, or make your own Set Exposure to avoid the floating point scaling, you can probably make a LifeCam specific Exposure VI work. Greg McKaskle |
| All times are GMT -5. The time now is 00:48. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi