Go to Post To borrow a slogan from the last place KC Royals "It's Our Time" The curse will be broken! ;) - Alpha Beta [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 26-01-2017, 16:16
SamCarlberg's Avatar
SamCarlberg SamCarlberg is offline
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 161
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Listener from VisionThread? What do I put in this?

The listener in the example is a lambda expression, or an "anonymous function". Basically, a method that's defined where it's used. It's similar to an anonymous class, but is more succinct.

Code:
visionThread = new VisionThread(camera, new GripPipeline(), pipeline -> {
  if (!gripPipeline.filterContoursOutput().isEmpty()) {
    Rect r = Imgproc.boundingRect(gripPipeline.filterContoursOutput().get(0));
    synchronized (imgLock){
      centerX = r.x + (r.width / 2);
    }
  }
});
can also be written as

Code:
visionThread = new VisionThread(camera, new GripPipeline(), new VisionRunner.Listener<GripPipeline>() {
  @Override
  public void copyPipelineOutputs(GripPipeline pipeline) {
    // same as the contents of the lambda above
  }
});
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:16.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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