View Single Post
  #5   Spotlight this post!  
Unread 12-10-2012, 21:27
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Using thresholds on WPICameraExtension classes

All the functions you're asking about are in the WPIJavaCV project, which should be in the SmartDashboard repository (I see you found it in another thread). getAnd() applies a logical AND to each pixel in 2 binary images:
Code:
on  AND on  = on
on  AND off = off
off AND on  = off
off AND off = off
getOr() does the same thing but with an OR operation:
Code:
on  OR on  = on
on  OR off = on
off OR on  = on
off OR off = off
So to do a threshold of red between [100,150] and green outside [75,100], you'd do:
Code:
    WPIBinaryImage red = image.getRedChannel(),
                   green = image.getGreenChannel();
    WPIBinaryImage redThresh = red.getThreshold(100).getAnd(red.getThresholdInverted(150)),
                   greenThres = green.getThresholdInverted(75).getOr(green.getThreshold(100));
    
    WPIBinaryImage threshold = red.getAnd(green);
Reply With Quote