Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   How to eliminate lag on USB Webcam Java (http://www.chiefdelphi.com/forums/showthread.php?t=146961)

ProfessorAlekM 04-10-2016 12:56 PM

How to eliminate lag on USB Webcam Java
 
Hello!

Our team was using the simple camera server code on our robot during our last competition. It worked, but it always had a 1-2 second lag. Is there anyway to just lower the resolution and frame rate of the video (preferable 160x120px) so that the video feed is at least real-time?

(We are using USB webcams)

IndySam 04-10-2016 01:03 PM

Re: How to eliminate lag on USB Webcam Java
 
Right click on the camera on the smart dashboard and you can change the resolution. You can also resize the window.

stundt1 04-10-2016 01:07 PM

Re: How to eliminate lag on USB Webcam Java
 
Inside the CameraServer Class there is a setQuality() Method.


You can use this to change the quality of the image sent to the Driverstation which should decrease the Lag.


Checkout the WPI Documentation on the CameraServer Class for more information.

ProfessorAlekM 04-10-2016 02:54 PM

Re: How to eliminate lag on USB Webcam Java
 
We heard from another team that you can preset the resolution of the HD-3000 Camera with the life-cam software, but we tried changing the size of the video in the LifeCam software, but all that does is change the resolution for that recording session, and doesn't transfer when we plug it into the roborio.

abigailthefox 04-13-2016 07:45 PM

Re: How to eliminate lag on USB Webcam Java
 
Try running the camera in its own thread during operator control.
Write the vision code like you usually would, and then during the operator control loop, call it in its own thread, separate from other functions of the robot.
We had major camera lag problems, and this fixed it for us.

Here's a bit of example code
Code:

    public void operatorControl()
    {
            isDone = false;
            //Begin vision processing on a new thread
            Thread thread = new Thread()
            {
                    public void run()
                    {
                            while (!isDone)
                            {
                                    if(RobotMap.visionSystemEnable != -1)
                                    {
                                        vision.vision();
                                    }
                            }
                    }
            };
            thread.start();


MrRoboSteve 04-13-2016 09:23 PM

Re: How to eliminate lag on USB Webcam Java
 
Use Resource Monitor to verify that you're not exceeding the 7mbps rate limit on robot <--> operator console communications. We had to set quality on the stream to 30 to do so.


All times are GMT -5. The time now is 07:22 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi