View Single Post
  #5   Spotlight this post!  
Unread 04-13-2016, 07:45 PM
abigailthefox's Avatar
abigailthefox abigailthefox is offline
Registered User
FRC #1711 (Raptors)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2015
Location: Traverse City
Posts: 48
abigailthefox is an unknown quantity at this point
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();
Reply With Quote