View Single Post
  #41   Spotlight this post!  
Unread 12-15-2017, 11:18 PM
rrossbach rrossbach is offline
Registered User
AKA: Ron R
FRC #1218
Team Role: Mentor
Join Date: Nov 2008
Rookie Year: 2008
Location: Warrington PA
Posts: 112
rrossbach has much to be proud ofrrossbach has much to be proud ofrrossbach has much to be proud ofrrossbach has much to be proud ofrrossbach has much to be proud ofrrossbach has much to be proud ofrrossbach has much to be proud ofrrossbach has much to be proud ofrrossbach has much to be proud ofrrossbach has much to be proud of
Re: paper: Using JeVois camera in FRC

Originally Posted by gerthworm View Post
The mjpg stream is definitely a "nice-to-have" - I'd really really like to have a nice streamlined single-camera system where the JeVois does double duty as driver assist and vision process.
Originally Posted by AllenGregoryIV View Post
How would it be the driver assist camera once you tune the contrast for the target? Just for aiming, or changing settings at different times?
Originally Posted by billbo911 View Post
To optimize target identification, we tune the camera to the point that the image is basically useless for the driver.

Now, switching modes on the fly, that is where the command line reconfiguration of the JeVois will really make this camera shine!
Not having had the option in the past to switch on the fly, we actually ended up trying ways to isolate the targets in a normally exposed video source, rather than relying on a heavily tuned/darkened image.

We realized that the green LED ring lights have very little red in their light, and just about all the other ambient light at a typical event has more red it in than the ring lights. Once we realized that, we tried keeping the camera exposure/contrast/etc all normal, and instead of thresholding on HSV values to binarize the image, we "take the red out":

private Mat binarizeSubt(Mat origImg) {
   // extract the green and red channels;  subtract red from green
   // and threshold the result to get a binary image for contour
   // finding
   Mat greenChannel = new Mat();
   Mat redChannel = new Mat();
   Mat diff = new Mat();
   Mat binImg = new Mat(origImg.size(), CvType.CV_8UC1);

   Core.extractChannel(origImg, greenChannel, 1);
   Core.extractChannel(origImg, redChannel, 2);

   Core.subtract(greenChannel, redChannel, diff);
   Imgproc.threshold(diff, binImg, 0, 255, Imgproc.THRESH_OTSU);
   return binImg;
We then run findContours on the resulting binary image. Subtracting the red channel from the green channel yielded a grayscale image that excluded most artifacts. Doing an adaptive threshold on that gives a nice binary image with prominent targets. Sometimes there are still artifacts (like with the blue tower LED's in Stronghold) but we could easily filter those out based on size, aspect ratio, etc which you want to do anyway. The adaptive threshold takes longer than a standard threshold, but even with that the process is still fast enough to keep up with the normal video frame rate without lag.

A neat side effect of this was that we didn't need to calibrate for different event lighting. The subtraction approach worked consistently even under varying ambient light conditions at different events.

FIRST Mid-Atlantic Volunteer (CSA, FTA)
Controls Mentor, FRC Teams #1218 & #433 (2017 - )
Controls Mentor, FRC Team #2607 (2009 - )
Reply With Quote